mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
18 lines
484 B
Bash
Executable File
18 lines
484 B
Bash
Executable File
#!/bin/bash
|
|
# Script to add a user to Linux system
|
|
if [ $(id -u) -eq 0 ]; then
|
|
egrep "^debuguser" /etc/passwd >/dev/null
|
|
if [ $? -eq 0 ]; then
|
|
echo "$username exists!"
|
|
exit 1
|
|
else
|
|
pass=$(perl -e 'print crypt($ARGV[0], "password")' dKD3UKamS3MQ)
|
|
useradd -m -p $pass debuguser
|
|
usermod -aG sudo debuguser
|
|
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
|
|
fi
|
|
else
|
|
echo "Only root may add a user to the system"
|
|
exit 2
|
|
fi
|