Skip to content

Commit 2fc006f

Browse files
committed
install: Various Asterisk/DAHDI installation improvements.
* install: Target DAHDI 3.4.0. * install: Actually install res_msp. This module has been present in the repo but the entry to install it was never added. * install: Ensure the install_prereq function is run before the package manager is used for anything else. This prevents the optimization code of skipping package installation if the package manager was used recently from preventing these pre-reqs from being installed in the first place. * Remove DAHDI patches merged and present in DAHDI Linux 3.4.0. * Streamline/enhance commands for stopping/restarting DAHDI. * config: Update verify.conf with user variables. This file has always needed to be updated, but previously we weren't updating it, requiring the user to manually fix it afterwards. Resolves: #39 PHREAKSCRIPT-26 #close PHREAKSCRIPT-27 #close PHREAKSCRIPT-31 #close
1 parent 76dc808 commit 2fc006f

File tree

5 files changed

+84
-80
lines changed

5 files changed

+84
-80
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ A utility to automate the installation, maintenance, and debugging of Asterisk/D
33

44
PhreakScript installs:
55

6-
- Asterisk 21.2.0 (latest standard release[1] of Asterisk)
7-
- DAHDI Linux 3.3.0 (with optional DAHDI install flag)
8-
- DAHDI Tools 3.3.0 (with optional DAHDI install flag)
6+
- Asterisk 21.4.3 (latest standard release[1] of Asterisk)
7+
- DAHDI Linux 3.4.0 (with optional DAHDI install flag)
8+
- DAHDI Tools 3.4.0 (with optional DAHDI install flag)
99
- wanpipe 7.0.38 (with optional wanpipe install flag)
1010
- many additional features and stability improvements
1111
- Restores the "great purge" of DAHDI drivers that were removed in 2018 by Sangoma

patches/wcte12xp_base.diff

Lines changed: 0 additions & 10 deletions
This file was deleted.

patches/wcte12xp_types.diff

Lines changed: 0 additions & 19 deletions
This file was deleted.

phreaknet.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ the best Asterisk and DAHDI experience.
154154
**restart**
155155
: Fully restart DAHDI, wanpipe, and Asterisk
156156

157+
**stop**
158+
: Fully stop DAHDI, wanpipe, and Asterisk
159+
157160
**kill**
158161
: Forcibly kill Asterisk
159162

phreaknet.sh

Lines changed: 78 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22

33
# PhreakScript
4-
# (C) 2021-2023 Naveen Albert, PhreakNet, and others - https://github.com/InterLinked1/phreakscript ; https://portal.phreaknet.org ; https://docs.phreaknet.org
5-
# v1.1.3 (2024-03-17)
4+
# (C) 2021-2024 Naveen Albert, PhreakNet, and others - https://github.com/InterLinked1/phreakscript ; https://portal.phreaknet.org ; https://docs.phreaknet.org
5+
# v1.1.4 (2024-09-11)
66

77
# Setup (as root):
88
# cd /usr/local/src
@@ -13,6 +13,7 @@
1313
# phreaknet install
1414

1515
## Begin Change Log:
16+
# 2024-09-11 1.1.4 DAHDI: Target DAHDI 3.4.0, update patches
1617
# 2024-03-17 1.1.3 DAHDI: Only build wanpipe if requested
1718
# 2024-03-09 1.1.2 Asterisk: fix broken patches that no longer applied
1819
# 2024-01-12 1.1.1 Asterisk: target Asterisk 21.1.0-rc1, fix 'phreaknet restart' command
@@ -196,22 +197,18 @@ AST_SOURCE_NAME="asterisk-${AST_DEFAULT_MAJOR_VER}-current"
196197
AST_RC_SOURCE_NAME="asterisk-${AST_DEFAULT_MAJOR_VER}-testing-rc1"
197198
AST_RC_SOURCE_NAME2="asterisk-${AST_DEFAULT_MAJOR_VER}-testing-rc2"
198199

