瀏覽代碼

Also change IRC password for users

Bob Mottram 9 年之前
父節點
當前提交
0105c36e9b
共有 1 個檔案被更改,包括 16 行新增1 行删除
  1. 16
    1
      src/freedombone-controlpanel

+ 16
- 1
src/freedombone-controlpanel 查看文件

646
     sel=$?
646
     sel=$?
647
     case $sel in
647
     case $sel in
648
         0)
648
         0)
649
+            EXISTING_IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
649
             NEW_IRC_PASSWORD=$(<$data)
650
             NEW_IRC_PASSWORD=$(<$data)
650
             sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf
651
             sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf
652
+
653
+            # replace the password for all users
654
+            for d in /home/*/ ; do
655
+                IRC_USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
656
+                if [[ $IRC_USERNAME != "git" && $IRC_USERNAME != "mirrors" ]]; then
657
+                    if [ -f /home/$IRC_USERNAME/.irssi/config ]; then
658
+                        sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/$IRC_USERNAME/.irssi/config
659
+                        chown -R $IRC_USERNAME:$IRC_USERNAME /home/$IRC_USERNAME/.irssi
660
+                    fi                  
661
+                fi
662
+            fi
663
+
664
+            # restart the daemon for the new password to take effect
665
+            systemctl restart ngircd
666
+            
651
             dialog --title $"IRC Password" \
667
             dialog --title $"IRC Password" \
652
                    --msgbox $"The IRC password was changed" 6 40
668
                    --msgbox $"The IRC password was changed" 6 40
653
-            systemctl restart ngircd
654
             ;;
669
             ;;
655
     esac
670
     esac
656
 }
671
 }