znc user creation script

This commit is contained in:
Blade of Darkness 2019-01-08 21:27:30 +00:00
parent b2ef2a897f
commit c492a65ccb
1 changed files with 37 additions and 0 deletions

37
create-znc_account.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# To merge it with 'create-account':
# source create-znc_account/create-znc_account.sh
# to create backups?
# ZNC account creation
CONF='/var/lib/znc/.znc/configs/znc.conf'
# $username and $password are retrieved from create-account script
if [[ -z $username || -z $password ]] && [[ -z $1 || -z $2 ]]
then
echo -e "Usage: $(basename $0) [username] [password] "
exit
elif [[ -z $username && -z $password ]] || [[ -n $1 && -n $2 ]]
then
username=$1
password=$2
fi
pkill -10 -u znc znc # Rewrite znc.conf
# set username and password
sed s/newuser/$username/g znc_account.newconf >> $CONF
/usr/bin/expect << EOF | grep -E 'Hash|Salt' | tr -d \\r >> $CONF
spawn znc --makepass
expect "*Enter password: "
send "$password\r"
expect "*Confirm password: "
send "$password\r"
expect eof
EOF
echo ' </Pass>\n</User>' >> $CONF
pkill -1 -u znc znc # Reload znc.conf
pkill -10 -u znc znc # Rewrite znc.conf