Added disco-linux-ents ball, made users use it.

This commit is contained in:
2012-08-23 18:21:12 -04:00
parent ab74e27bb8
commit 4a5a7abcca
3 changed files with 47 additions and 12 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
DEL=""
ADD=""
MOD=""
GETENT=""
HOSTNAME=$(hostname)
if [ "$1" == "user" ]; then
GETENT="passwd"
DEL="userdel"
ADD="useradd"
MOD="usermod"
elif [ "$1" == "group" ]; then
GETENT="group"
DEL="groupdel"
ADD="groupadd"
MOD="groupmod"
fi
NAME="$2"
op="$3"
PARAMS=$(disco-param get ${HOSTNAME}/users/${op}/${NAME})
getent ${GETENT} | grep "^${NAME}" 2>&1 | disco-shutup
RETVAL=$?
if [ $RETVAL -eq 0 ] && [ "$op" == "absent" ]; then
${DEL} ${NAME}
elif [ $RETVAL -eq 0 ]; then
${MOD} ${PARAMS} ${NAME}
elif [ "$op" == "present" ]; then
${ADD} ${PARAMS} ${NAME}
fi
exit $?

1
balls/users/requires Normal file
View File

@@ -0,0 +1 @@
disco-linux-ents

View File

@@ -11,17 +11,15 @@
HOSTNAME=$(hostname)
for username in $(disco-param keys ${HOSTNAME}/users)
RETVAL=0
for op in present absent
do
NAME=$username
PARAMS=$(disco-param get ${HOSTNAME}/users/${NAME})
getent passwd | grep "^${NAME}" 2>&1 | disco-shutup
RETVAL=$?
if [ $RETVAL -eq 0 ] && [ "$PARAMS" == "" ]; then
userdel ${NAME}
elif [ $RETVAL -ne 0 ]; then
usermod ${PARAMS} ${NAME}
elif [ "$PARAMS" != "" ]; then
useradd ${PARAMS} ${NAME}
fi
for username in $(disco-param keys ${HOSTNAME}/users/${op})
do
disco-linux-ents user $username $op
RETVAL=$(expr $RETVAL + $?)
done
done
exit $RETVAL