search if user has been added previously

This commit is contained in:
Blade of Darkness 2019-02-04 02:11:27 +00:00
parent 260bee58db
commit 4d345cf484
1 changed files with 12 additions and 2 deletions

View File

@ -7,9 +7,17 @@ PID=$(pgrep -u znc znc)
# $username and $password are retrieved from create-account script
if [[ -z $1 || -z $2 ]]
then
echo -e "Usage: $(basename $0) [username] [password] "
echo -e "Usage: $(basename $0) [username] [password]"
exit
if
fi
# search if $username has been added previously
if grep -iq $1 $CONF
then
echo -e "User: '$1' already exists"
exit
fi
username=$1
password=$2
@ -29,5 +37,7 @@ EOF
echo " </Pass>" >> $CONF
echo "</User>" >> $CONF
sleep 1
kill -s HUP $PID # Reload znc.conf
sleep 1
kill -s USR1 $PID # Rewrite znc.conf