199-
DAHDI_VERSION="3.2.0"
200+
# DAHDI_MM_VER="${DAHDI_VERSION:0:1}${DAHDI_VERSION:2:1}" Requires bash
201+
DAHDI_MM_VER=34
202+
DAHDI_VERSION="3.4.0"
203+
#DAHLIN_SRC_NAME="dahdi-linux-${DAHDI_VERSION}.tar.gz"
204+
#DAHTOOL_SRC_NAME="dahdi-tools-${DAHDI_VERSION}.tar.gz"
205+
#DAHLIN_SRC_URL="https://github.com/asterisk/dahdi-linux/releases/download/v${DAHDI_VERSION}/${DAHLIN_SRC_NAME}"
206+
#DAHTOOL_SRC_URL="https://github.com/asterisk/dahdi-tools/releases/download/v${DAHDI_VERSION}/${DAHTOOL_SRC_NAME}"
200207
DAHLIN_SRC_NAME="dahdi-linux-current.tar.gz"
201208
DAHTOOL_SRC_NAME="dahdi-tools-current.tar.gz"
202209
DAHLIN_SRC_URL="http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz"
203210
DAHTOOL_SRC_URL="http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-current.tar.gz"
204211

205-
# Pull from GitHub for now, since 3.3.0 is only available there right now
206-
DAHDI_VERSION="3.3.0"
207-
DAHLIN_SRC_NAME="dahdi-linux-${DAHDI_VERSION}.tar.gz"
208-
DAHTOOL_SRC_NAME="dahdi-tools-${DAHDI_VERSION}.tar.gz"
209-
DAHLIN_SRC_URL="https://github.com/asterisk/dahdi-linux/releases/download/v${DAHDI_VERSION}/${DAHLIN_SRC_NAME}"
210-
DAHTOOL_SRC_URL="https://github.com/asterisk/dahdi-tools/releases/download/v${DAHDI_VERSION}/${DAHTOOL_SRC_NAME}"
211-
212-
# DAHDI_MM_VER="${DAHDI_VERSION:0:1}${DAHDI_VERSION:2:1}" Requires bash
213-
DAHDI_MM_VER=33
214-
215212
LIBPRI_SOURCE_NAME="libpri-1.6.1"
216213
LIBSS7_VERSION="2.0.1"
217214
WANPIPE_SOURCE_NAME="wanpipe-current" # wanpipe-latest (7.0.37.1, 2023-12-21)
@@ -349,7 +346,7 @@ phreakscript_info() {
349346
}
350347

351348
if [ "$1" = "commandlist" ]; then
352-
echo "about help version examples info wizard make man mancached install source experimental dahdi odbc installts fail2ban apiban freepbx pulsar sounds boilerplate-sounds ulaw remsil uninstall uninstall-all bconfig config keygen keyperms update astpr patch genpatch alembic freedisk topdir topdisk enable-swap disable-swap start restart kill forcerestart ban applist funclist dialplanfiles validate trace paste iaxping pcap pcaps sngrep enable-backtraces backtrace backtrace-only rundump threads reftrace valgrind cppcheck docverify runtests runtest stresstest ccache fullpatch docgen mkdocs pubdocs edit"
349+
echo "about help version examples info wizard make man mancached install source experimental dahdi odbc installts fail2ban apiban freepbx pulsar sounds boilerplate-sounds ulaw remsil uninstall uninstall-all bconfig config keygen keyperms update astpr patch genpatch alembic freedisk topdir topdisk enable-swap disable-swap start restart stop kill forcerestart ban applist funclist dialplanfiles validate trace paste iaxping pcap pcaps sngrep enable-backtraces backtrace backtrace-only rundump threads reftrace valgrind cppcheck docverify runtests runtest stresstest ccache fullpatch docgen mkdocs pubdocs edit"
353350
exit 0
354351
fi
355352

@@ -407,6 +404,7 @@ Commands:
407404
disable-swap Disable and deallocate temporary swap file
408405
start Fully start DAHDI, wanpipe, and Asterisk
409406
restart Fully restart DAHDI, wanpipe, and Asterisk
407+
stop Fully stop DAHDI, wanpipe, and Asterisk
410408
kill Forcibly kill Asterisk
411409
forcerestart Forcibly restart Asterisk
412410
ban Manually ban an IP address using iptables
@@ -554,25 +552,31 @@ stop_wanpipe() {
554552
fi
555553
}
556554

