From 4d345cf4845af8351f96f1d856f153cf36e035af Mon Sep 17 00:00:00 2001 From: Naglfar Date: Mon, 4 Feb 2019 02:11:27 +0000 Subject: [PATCH] search if user has been added previously --- create-znc_account.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/create-znc_account.sh b/create-znc_account.sh index ee2fb35..e1e93a7 100644 --- a/create-znc_account.sh +++ b/create-znc_account.sh @@ -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 " " >> $CONF echo "" >> $CONF +sleep 1 kill -s HUP $PID # Reload znc.conf +sleep 1 kill -s USR1 $PID # Rewrite znc.conf