@@ -554,15 +554,23 @@ stop_wanpipe() {
554
554
555
555
# Completely restart wanpipe, DAHDI (and any DAHDI drivers), and Asterisk
556
556
# This is surprisingly complicated, and can be dangerous if done incorrectly
557
+ # $1 to restart without completely restarting Asterisk
557
558
restart_telephony () {
558
- service asterisk stop # stop Asterisk
559
- astpid=$( ps -aux | grep " asterisk" | grep -v " grep" | head -n 1 | xargs | cut -d' ' -f2 )
560
- if [ " $astpid " != " " ]; then
561
- # if that didn't work, kill it manually
562
- kill -9 $astpid
563
- printf " Killed Asterisk process %s\n" " $astpid "
559
+ if [ " $1 " = " 1" ]; then
560
+ rasterisk -x " module unload chan_dahdi" | grep " Unloaded chan_dahdi"
561
+ if [ $? -ne 0 ]; then
562
+ die " chan_dahdi could not be unloaded"
563
+ fi
564
564
else
565
- printf " Asterisk not currently running...\n"
565
+ service asterisk stop # stop Asterisk
566
+ astpid=$( ps -aux | grep " asterisk" | grep -v " grep" | head -n 1 | xargs | cut -d' ' -f2 )
567
+ if [ " $astpid " != " " ]; then
568
+ # if that didn't work, kill it manually
569
+ kill -9 $astpid
570
+ printf " Killed Asterisk process %s\n" " $astpid "
571
+ else
572
+ printf " Asterisk not currently running...\n"
573
+ fi
566
574
fi
567
575
lsmod | grep dahdi
568
576
curdrivers=` lsmod | grep " dahdi " | xargs | cut -d' ' -f4-`
@@ -624,9 +632,13 @@ restart_telephony() {
624
632
fi
625
633
fi
626
634
printf " DAHDI is now running normally...\n"
627
- service asterisk start
628
- astpid=$( ps -aux | grep " asterisk" | grep -v " grep" | head -n 1 | xargs | cut -d' ' -f2 )
629
- printf " Asterisk now running on pid %s\n" " $astpid "
635
+ if [ " $1 " = " 1" ]; then
636
+ rasterisk -x " module load chan_dahdi"
637
+ else
638
+ service asterisk start
639
+ astpid=$( ps -aux | grep " asterisk" | grep -v " grep" | head -n 1 | xargs | cut -d' ' -f2 )
640
+ printf " Asterisk now running on pid %s\n" " $astpid "
641
+ fi
630
642
}
631
643
632
644
# Mainly intended to start the telephony drivers on bootup, since this doesn't always happen automatically
@@ -3624,7 +3636,12 @@ elif [ "$cmd" = "forcerestart" ]; then
3624
3636
echog " Successfully started Asterisk again."
3625
3637
fi
3626
3638
elif [ " $cmd " = " restart" ]; then
3627
- restart_telephony
3639
+ # not really forcing install of anything, but to use the --force flag
3640
+ if [ " $FORCE_INSTALL " = " 1" ]; then
3641
+ restart_telephony 0
3642
+ else
3643
+ restart_telephony 1
3644
+ fi
3628
3645
elif [ " $cmd " = " start" ]; then
3629
3646
start_telephony
3630
3647
elif [ " $cmd " = " edit" ]; then
0 commit comments