Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active May 3, 2016 14:25
Show Gist options
  • Save chmouel/8980ce4564073a35bc3c to your computer and use it in GitHub Desktop.
Save chmouel/8980ce4564073a35bc3c to your computer and use it in GitHub Desktop.
Script to add user, to copy and paste in your irc buffer to create the user as admin and send the other part to the user for infos
#!/bin/bash
USER=$1
REALNAME=$2
PASS=$(pwgen -B -s -n 12 1)
if [[ -z ${USER} || -z ${REALNAME} ]];then
echo "znc-add-user.sh: login realname"
exit 1
fi
# Configure these variables !
ZNC_SERVER=zncserver.host
ZNC_PORT=3223
IRC_NETWORK="Freenode"
IRC_SERVER_PORT="irc.freenode.net 6667"
# To copy as znc admin in your chat channel
cat <<EOF
/msg *controlpanel adduser $USER ${PASS}
/msg *controlpanel set nick $USER $USER
/msg *controlpanel set altnick $USER $USER
/msg *controlpanel set ident $USER $USER
/msg *controlpanel set realname $USER $REALNAME
/msg *controlpanel set multiclients $USER true
/msg *controlpanel set denysetbindhost $USER true
/msg *controlpanel set defaultchanmodes $USER +nt
/msg *controlpanel set admin $USER false
/msg *controlpanel set autoclearchanbuffer $USER true
/msg *controlpanel set password $USER ${PASS}
/msg *controlpanel set quitmsg $USER Nonobot should live
/msg *controlpanel set maxnetworks $USER 1
/msg *controlpanel addctcp $USER VERSION http://nonobot
/msg *controlpanel addnetwork $USER ${IRC_NETWORK}
/msg *controlpanel addserver $USER ${IRC_NETWORK} ${IRC_SERVER_PORT}
/msg *controlpanel loadmodule $USER chansaver
/msg *controlpanel loadmodule $USER controlpanel
/msg *status saveconfig
EOF
# To give to user
cat <<EOF
User for ${REALNAME}:
Server: ${ZNC_SERVER}
Port: ${ZNC_PORT}
SSL: True
SSL Verify: Off
Password: ${USER}/${IRC_NETWORK}:${PASS}
Web Interface: https://${ZNC_SERVER}:${ZNC_PORT}
Username: ${USER}
Password: ${PASS}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment