envs.net - main scripts and configs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
462 B

#!/usr/bin/env bash
if [ "$(id -u)" -ne "$(id -u znc)" ]; then
printf 'Please run as znc!\n' ; exit 1
fi
CONF='/srv/znc/.znc/configs/znc.conf'
PID="$(pgrep -u znc znc)"
if [ -z "$1" ]; then
echo -e "Usage: $(basename "$0") [username]" ; exit 1
fi
if grep -Fxq "<User $1>" "$CONF"; then
echo -e "znc user \"$1\" already exists" ; exit 1
fi
sed -e "s/NEWUSER/$1/g" /srv/znc/newuser.conf.template >> "$CONF"
[ -n "$2" ] && kill -s HUP "$PID"
exit 0