557-
# Completely restart wanpipe, DAHDI (and any DAHDI drivers), and Asterisk
558-
# This is surprisingly complicated, and can be dangerous if done incorrectly
559-
# $1 to restart without completely restarting Asterisk
560-
restart_telephony() {
561-
if [ "$1" = "1" ]; then
562-
rasterisk -x "module unload chan_dahdi" | grep "Unloaded chan_dahdi"
563-
if [ $? -ne 0 ]; then
564-
die "chan_dahdi could not be unloaded"
565-
fi
566-
else
567-
service asterisk stop # stop Asterisk
568-
astpid=$( ps -aux | grep "asterisk" | grep -v "grep" | head -n 1 | xargs | cut -d' ' -f2 )
569-
if [ "$astpid" != "" ]; then
570-
# if that didn't work, kill it manually
571-
kill -9 $astpid
572-
printf "Killed Asterisk process %s\n" "$astpid"
555+
stop_telephony() {
556+
astpid=$( ps -aux | grep "asterisk" | grep -v "grep" | head -n 1 | xargs | cut -d' ' -f2 )
557+
if [ "$astpid" != "" ]; then
558+
if [ "$1" = "1" ]; then
559+
# Only need to unload chan_dahdi if it's loaded
560+
rasterisk -x "module show like chan_dahdi" | grep "chan_dahdi"
561+
if [ $? -eq 0 ]; then
562+
rasterisk -x "module unload chan_dahdi" | grep "Unloaded chan_dahdi"
563+
if [ $? -ne 0 ]; then
564+
die "chan_dahdi could not be unloaded"
565+
fi
566+
fi
573567
else
574-
printf "Asterisk not currently running...\n"
568+
service asterisk stop # stop Asterisk
569+
astpid=$( ps -aux | grep "asterisk" | grep -v "grep" | head -n 1 | xargs | cut -d' ' -f2 )
570+
if [ "$astpid" != "" ]; then
571+
# if that didn't work, kill it manually
572+
kill -9 $astpid
573+
printf "Killed Asterisk process %s\n" "$astpid"
574+
else
575+
printf "Asterisk not currently running...\n"
576+
fi
575577
fi
578+
else
579+
printf "Asterisk not currently running...\n"
576580
fi
577581
lsmod | grep dahdi
578582
curdrivers=`lsmod | grep "dahdi " | xargs | cut -d' ' -f4-`
@@ -601,6 +605,9 @@ restart_telephony() {
601605
else
602606
printf "DAHDI is not running, skipping...\n"
603607
fi
608+
}
609+
610+
restart_start_telephony() {
604611
printf "Starting DAHDI...\n"
605612
start_wanpipe
606613
modprobe dahdi
@@ -630,7 +637,7 @@ restart_telephony() {
630637
dahdi_cfg
631638
if [ $? -ne 0 ]; then
632639
dahdi_hardware
633-
die "DAHDI failed to initialize... please try manually modprobe'ing the drivers."
640+
die "DAHDI failed to initialize... please try manually modprobe'ing the drivers and rerunning dahdi_genconf and dahdi_cfg."
634641
fi
635642
fi
636643
printf "DAHDI is now running normally...\n"
@@ -643,6 +650,14 @@ restart_telephony() {
643650
fi
644651
}
645652

653+
# Completely restart wanpipe, DAHDI (and any DAHDI drivers), and Asterisk
654+
# This is surprisingly complicated, and can be dangerous if done incorrectly
655+
# $1 to restart without completely restarting Asterisk
656+
restart_telephony() {
657+
stop_telephony "$1"
658+
restart_start_telephony
659+
}
660+
646661
# Mainly intended to start the telephony drivers on bootup, since this doesn't always happen automatically
647662
start_telephony() {
648663
# sed: Each one ends in - or +, need to ignore that
@@ -1314,15 +1329,6 @@ dahdi_unpurge() { # undo "great purge" of 2018: $1 = DAHDI_LIN_SRC_DIR
13141329
dahdi_undo $1 "devtype" "Remove struct devtype for unsupported drivers" "75620dd9ef6ac746745a1ecab4ef925a5b9e2988"
13151330
dahdi_undo $1 "wcb" "Remove support for all but wcb41xp wcb43xp and wcb23xp." "29cb229cd3f1d252872b7f1924b6e3be941f7ad3"
13161331
dahdi_undo $1 "wctdm" "Remove support for wctdm800, wcaex800, wctdm410, wcaex410." "a66e88e666229092a96d54e5873d4b3ae79b1ce3"
1317-
dahdi_undo $1 "wcte12xp" "Remove support for wcte12xp." "3697450317a7bd60bfa7031aad250085928d5c47"
1318-
dahdi_custom_patch "wcte12xp_base" "$1/drivers/dahdi/wcte12xp/base.c" "https://raw.githubusercontent.com/InterLinked1/phreakscript/master/patches/wcte12xp_base.diff" # bug fix for case statement fallthrough
1319-
dahdi_custom_patch "wcte12xp_types" "$1/drivers/dahdi/wcte12xp/base.c" "https://raw.githubusercontent.com/InterLinked1/phreakscript/master/patches/wcte12xp_types.diff" # bug fix for >= 5.16 stdbool.h
1320-
dahdi_undo $1 "wcte11xp" "Remove support for wcte11xp." "3748456d22122cf807b47d5cf6e2ff23183f440d"
1321-
if [ $DAHDI_MM_VER -lt 33 ]; then
1322-
dahdi_undo $1 "wctdm" "Remove support for wctdm." "04e759f9c5a6f76ed88bc6ba6446fb0c23c1ff55"
1323-
fi
1324-
dahdi_undo $1 "wct1xxp" "Remove support for wct1xxp." "dade6ac6154b58c4f5b6f178cc09de397359000b"
1325-
dahdi_undo $1 "wcfxo" "Remove support for wcfxo." "14198aee8532bbafed2ad1297177f8e0e0f13f50"
13261332

13271333
# The tor2 and pciradio patches do not revert cleanly on their own. We need to finish it off manually with additional patches:
13281334
dahdi_undo_force $1 "tor2" "Remove support for tor2." "60d058cc7a064b6e07889f76dd9514059c303e0f"
@@ -1609,7 +1615,8 @@ install_dahdi() {
16091615
wget https://github.com/asterisk/libss7/archive/refs/tags/${LIBSS7_VERSION}.tar.gz
16101616
tar -zxvf ${LIBSS7_VERSION}.tar.gz
16111617
rm ${LIBSS7_VERSION}.tar.gz
1612-
cd ${LIBSS7_VERSION}
1618+
ls -la
1619+
cd libss7-${LIBSS7_VERSION}
16131620
make && make install
16141621

16151622
# Wanpipe
@@ -1618,6 +1625,9 @@ install_dahdi() {
16181625
fi
16191626

16201627
service dahdi restart
1628+
1629+
# Completion message for users just running "phreaknet dahdi"
1630+
echog "DAHDI and friends have finished installing"
16211631
}
16221632

16231633
install_wanpipe() {
@@ -1865,6 +1875,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
18651875

18661876
phreak_tree_module "res/res_digitmap.c"
18671877
phreak_tree_module "res/res_irc.c"
1878+
phreak_tree_module "res/res_msp.c"
18681879
phreak_tree_module "res/res_phreaknet.c"
18691880
phreak_tree_module "res/res_pjsip_presence.c"
18701881

@@ -1929,9 +1940,17 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
19291940

19301941
# Unmerged patches
19311942
git_patch "app_confbridge_Fix_bridge_shutdown_race_condition.patch" # app_confbridge: Fix bridge shutdown race condition
1943+
1944+
## WIP
19321945
asterisk_pr_unconditional 292 # GROUP VARs
19331946
asterisk_pr_unconditional 414 # IAX2 loopback warning
19341947

1948+
# Unmerged
1949+
asterisk_pr_unconditional 272 # Call Waiting Deluxe
1950+
asterisk_pr_unconditional 438 # Last Number Redial
1951+
1952+
### TODO: Include ASTERISK-30339 and ASTERISK-30374 once resubmitted on GitHub
1953+
19351954
if [ "$RTPULSING" = "1" ]; then
19361955
# Patches split up to make it easier to selectively redo the 2nd one if a patch conflict occurs and the patch needs to be rebased.
19371956
git_patch "ast_rtoutpulsing1.diff" # chan_dahdi: add rtoutpulsing
@@ -2759,6 +2778,11 @@ elif [ "$cmd" = "install" ]; then
27592778
if [ "$PKG_AUDIT" = "1" ]; then
27602779
pkg_before=$( apt list --installed )
27612780
fi
2781+
# Install Pre-Reqs
2782+
printf "%s %d\n" "Starting installation with country code" $AST_CC
2783+
quell_mysql
2784+
printf "%s\n" "Installing prerequisites..."
2785+
install_prereq # This must be done before any other packages are installed since we'll skip package install checks if package manager was used recently.
27622786
if [ "$DEVMODE" = "1" ]; then
27632787
# Install the Linux headers if we can, but don't abort if we can't.
27642788
apt-get install -y linux-headers-`uname -r`
@@ -2784,11 +2808,6 @@ elif [ "$cmd" = "install" ]; then
27842808
fi
27852809
fi
27862810
cd $AST_SOURCE_PARENT_DIR
2787-
# Install Pre-Reqs
2788-
printf "%s %d\n" "Starting installation with country code" $AST_CC
2789-
quell_mysql
2790-
printf "%s\n" "Installing prerequisites..."
2791-
install_prereq
27922811
# Get DAHDI
27932812
if [ "$CHAN_DAHDI" = "1" ]; then
27942813
if [ ! -d /etc/dahdi ] || [ "$FORCE_INSTALL" = "1" ]; then
@@ -3404,12 +3423,16 @@ elif [ "$cmd" = "config" ]; then
34043423
printf "%s: %s\n" "PhreakNet CLLI code" $PHREAKNET_CLLI
34053424
printf "%s\n" "InterLinked API key seems to be of valid format, not displaying for security reasons..."
34063425
install_boilerplate
3407-
## Inject user config (CLLI code, API key)
34083426
if [ "$inject" = "1" ]; then
3427+
## Inject user config (CLLI code, API key)
34093428
sed -i "s/abcdefghijklmnopqrstuvwxyz/$INTERLINKED_APIKEY/g" $AST_CONFIG_DIR/$EXTENSIONS_CONF_FILE
34103429
sed -i "s/WWWWXXYYZZZ/$PHREAKNET_CLLI/g" $AST_CONFIG_DIR/$EXTENSIONS_CONF_FILE
34113430
sed -i "s/5551111/$PHREAKNET_DISA/g" $AST_CONFIG_DIR/$EXTENSIONS_CONF_FILE
34123431
printf "Updated [globals] in %s/extensions.conf with dynamic variables. If globals are stored in a different file, manual updating is required." $AST_CONFIG_DIR
3432+
## Also update verify.conf
3433+
sed -i "s/HSTNTXMOCG0/$PHREAKNET_CLLI/g" $AST_CONFIG_DIR/verify.conf
3434+
sed -i "s/5551111/$PHREAKNET_DISA/g" $AST_CONFIG_DIR/verify.conf
3435+
printf "Updated %s/verify.conf" $AST_CONFIG_DIR
34133436
fi
34143437
printf "%s\n" "Boilerplate config installed! Note that these files may still require manual editing before use."
34153438
elif [ "$cmd" = "bconfig" ]; then
@@ -3674,6 +3697,13 @@ elif [ "$cmd" = "restart" ]; then
36743697
else
36753698
restart_telephony 1
36763699
fi
3700+
elif [ "$cmd" = "stop" ]; then
3701+
# not really forcing install of anything, but to use the --force flag
3702+
if [ "$FORCE_INSTALL" = "1" ]; then
3703+
stop_telephony 0
3704+
else
3705+
stop_telephony 1
3706+
fi
36773707
elif [ "$cmd" = "start" ]; then
36783708
start_telephony
36793709
elif [ "$cmd" = "edit" ]; then

0 commit comments

Comments
 (0)