revision... i'll better use while, cases and getopts :)
This commit is contained in:
parent
3ab1ba0d21
commit
546a0c479e
1 changed files with 82 additions and 17 deletions
99
ffuseradd.sh
99
ffuseradd.sh
|
@ -1,23 +1,88 @@
|
|||
#!/bin/bash
|
||||
|
||||
NMEUSR=$1
|
||||
EMLUSR=$2
|
||||
GRPUSR=$3
|
||||
ADDUSR="$(which useradd) -m -G"
|
||||
#NMEUSR=$1
|
||||
#EMLUSR=$2
|
||||
#GRPUSR=$3
|
||||
#ADDUSR="$(which useradd) -m"
|
||||
|
||||
|
||||
if [ "$NMEUSR" = "" ]; then
|
||||
echo -e "\nUSAGE: ffuseradd <USERNAME>... [EMAIL ADDRESS]... [GROUP]... \nUsername is\
|
||||
necessary!\nEmail address and group are optional.\nGroups for example: sudo,www-user. Ever add multible groups \",\" separated! Leave it blank for standard user."
|
||||
exit
|
||||
else
|
||||
if [ "$EMLUSR" = "" ]; then
|
||||
echo -e "You entered username:\n Username: "$NMEUSR"\n Email address: none"
|
||||
else
|
||||
echo -e "You entered username:\n Username: "$NMEUSR"\n Email address: "$EMLUSR""
|
||||
fi
|
||||
fi
|
||||
# Usage info
|
||||
|
||||
#if [ "$NMEUSR" = "" ]; then
|
||||
# echo -e "\nUSAGE: ffuseradd <USERNAME>... [EMAIL ADDRESS]... [GROUP]... \nUsername is\
|
||||
# necessary!\nEmail address and group are optional.\nGroups for example: sudo,www-user. Ever add multible groups \",\" separated! Leave it blank for standard user."
|
||||
# exit
|
||||
#else
|
||||
# if [ "$EMLUSR" = "" ]; then
|
||||
# echo -e "You entered:\n Username: "$NMEUSR"\n Email address: none"
|
||||
# else
|
||||
# echo -e "You entered:\n Username: "$NMEUSR"\n Email address: "$EMLUSR""
|
||||
# fi
|
||||
#fi
|
||||
|
||||
# Adding user
|
||||
echo -e "\nadding user "$NMEUSR" with "$ADDUSR""
|
||||
echo $GRPUSR
|
||||
|
||||
#echo -e "\nadding user "$NMEUSR" with "$ADDUSR" "$GRPUSR" "$NMEUSR""
|
||||
|
||||
###################
|
||||
### UND NOCHMAL ###
|
||||
###################
|
||||
|
||||
usage()
|
||||
{
|
||||
cat<<EOF
|
||||
usage: $0 -u <USERNAME> -[e|g]options
|
||||
|
||||
This script adds a new user and includes his public key into the users home
|
||||
|
||||
OPTIONS:
|
||||
-h show this message
|
||||
-u set username
|
||||
-e set new users email address
|
||||
-g set additional group(s) for the new user
|
||||
EOF
|
||||
}
|
||||
|
||||
NMEUSR=
|
||||
EMLUSR=
|
||||
GROUSR=
|
||||
VERBOSE=
|
||||
|
||||
while getopts "h:u:e:g:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
h)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
u)
|
||||
NMEUSR=$OPTARG
|
||||
;;
|
||||
e)
|
||||
EMLUSR=$OPTARG
|
||||
;;
|
||||
g)
|
||||
GRPUSR=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $NMEUSR ]] || [[ -z $EMLUSR ]] || [[ -z $GRPUSR ]]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#while getopts u:e:g: option
|
||||
#do
|
||||
# case "${option}"
|
||||
# in
|
||||
# u) NMEUSR=${OPTARG};;
|
||||
# e) EMLUSR=${OPTARG};;
|
||||
# g) GRPUSR=${OPTARG};;
|
||||
# esac
|
||||
#done
|
||||
|
||||
#echo $NMEUSR
|
||||
#echo $EMLUSR
|
||||
#echo $GRPUSR
|
||||
|
|
Loading…
Reference in a new issue