| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/bin/bash
- # Licence : GPL v3
- # Author: Laurent HUBERT
- #
- # Creates a new user for administrative purposes (in sudo group)
- #
- cat <<EOF
- ##################################
- # Creating default user #
- ##################################
- EOF
- read -p "Please enter default user name: " the_user
- if [ -n "$the_user" ]
- then
- echo Creating user $the_user
- # Creates the user but disable the login to set the password later:
- adduser --gecos ,,,, --disabled-login $the_user
- status=$?
- else
- # Exit with non zero status
- exit 1
- fi
- if [ 0 -ne "$status" ]
- then
- echo "Error creating $the_user"
- echo "Please try again by rebooting"
- else
- adduser $the_user sudo
- fi
- status=1
- while [ 0 -ne "$status" ]
- do
- passwd $the_user
- status=$?
- if [ 0 -ne "$status" ]
- then
- echo "Error changing $the_user password"
- echo "Please try again"
- else
- cat <<EOF
- ************************************
- * $the_user : created successfully *
- ************************************
- EOF
- exit 0
- fi
- done
- echo "An error occurred changing $the_user password"
- exit $status
|