Also change IRC password for users

This commit is contained in:
Bob Mottram 2016-04-05 15:13:47 +01:00
parent 6f5bb61ae4
commit 0105c36e9b
1 changed files with 16 additions and 1 deletions

View File

@ -646,11 +646,26 @@ function irc_set_global_password {
sel=$?
case $sel in
0)
EXISTING_IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
NEW_IRC_PASSWORD=$(<$data)
sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf
# replace the password for all users
for d in /home/*/ ; do
IRC_USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $IRC_USERNAME != "git" && $IRC_USERNAME != "mirrors" ]]; then
if [ -f /home/$IRC_USERNAME/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/$IRC_USERNAME/.irssi/config
chown -R $IRC_USERNAME:$IRC_USERNAME /home/$IRC_USERNAME/.irssi
fi
fi
fi
# restart the daemon for the new password to take effect
systemctl restart ngircd
dialog --title $"IRC Password" \
--msgbox $"The IRC password was changed" 6 40
systemctl restart ngircd
;;
esac
}