Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #################################################################
- ################## Create User mongod ################
- #################################################################
- #Creates mongod group and user with password
- #call the script with password for mongod as arguements
- ROOT_UID=0
- SUCCESS=0
- E_USEREXISTS=70
- # Run as root
- if [ "$UID" -ne "$ROOT_UID" ]
- then
- echo "Must be root to run this script."
- exit $E_NOTROOT
- fi
- #test, if argument is there
- if [ $# -eq 1 ]; then
- group=mongod
- username=mongod
- pass=$1
- # Check if user already exists.
- grep -q "$username" /etc/passwd
- if [ $? -eq $SUCCESS ]
- then
- echo "User $username does already exist."
- echo "please chose another username."
- exit $E_USEREXISTS
- fi
- groupadd $group
- useradd -p $pass -d /home/$username -m -g $group -s /bin/bash $username
- echo "the account is setup"
- else
- echo " this programm needs 2 arguments you have given $# "
- echo " you have to call the script $0 password"
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement