Added the groups module to create linux groups, renamed disco-linux-ents to entities

This commit is contained in:
2012-08-23 18:40:06 -04:00
parent 4a5a7abcca
commit e121bc09e1
3 changed files with 27 additions and 0 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 $?