Browse Source

Separate function for sipwitch daemon update

Bob Mottram 9 years ago
parent
commit
616b874bb4
1 changed files with 37 additions and 34 deletions
  1. 37
    34
      src/freedombone

+ 37
- 34
src/freedombone View File

@@ -10218,6 +10218,42 @@ function install_voip {
10218 10218
     echo 'install_voip' >> $COMPLETION_FILE
10219 10219
 }
10220 10220
 
10221
+function update_sipwitch_daemon {
10222
+    if [ ! -f /etc/init.d/sipwitch ]; then
10223
+        return
10224
+    fi
10225
+    service sipwitch stop
10226
+
10227
+    # remove the original sipwitch daemon if it exists
10228
+    if [ -f /etc/init.d/sipwitch ]; then
10229
+        rm -f /etc/init.d/sipwitch
10230
+    fi
10231
+
10232
+    # daemon
10233
+    echo '[Unit]' > /etc/systemd/system/sipwitch.service
10234
+    echo 'Description=GNU SIP Witch, a SIP telephony service daemon.' >> /etc/systemd/system/sipwitch.service
10235
+    echo 'After=network.target' >> /etc/systemd/system/sipwitch.service
10236
+    echo '' >> /etc/systemd/system/sipwitch.service
10237
+    echo '[Service]' >> /etc/systemd/system/sipwitch.service
10238
+    echo 'Type=simple' >> /etc/systemd/system/sipwitch.service
10239
+    echo 'Group=sipwitch' >> /etc/systemd/system/sipwitch.service
10240
+    echo 'PIDFile=/var/run/sipwitch/pidfile' >> /etc/systemd/system/sipwitch.service
10241
+    echo 'EnvironmentFile=-/etc/conf.d/sipwitch' >> /etc/systemd/system/sipwitch.service
10242
+    echo 'EnvironmentFile=-/etc/sipwitch.conf' >> /etc/systemd/system/sipwitch.service
10243
+    echo 'EnvironmentFile=-/etc/default/sipwitch' >> /etc/systemd/system/sipwitch.service
10244
+    echo 'ExecStartPre=-/bin/rm -f /var/run/sipwitch/control' >> /etc/systemd/system/sipwitch.service
10245
+    echo 'ExecStart=/usr/sbin/sipw -f $OPTIONS' >> /etc/systemd/system/sipwitch.service
10246
+    echo 'Restart=always' >> /etc/systemd/system/sipwitch.service
10247
+    echo 'NotifyAccess=main' >> /etc/systemd/system/sipwitch.service
10248
+    echo '' >> /etc/systemd/system/sipwitch.service
10249
+    echo '[Install]' >> /etc/systemd/system/sipwitch.service
10250
+    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/sipwitch.service
10251
+
10252
+    systemctl enable sipwitch
10253
+    systemctl daemon-reload
10254
+    systemctl start sipwitch
10255
+}
10256
+
10221 10257
 function install_sip {
10222 10258
     if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
10223 10259
         return
@@ -10289,40 +10325,6 @@ function install_sip {
10289 10325
         echo "SIP onion domain:$SIP_ONION_HOSTNAME" >> $COMPLETION_FILE
10290 10326
     fi
10291 10327
 
10292
-    systemctl stop sipwitch
10293
-
10294
-    # Note: the existing sipwitch init daemon doesn't appear to work well
10295
-    # so here we replace it with a systemd one
10296
-
10297
-    # remove the original sipwitch daemon if it exists
10298
-    if [ -f /etc/init.d/sipwitch ]; then
10299
-        rm -f /etc/init.d/sipwitch
10300
-    fi
10301
-
10302
-    # daemon
10303
-    echo '[Unit]' > /etc/systemd/system/sipwitch.service
10304
-    echo 'Description=GNU SIP Witch, a SIP telephony service daemon.' >> /etc/systemd/system/sipwitch.service
10305
-    echo 'After=network.target' >> /etc/systemd/system/sipwitch.service
10306
-    echo '' >> /etc/systemd/system/sipwitch.service
10307
-    echo '[Service]' >> /etc/systemd/system/sipwitch.service
10308
-    echo 'Type=simple' >> /etc/systemd/system/sipwitch.service
10309
-    echo 'Group=sipwitch' >> /etc/systemd/system/sipwitch.service
10310
-    echo 'PIDFile=/var/run/sipwitch/pidfile' >> /etc/systemd/system/sipwitch.service
10311
-    echo 'EnvironmentFile=-/etc/conf.d/sipwitch' >> /etc/systemd/system/sipwitch.service
10312
-    echo 'EnvironmentFile=-/etc/sipwitch.conf' >> /etc/systemd/system/sipwitch.service
10313
-    echo 'EnvironmentFile=-/etc/default/sipwitch' >> /etc/systemd/system/sipwitch.service
10314
-    echo 'ExecStartPre=-/bin/rm -f /var/run/sipwitch/control' >> /etc/systemd/system/sipwitch.service
10315
-    echo 'ExecStart=/usr/sbin/sipw -f $OPTIONS' >> /etc/systemd/system/sipwitch.service
10316
-    echo 'Restart=always' >> /etc/systemd/system/sipwitch.service
10317
-    echo 'NotifyAccess=main' >> /etc/systemd/system/sipwitch.service
10318
-    echo '' >> /etc/systemd/system/sipwitch.service
10319
-    echo '[Install]' >> /etc/systemd/system/sipwitch.service
10320
-    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/sipwitch.service
10321
-
10322
-    systemctl enable sipwitch
10323
-    systemctl daemon-reload
10324
-    systemctl start sipwitch
10325
-
10326 10328
     if ! grep -q $"SIP Server" /home/$MY_USERNAME/README; then
10327 10329
         echo '' >> /home/$MY_USERNAME/README
10328 10330
         echo '' >> /home/$MY_USERNAME/README
@@ -10491,6 +10493,7 @@ install_irc_server
10491 10493
 configure_firewall_for_irc
10492 10494
 install_voip
10493 10495
 install_sip
10496
+update_sipwitch_daemon
10494 10497
 install_wiki
10495 10498
 install_blog
10496 10499
 mark_blog_domain