toastie89 1 year ago
parent
commit
70b2125701
1 changed files with 18 additions and 0 deletions
  1. 18 0
      create-users.sh

+ 18 - 0
create-users.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+test -f /etc/users.list || exit 0
+
+while read id username hash groups; do
+        # Skip, if user already exists
+        grep ^$username /etc/passwd && continue
+        # Create group
+        addgroup --gid $id $username
+        # Create user
+        useradd -m -u $id -s /bin/bash -g $username $username
+        # Set password
+        echo "$username:$hash" | /usr/sbin/chpasswd -e
+        # Add supplemental groups
+        if [ $groups ]; then
+                usermod -aG $groups $username
+        fi
+done < /etc/users.list