Browse Source

Check if irc user already exists before adding

Bob Mottram 8 years ago
parent
commit
f15580cc3e
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      src/freedombone-app-irc

+ 8
- 1
src/freedombone-app-irc View File

@@ -193,6 +193,13 @@ function add_user_irc_bouncer {
193 193
     ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk -F ' ' '{print $1}' | cut -c1-20)"
194 194
     new_user_hash=$(echo -n "${new_user_password}${ZNC_SALT}" | sha256sum | awk -F ' ' '{print $1}')
195 195
 
196
+    if grep -q "<User ${new_username}>" /home/znc/.znc/configs/znc.conf; then
197
+        # user already exists
198
+        sed -i "s|Hash = .*|Hash = ${new_user_hash}|g" /home/znc/.znc/configs/znc.conf
199
+        sed -i "s|Salt = .*|Salt = ${ZNC_SALT}|g" /home/znc/.znc/configs/znc.conf
200
+        return
201
+    fi
202
+
196 203
     echo "<User ${new_username}>" >> /home/znc/.znc/configs/znc.conf
197 204
     echo "    Admin      = ${is_admin}" >> /home/znc/.znc/configs/znc.conf
198 205
     echo "    AltNick = ${new_username}_" >> /home/znc/.znc/configs/znc.conf
@@ -300,7 +307,7 @@ function irc_set_global_password {
300 307
     dialog --title $"IRC Password" \
301 308
            --clear \
302 309
            --backtitle $"Freedombone Control Panel" \
303
-           --passwordbox $"Password for all IRC users, or press Enter for no password" 10 50 2> $data
310
+           --passwordbox $"Password for all IRC users, or press Enter for no password" 10 60 2> $data
304 311
     sel=$?
305 312
     case $sel in
306 313
         0)