Browse Source

To torify the irc server, or not to torify the irc server? That is the question.

Bob Mottram 9 years ago
parent
commit
339789c5e1
2 changed files with 33 additions and 5 deletions
  1. 19
    3
      src/freedombone
  2. 14
    2
      src/freedombone-controlpanel

+ 19
- 3
src/freedombone View File

@@ -6874,13 +6874,17 @@ function install_irc_client {
6874 6874
     echo '  {' >> /home/$MY_USERNAME/.irssi/config
6875 6875
     if [[ $ONION_ONLY == 'no' ]]; then
6876 6876
         echo "    address = \"${DEFAULT_DOMAIN_NAME}\";" >> /home/$MY_USERNAME/.irssi/config
6877
+        echo "    port = \"${IRC_PORT}\";" >> /home/$MY_USERNAME/.irssi/config
6878
+        echo '    use_ssl = "yes";' >> /home/$MY_USERNAME/.irssi/config
6877 6879
     else
6878 6880
         IRC_ONION_HOSTNAME=$(cat $COMPLETION_FILE | grep "IRC onion domain" | awk -F ':' '{print $2}')
6879 6881
         echo "    address = \"${IRC_ONION_HOSTNAME}\";" >> /home/$MY_USERNAME/.irssi/config
6882
+        echo "    port = \"${IRC_ONION_PORT}\";" >> /home/$MY_USERNAME/.irssi/config 
6883
+        echo '    use_ssl = "no";' >> /home/$MY_USERNAME/.irssi/config
6884
+        sed -i "s/;Ports =.*/Ports = $IRC_PORT, $IRC_ONION_PORT/1" /etc/ngircd/ngircd.conf
6885
+        systemctl restart ngircd
6880 6886
     fi
6881 6887
     echo '    chatnet = "Freedombone";' >> /home/$MY_USERNAME/.irssi/config
6882
-    echo "    port = \"${IRC_PORT}\";" >> /home/$MY_USERNAME/.irssi/config
6883
-    echo '    use_ssl = "yes";' >> /home/$MY_USERNAME/.irssi/config
6884 6888
     echo '    ssl_verify = "no";' >> /home/$MY_USERNAME/.irssi/config
6885 6889
     echo '    autoconnect = "yes";' >> /home/$MY_USERNAME/.irssi/config
6886 6890
     if [ $IRC_PASSWORD ]; then
@@ -7011,7 +7015,19 @@ function install_irc_server {
7011 7015
         echo "IRC onion domain:$IRC_ONION_HOSTNAME" >> $COMPLETION_FILE
7012 7016
     fi
7013 7017
 
7014
-    systemctl restart ngircd
7018
+    systemctl stop ngircd
7019
+    if [ ! -f /lib/systemd/system/ngircd.service ]; then
7020
+        echo $'No systemd daemon found for ngircd'
7021
+        exit 82528
7022
+    fi
7023
+    
7024
+    if [[ $ONION_ONLY == 'no' ]]; then
7025
+        sed -i 's|ExecStart.*|ExecStart=/usr/sbin/ngircd|g' /lib/systemd/system/ngircd.service
7026
+    else
7027
+        sed -i 's|ExecStart.*|ExecStart=/usr/bin/torify /usr/sbin/ngircd|g' /lib/systemd/system/ngircd.service
7028
+    fi  
7029
+    systemctl daemon-reload
7030
+    systemctl start ngircd
7015 7031
 
7016 7032
     # keep the daemon running
7017 7033
     echo '' >> /usr/bin/$WATCHDOG_SCRIPT_NAME

+ 14
- 2
src/freedombone-controlpanel View File

@@ -742,6 +742,12 @@ function change_ssh_public_key {
742 742
 }
743 743
 
744 744
 function irc_via_onion {
745
+    if [ ! -f /lib/systemd/system/ngircd.service ]; then
746
+        dialog --title $"IRC Server" \
747
+               --msgbox $"ngircd systemd daemon not found" 8 50
748
+        return
749
+    fi
750
+    
745 751
     dialog --title $"IRC Server" \
746 752
            --backtitle $"Freedombone Control Panel" \
747 753
            --defaultno \
@@ -760,13 +766,19 @@ function irc_via_onion {
760 766
                 sed -i "s/Ports = $IRC_PORT, $IRC_ONION_PORT/;Ports = $IRC_PORT, $IRC_ONION_PORT/1" /etc/ngircd/ngircd.conf
761 767
             fi
762 768
         fi
763
-        systemctl restart ngircd
769
+        systemctl stop ngircd
770
+        sed -i 's|ExecStart.*|ExecStart=/usr/sbin/ngircd|g' /lib/systemd/system/ngircd.service
771
+        systemctl daemon-reload
772
+        systemctl start ngircd
764 773
         dialog --title $"IRC Server" \
765 774
                --msgbox $"The IRC server can now be accessed via SSL at your main domain name" 8 50
766 775
     else
767 776
         if grep -q ";Ports = $IRC_PORT, $IRC_ONION_PORT" /etc/ngircd/ngircd.conf; then
768 777
             sed -i "s/;Ports =.*/Ports = $IRC_PORT, $IRC_ONION_PORT/1" /etc/ngircd/ngircd.conf
769
-            systemctl restart ngircd
778
+            systemctl stop ngircd
779
+            sed -i 's|ExecStart.*|ExecStart=/usr/bin/torify /usr/sbin/ngircd|g' /lib/systemd/system/ngircd.service
780
+            systemctl daemon-reload
781
+            systemctl start ngircd
770 782
         fi
771 783
         dialog --title $"IRC Server" \
772 784
                --msgbox $"The IRC server can now be accessed via its onion address without SSL" 8 50