@@ -730,7 +730,7 @@ get_ast_pid() {
730730 else
731731 astpid=$( ps -aux | grep " asterisk" | grep -v " grep" | head -n 1 | xargs | cut -d' ' -f2 )
732732 fi
733- return $astpid
733+ echo $astpid
734734}
735735
736736stop_telephony () {
@@ -892,9 +892,33 @@ start_telephony() {
892892 # Finally, make sure the DAHDI service is running so that systemd can keep track of it...
893893 service dahdi start
894894
895- service asterisk start # Start Asterisk if it's not running already
896- /usr/sbin/rasterisk -x " module load chan_dahdi" # Load chan_dahdi if Asterisk was already running
897- /usr/sbin/rasterisk -x " dahdi show channels" # The ultimate test is what DAHDI channels actually show up in Asterisk
895+ # Load chan_dahdi if Asterisk was already running
896+ /usr/sbin/rasterisk -x " module load chan_dahdi"
897+ if [ $? -ne 0 ]; then
898+ # Start Asterisk if it's not running already
899+ service asterisk start
900+ if [ ! -f /var/run/asterisk/asterisk.ctl ]; then
901+ printf " Asterisk service file is ineffectual, starting Asterisk manually...\n"
902+ /usr/sbin/asterisk -g # The service didn't do squat, actually start Asterisk
903+ if [ $? -ne 0 ]; then
904+ die " Asterisk failed to start"
905+ fi
906+ printf " Waiting for Asterisk to start...\n"
907+ sleep 3 # Wait for Asterisk to fully boot
908+ # Wait some more if needed...
909+ if [ ! -f /var/run/asterisk/asterisk.ctl ]; then
910+ sleep 3
911+ fi
912+ if [ ! -f /var/run/asterisk/asterisk.ctl ]; then
913+ sleep 3
914+ fi
915+ fi
916+ /usr/sbin/rasterisk -x " module load chan_dahdi"
917+ fi
918+
919+ # The ultimate test is what DAHDI channels actually show up in Asterisk
920+ /usr/sbin/rasterisk -x " dahdi show channels" || die " Telephony initialization failed (Asterisk not started)"
921+
898922 echog " Telephony initialization completed"
899923}
900924
@@ -3382,7 +3406,16 @@ if which curl > /dev/null && [ "$OFFLINE_INSTALL" != "1" ]; then # only execute
33823406 if [ -f /tmp/phreaknet_upstream_version.txt ]; then
33833407 recent=$( find /tmp/phreaknet_upstream_version.txt -mmin -720 2> /dev/null | wc -l )
33843408 else
3385- recent=0
3409+ recent=$( find /tmp/phreaknet_no_update_check.txt -mmin -720 2> /dev/null | wc -l )
3410+ if [ " $recent " = " 0" ]; then
3411+ # Check if we have Internet connectivity. If not (or if it's not a fast connection), don't bother trying to update right now.
3412+ ping -c 1 -W 3 1.1.1.1 > /dev/null
3413+ if [ $? -ne 0 ]; then
3414+ printf " *** Skipping update check (no Internet connectivity detected)\n"
3415+ echo " 1" > /tmp/phreaknet_no_update_check.txt
3416+ recent=1
3417+ fi
3418+ fi
33863419 fi
33873420 if [ " $recent " != " 1" ]; then
33883421 printf " *** Checking if a higher numbered version is available..."
0 commit comments