summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-handle_users.inc
diff options
context:
space:
mode:
authorroot2014-06-30 15:21:04 +0200
committerroot2014-06-30 15:21:04 +0200
commit9aabe45d6e2865dcc95e4a6f5823c9310904b1e9 (patch)
tree2b53f43e95d3944b73864f4e5995a75ab42a61b0 /satellit_installer/includes/10-handle_users.inc
downloadsetup-scripts-9aabe45d6e2865dcc95e4a6f5823c9310904b1e9.tar.gz
setup-scripts-9aabe45d6e2865dcc95e4a6f5823c9310904b1e9.tar.xz
setup-scripts-9aabe45d6e2865dcc95e4a6f5823c9310904b1e9.zip
[SSPS] Satellite server preparation script. Further heavy debugging needed -
this is just the first checkin after tidying to server as a starting point.
Diffstat (limited to 'satellit_installer/includes/10-handle_users.inc')
-rw-r--r--satellit_installer/includes/10-handle_users.inc31
1 files changed, 31 insertions, 0 deletions
diff --git a/satellit_installer/includes/10-handle_users.inc b/satellit_installer/includes/10-handle_users.inc
new file mode 100644
index 0000000..79ad9eb
--- /dev/null
+++ b/satellit_installer/includes/10-handle_users.inc
@@ -0,0 +1,31 @@
+add_group() {
+ echo -n "# Adding group: $1, gid $2..."
+ groupadd -g "$2" "$1" 2>/dev/null || echo "Could not add group $1 / gid $2!"
+ echo "ok."
+}
+
+add_user() {
+ echo -n "# Adding user: $1, uid $2, to gid $3..."
+ useradd -u "$2" -m -d /home/"$1" -s /bin/bash -g "$3" "$1" 2>/dev/null \
+ || echo "Could not add user ${1}/${2} / gid $3!"
+ echo "ok."
+}
+
+
+kill_user() {
+ echo -n "# Terminating user account id $1, leaving user home/files as they were: "
+ userdel $(getent passwd "$1" | cut -f 1 -d ":") || echo "# could not kill userid ${1}!"
+ echo "ok."
+}
+
+check_users() {
+ echo "#"
+ echo "# Checking for users to kill with id>=1000: "
+ for userid in $(cat /etc/passwd|cut -f 3 -d ":"|sort -n); do
+ case $userid in
+ 65534) echo "# Ignoring user 65534/sync." ;;
+ *) [ "$userid" -ge 1000 ] && kill_user "$userid"
+ esac
+ done
+}
+