Compare commits
2 Commits
6148484b4f
...
04e79c6279
Author | SHA1 | Date |
---|---|---|
deicidus | 04e79c6279 | 1 year ago |
deicidus | 50cc345591 | 1 year ago |
2 changed files with 27 additions and 1 deletions
@ -0,0 +1,26 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
# User information |
||||||
|
USERNAME="$1" |
||||||
|
PASSWORD="$2" |
||||||
|
USER_DIRECTORY="./users/$USERNAME" |
||||||
|
|
||||||
|
# Check if the username and password are provided |
||||||
|
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then |
||||||
|
echo "Username and password are required." |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
# Create the user (-m creates their home directory) |
||||||
|
sudo useradd -m "$USERNAME" |
||||||
|
|
||||||
|
# Check if the user was created successfully |
||||||
|
if [ $? -ne 0 ]; then |
||||||
|
echo "Failed to create user." |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
# Set the password |
||||||
|
echo "$USERNAME:$PASSWORD" | sudo chpasswd |
||||||
|
|
||||||
|
echo "User $USERNAME created successfully." |
Loading…
Reference in new issue