Rewrite autocluster in Python
[tridge/autocluster.git] / base / all / root / scripts / tasks / setup_node_nas.sh
1 #!/bin/bash
2
3 # Per-node NAS cluster configuration steps
4
5 set -e
6
7 conf_file="/root/scripts/nas.conf"
8
9 auth_type=$(sed -r -n -e 's@^auth_method[[:space:]]*=[[:space:]]*(files|winbind)[[:space:]]*$@\1@p' "$conf_file")
10
11 case "$auth_type" in
12     winbind|files) : ;;
13     *)
14         echo "Unsupported authentication type \"${auth_type}\""
15         usage
16 esac
17
18 domain=$(sed -r -n -e 's@^domain[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file" | tr '[a-z]' '[A-Z]')
19
20 kdc=$(sed -r -n -e 's@^kdc[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file")
21
22 case "$auth_type" in
23     winbind)
24         echo "Setting up NSS, PAM, KRB5..."
25         authconfig --update --nostart \
26             --enablewinbindauth --enablewinbind \
27             --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
28         ;;
29     files)
30         echo "Setting up NSS, PAM, KRB5..."
31         authconfig --update --nostart \
32             --disablewinbindauth --disablewinbind \
33             --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
34         ;;
35 esac
36
37 echo "Configuring services..."
38 (cd scripts/cluster_configure && \
39     ./cluster-configure.py -t "templates/rhel/" -vv "$conf_file")