瀏覽代碼

Changing the irc server password

Bob Mottram 8 年之前
父節點
當前提交
645959f0fa
共有 1 個文件被更改,包括 23 次插入0 次删除
  1. 23
    0
      src/freedombone-app-irc

+ 23
- 0
src/freedombone-app-irc 查看文件

293
                 fi
293
                 fi
294
             done
294
             done
295
 
295
 
296
+            read_config_param DEFAULT_DOMAIN_NAME
297
+            read_config_param IRC_PORT
298
+            read_config_param MY_USERNAME
299
+
300
+            stop_irc_bouncer
301
+            sleep 2
302
+
303
+            # change the hashes. There are multiple users, but since we're using a global
304
+            # password this doesn't matter
305
+            ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk -F ' ' '{print $1}' | cut -c1-20)"
306
+            new_user_hash=$(echo -n "${NEW_IRC_PASSWORD}${ZNC_SALT}" | sha256sum | awk -F ' ' '{print $1}')
307
+            sed -i "s|Hash = .*|Hash = ${new_user_hash}|g" /home/znc/.znc/configs/znc.conf
308
+            sed -i "s|Salt = .*|Salt = ${ZNC_SALT}|g" /home/znc/.znc/configs/znc.conf
309
+
310
+            # change the server password
311
+            sed -i "s|Server     = ${DEFAULT_DOMAIN_NAME}.*|Server     = ${DEFAULT_DOMAIN_NAME} ${IRC_PORT} ${NEW_IRC_PASSWORD}|g" /home/znc/.znc/configs/znc.conf
312
+
313
+            # Update the password in the readme
314
+            sed -i "s|IRC login password.*|IRC login password: $NEW_IRC_PASSWORD|g" /home/$MY_USERNAME/README
315
+
316
+            write_config_param "IRC_PASSWORD" "$NEW_IRC_PASSWORD"
317
+
296
             # restart the daemon for the new password to take effect
318
             # restart the daemon for the new password to take effect
297
             systemctl restart ngircd
319
             systemctl restart ngircd
320
+            start_irc_bouncer
298
 
321
 
299
             dialog --title $"IRC Password" \
322
             dialog --title $"IRC Password" \
300
                    --msgbox $"The IRC password was changed" 6 40
323
                    --msgbox $"The IRC password was changed" 6 40