Skip to content

Commit 2571432

Browse files
authored
install: Improve robustness of various install procedures. (#44)
* res_alarmsystem.conf.sample: Comment out config, to avoid newly built systems having this module enabled by default. * wanpipe: Install missing pre-reqs if needed. * wanpipe: Use more proper arguments for Setup script. * wanpipe: Don't ignore install failures. wanpipe is not installed by default anymore and should compile successfully on kernels through 6.1.0. To work around this, users can force continuing the install if needed using --force, or install on kernels <= 6.1.0. * No CI is being added, since GitHub uses the 6.8.0-1015-azure kernel for builds, which is newer than 6.1.0. * install: Disable yappcap from building if the test suite fails to build initially. This is deprecated and not needed for all tests. * install: Fix misimplementation of --fast flag. A nice value was set, but not actually used anywhere, which actually resulted in builds being slower with this flag. Also pull this out to the top of the script, so that all compilation is affected. PHREAKSCRIPT-42 #close PHREAKSCRIPT-48 #close
1 parent 6580b64 commit 2571432

File tree

2 files changed

+125
-108
lines changed

2 files changed

+125
-108
lines changed

configs/samples/res_alarmsystem.conf.sample

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,44 @@
1414

1515
; *** Server configuration
1616

17-
[general]
18-
bindport=4589 ; UDP port to which alarm server will bind, if any servers are enabled.
17+
;[general]
18+
;bindport=4589 ; UDP port to which alarm server will bind, if any servers are enabled.
1919
;bindaddr=0.0.0.0
2020

21-
[myserver] ; Defines an alarm server to which alarm clients can report.
22-
type = server
23-
ip_loss_tolerance = 60 ; Number of seconds the server will tolerate not receiving pings from clients before considering
21+
;[myserver] ; Defines an alarm server to which alarm clients can report.
22+
;type = server
23+
;ip_loss_tolerance = 60 ; Number of seconds the server will tolerate not receiving pings from clients before considering
2424
; IP connectivity to a client to have been lost (which will trigger the internet_lost alarm).
25-
contexts = myserver-contexts ; A config section which defines dialplan contexts to execute for each alarm event
26-
logfile = /var/log/asterisk/alarm_server.log ; Log file for this server
25+
;contexts = myserver-contexts ; A config section which defines dialplan contexts to execute for each alarm event
26+
;logfile = /var/log/asterisk/alarm_server.log ; Log file for this server
2727

28-
[clients] ; Special section defining clients authorized to report to this server
28+
;[clients] ; Special section defining clients authorized to report to this server
2929
;A101 = 1D7B ; one entry for each client, with client ID as the key and client PIN as the value
3030

3131
; *** Client configuration
3232

33-
[myclient] ; Each alarm client is defined in its own section
34-
type = client
35-
client_id = A101 ; Unique, telenumeric ID (0-9,A-D) for this client. Should be unique across all clients that report to a server.
33+
;[myclient] ; Each alarm client is defined in its own section
34+
;type = client
35+
;client_id = A101 ; Unique, telenumeric ID (0-9,A-D) for this client. Should be unique across all clients that report to a server.
3636
; Note that there is no security mechanism to restrict reporting aside from the client ID.
3737
; Therefore, if the alarm server is exposed to the Internet, you may wish to use long, hard-to-guess client IDs
3838
; to prevent spoofed reports, or lock down your firewall accordingly.
3939
;client_pin=1D794B61 ; PIN, if required by server for authentication
40-
server_ip = 127.0.0.1:4589 ; IP/port to reach alarm server over IP
41-
server_dialstr = DAHDI/g1/*70w18005551212 ; A dial string for "POTS phone failover" to reach alarm server if unable to by IP. If you need to use dial options, use a Local channel to encapsulate the Dial() call.
40+
;server_ip = 127.0.0.1:4589 ; IP/port to reach alarm server over IP
41+
;server_dialstr = DAHDI/g1/*70w18005551212 ; A dial string for "POTS phone failover" to reach alarm server if unable to by IP. If you need to use dial options, use a Local channel to encapsulate the Dial() call.
4242
; The server should call AlarmEventReceiver() (NOT AlarmReceiver() !!!) when receiving such a call.
4343
; NOTE: When reporting an alarm trigger, the line will stay open until disarm_delay has been reached, to avoid making multiple calls in succession
44-
phone_hangup_delay = 45 ; Number of seconds to keep phone failover line open upon reporting event for reporting further events in that time.
44+
;phone_hangup_delay = 45 ; Number of seconds to keep phone failover line open upon reporting event for reporting further events in that time.
4545
; It is recommended this setting be at least 10-15 seconds, so that if phone failover is being used,
4646
; a single phone call is sufficient to report sensor trigger and alarm disarm events, rather than dialing up a second time to report this event.
4747
; You may want to tweak this based on the cost of each call, cost per minute, and the acceptable amount of delay in setting up a call. Default is 45.
48-
ping_interval = 4 ; How often to ping the server
49-
egress_delay = 15 ; number of seconds grace period to exit without re-triggering alarm
50-
contexts = myclient-contexts ; A config section which defines dialplan contexts to execute for each alarm event
51-
logfile = /var/log/asterisk/alarm_myclient.log ; Log file to which to log alarm events.
48+
;ping_interval = 4 ; How often to ping the server
49+
;egress_delay = 15 ; number of seconds grace period to exit without re-triggering alarm
50+
;contexts = myclient-contexts ; A config section which defines dialplan contexts to execute for each alarm event
51+
;logfile = /var/log/asterisk/alarm_myclient.log ; Log file to which to log alarm events.
5252

53-
[myclient-contexts]
54-
type = contexts
53+
;[myclient-contexts]
54+
;type = contexts
5555
; In this section, the key is the name of the alarm event for which the specified dialplan will be executed,
5656
; and the value is the dialplan [exten@]context to execute. If exten is omitted, s will be used. The priority will always be 1.
5757
;
@@ -64,20 +64,20 @@ type = contexts
6464
; internet_lost = iplost@myclientalarm ; Internet connectivity to alarm peer lost
6565
; internet_restored = iprestored@myclientalarm ; Internet connectivity to alarm peer restored
6666

67-
[door] ; Section defining a door sensor
68-
type = sensor
69-
sensor_id = 1 ; Unique, numeric ID for this sensor. Should be unique across all sensors belongng to all clients that report to a server.
70-
client = myclient ; Client associated with this sensor
71-
device = DAHDI/23 ; if specified, then arg2 to AlarmSensor is optional since we can use the channel to determine which sensor was activated
67+
;[door] ; Section defining a door sensor
68+
;type = sensor
69+
;sensor_id = 1 ; Unique, numeric ID for this sensor. Should be unique across all sensors belongng to all clients that report to a server.
70+
;client = myclient ; Client associated with this sensor
71+
;device = DAHDI/23 ; if specified, then arg2 to AlarmSensor is optional since we can use the channel to determine which sensor was activated
7272
; (This way, the same context can be specified for all sensors, using immediate=yes in chan_dahdi.conf)
73-
disarm_delay = 45 ; Number of seconds grace period permitted to disarm an active alarm after this sensor triggers before it is considered a breach.
73+
;disarm_delay = 45 ; Number of seconds grace period permitted to disarm an active alarm after this sensor triggers before it is considered a breach.
7474
; Default is 60.
7575

76-
[keypad] ; Section defining alarm keypad settings. An alarm keypad can be instantiated by using AlarmKeypad()
77-
type = keypad
78-
client = myclient ; Client associated with these keypad settings
79-
keypad_device = PJSIP/Polycom ; dial string for alarm keypad endpoints to autodial when alarm is triggered. Use a Local channel for predial options to autoanswer.
80-
pin = 1234 ; Hardcoded PIN which must be entered to disarm the alarm. Multiple PINs can be permitted by providing multiple comma-separated PINs.
81-
audio = custom/siren ; An optional audio file to play while waiting for the alarm to be disarmed. By default, a tone is played.
82-
cid_num = DISARM SYSTEM NOW ; Caller ID number to use for outgoing calls to the keypad device
83-
cid_name = ALARM PANEL ; Caller ID name to use for outgoing calls to the keypad device
76+
;[keypad] ; Section defining alarm keypad settings. An alarm keypad can be instantiated by using AlarmKeypad()
77+
;type = keypad
78+
;client = myclient ; Client associated with these keypad settings
79+
;keypad_device = PJSIP/Polycom ; dial string for alarm keypad endpoints to autodial when alarm is triggered. Use a Local channel for predial options to autoanswer.
80+
;pin = 1234 ; Hardcoded PIN which must be entered to disarm the alarm. Multiple PINs can be permitted by providing multiple comma-separated PINs.
81+
;audio = custom/siren ; An optional audio file to play while waiting for the alarm to be disarmed. By default, a tone is played.
82+
;cid_num = DISARM SYSTEM NOW ; Caller ID number to use for outgoing calls to the keypad device
83+
;cid_name = ALARM PANEL ; Caller ID name to use for outgoing calls to the keypad device

phreaknet.sh

Lines changed: 91 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# PhreakScript
44
# (C) 2021-2024 Naveen Albert, PhreakNet, and others - https://github.com/InterLinked1/phreakscript ; https://portal.phreaknet.org ; https://docs.phreaknet.org
5-
# v1.1.7 (2024-09-19)
5+
# v1.1.8 (2024-10-16)
66

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

1515
## Begin Change Log:
16+
# 2024-10-16 1.1.8 wanpipe: Installation procedure improvements
1617
# 2024-09-19 1.1.7 DAHDI: Slipstream critical build fixes, fix build issues on various distros and kernels
1718
# 2024-09-16 1.1.6 DAHDI: Add patch to enable building of XPP drivers on 32-bit architectures
1819
# 2024-09-15 1.1.5 DAHDI: Massive overhaul to DAHDI stop/start/restart logic, fixes for manual span assignment
@@ -211,7 +212,7 @@ DAHTOOL_SRC_URL="http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-t
211212

212213
LIBPRI_SOURCE_NAME="libpri-1.6.1"
213214
LIBSS7_VERSION="2.0.1"
214-
WANPIPE_SOURCE_NAME="wanpipe-current" # wanpipe-latest (7.0.37.1, 2023-12-21)
215+
WANPIPE_SOURCE_NAME="wanpipe-current" # wanpipe-latest (7.0.38, 2024-02-05)
215216
ODBC_VER="3.1.14"
216217
CISCO_CM_SIP="cisco-usecallmanager-18.15.0"
217218
MIN_ARGS=1
@@ -1300,6 +1301,15 @@ install_testsuite_itself() {
13001301
cd $AST_SOURCE_PARENT_DIR
13011302
cd testsuite
13021303
./setupVenv.sh
1304+
1305+
if [ $? -ne 0 ]; then
1306+
# Test suite failed to compile.
1307+
# Disable yappcap and try again. This is an old library that no longer compiles on newer systems, e.g. Ubuntu 24.04
1308+
echoerr "Test suite failed to install, disabling yappcap and trying again..."
1309+
sed -i 's|^https://github.com/asterisk/yappcap|#https://github.com/asterisk/yappcap|' extras.txt
1310+
./setupVenv.sh # Retry
1311+
fi
1312+
13031313
# ./runInVenv.sh python3 ./runtests.py -t tests/channels/iax2/basic-call/ # run a single basic test
13041314
#./runInVenv.sh python3 ./runtests.py -l # list all tests
13051315

@@ -1545,6 +1555,74 @@ linux_headers_install_apt() {
15451555
fi
15461556
}
15471557

1558+
install_wanpipe() {
1559+
MYSOURCEDIR=/lib/modules/$(uname -r)/build
1560+
MYSOURCEDIRORIG=$MYSOURCEDIR
1561+
MYINCLUDEDIR=/usr/src/linux-headers-$(uname -r)/include
1562+
1563+
ensure_installed flex # required for wancfg
1564+
ensure_installed bison # required for wanpipe
1565+
ensure_installed libtool # required for libsangoma
1566+
1567+
# wanpipe currently fails to install on Debian because the wanpipe Setup.sh doesn't support recursive Makefile includes.
1568+
# Explicitly find the right source directory to use if that's the case.
1569+
# XXX See below: I don't think this is fully correct at the moment, since SOURCEDIR in wanpipe's Setup.sh is used for multiple, unrelated things.
1570+
while true; do
1571+
printf "Checking file: %s\n" "$MYSOURCEDIR/Makefile" >&2
1572+
if [ ! -f "$MYSOURCEDIR/Makefile" ]; then
1573+
echoerr "File $MYSOURCEDIR/Makefile does not exist\n"
1574+
break
1575+
fi
1576+
1577+
# POSIX sh doesn't support ${var:x:y} syntax
1578+
contents=$( cat "$MYSOURCEDIR/Makefile" )
1579+
first7=$( echo "$contents" | cut -d" " -f1 )
1580+
if [ "${first7}" = "include" ]; then
1581+
nextfile=$( echo "$contents" | cut -d" " -f2 )
1582+
printf "Following include to %s\n" "${nextfile}" >&2
1583+
MYSOURCEDIR=`dirname "${nextfile}"`
1584+
else
1585+
printf "Actual makefile is %s\n" "$MYSOURCEDIR/Makefile" >&2
1586+
break
1587+
fi
1588+
done
1589+
1590+
cd $AST_SOURCE_PARENT_DIR
1591+
# Sangoma clearly doesn't know how to run a web server, since their server keeps going down.
1592+
# Pull tarball from Wayback Machine if Sangoma's is unresponsive
1593+
wget --tries=1 https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME}.tgz
1594+
if [ $? -ne 0 ]; then
1595+
# Note: This link needs to be updated for new versions of wanpipe
1596+
wget https://web.archive.org/web/20240708051349/https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME}.tgz
1597+
fi
1598+
tar xvfz ${WANPIPE_SOURCE_NAME}.tgz
1599+
WANPIPE_DIR=`tar -tzf $WANPIPE_SOURCE_NAME.tgz | head -1 | cut -f1 -d"/"`
1600+
cd ${WANPIPE_DIR}
1601+
if [ $? -ne 0 ]; then
1602+
die "Failed to download/extract wanpipe"
1603+
fi
1604+
rm ${AST_SOURCE_PARENT_DIR}/${WANPIPE_SOURCE_NAME}.tgz
1605+
#phreak_fuzzy_patch "af_wanpipe.diff"
1606+
1607+
#./Setup dahdi --silent
1608+
./Setup install --silent # Even if Setup dahdi fails, this can work
1609+
1610+
if [ $? -ne 0 ]; then
1611+
echoerr "wanpipe install failed: unsupported kernel?"
1612+
# No need to cat setup_drv_compile.log here, Setup automatically does so on failure
1613+
# XXX wanpipe currently fails to compile on kernels newer than 6.1.0. See [PHREAKSCRIPT-49]
1614+
if [ "$IGNORE_FAILURES" = "1" ]; then
1615+
printf "Installation of other items will proceed anyways...\n"
1616+
sleep 1
1617+
else
1618+
exit 1
1619+
fi
1620+
else
1621+
wanrouter stop
1622+
wanrouter start
1623+
fi
1624+
}
1625+
15481626
install_dahdi() {
15491627
# Install the kernel headers
15501628
if [ "$KSRC" = "" ]; then
@@ -1863,67 +1941,6 @@ install_dahdi() {
18631941
echog "DAHDI and friends have finished installing"
18641942
}
18651943

1866-
install_wanpipe() {
1867-
MYSOURCEDIR=/lib/modules/$(uname -r)/build
1868-
MYSOURCEDIRORIG=$MYSOURCEDIR
1869-
MYINCLUDEDIR=/usr/src/linux-headers-$(uname -r)/include
1870-
1871-
# wanpipe currently fails to install on Debian because the wanpipe Setup.sh doesn't support recursive Makefile includes.
1872-
# Explicitly find the right source directory to use if that's the case.
1873-
# XXX See below: I don't think this is fully correct at the moment, since SOURCEDIR in wanpipe's Setup.sh is used for multiple, unrelated things.
1874-
while true; do
1875-
printf "Checking file: %s\n" "$MYSOURCEDIR/Makefile" >&2
1876-
if [ ! -f "$MYSOURCEDIR/Makefile" ]; then
1877-
echoerr "File $MYSOURCEDIR/Makefile does not exist\n"
1878-
break
1879-
fi
1880-
1881-
# POSIX sh doesn't support ${var:x:y} syntax
1882-
contents=$( cat "$MYSOURCEDIR/Makefile" )
1883-
first7=$( echo "$contents" | cut -d" " -f1 )
1884-
if [ "${first7}" = "include" ]; then
1885-
nextfile=$( echo "$contents" | cut -d" " -f2 )
1886-
printf "Following include to %s\n" "${nextfile}" >&2
1887-
MYSOURCEDIR=`dirname "${nextfile}"`
1888-
else
1889-
printf "Actual makefile is %s\n" "$MYSOURCEDIR/Makefile" >&2
1890-
break
1891-
fi
1892-
done
1893-
1894-
cd $AST_SOURCE_PARENT_DIR
1895-
# Sangoma clearly doesn't know how to run a web server, since their server keeps going down.
1896-
# Pull tarball from Wayback Machine if Sangoma's is unresponsive
1897-
wget --tries=1 https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME}.tgz
1898-
if [ $? -ne 0 ]; then
1899-
wget https://web.archive.org/web/20240103031741/https://ftp.sangoma.com/linux/current_wanpipe/${WANPIPE_SOURCE_NAME}.tgz
1900-
fi
1901-
tar xvfz ${WANPIPE_SOURCE_NAME}.tgz
1902-
WANPIPE_DIR=`tar -tzf $WANPIPE_SOURCE_NAME.tgz | head -1 | cut -f1 -d"/"`
1903-
cd ${WANPIPE_DIR}
1904-
if [ $? -ne 0 ]; then
1905-
die "Failed to download/extract wanpipe"
1906-
fi
1907-
rm ${AST_SOURCE_PARENT_DIR}/${WANPIPE_SOURCE_NAME}.tgz
1908-
#phreak_fuzzy_patch "af_wanpipe.diff"
1909-
1910-
./Setup dahdi --silent
1911-
1912-
if [ $? -ne 0 ]; then
1913-
echoerr "wanpipe install failed: unsupported kernel?"
1914-
IGNORE_FAILURES=1 # XXX: For now, remove once wanpipe is more reliable
1915-
if [ "$IGNORE_FAILURES" = "1" ]; then
1916-
printf "Installation of other items will proceed anyways...\n"
1917-
sleep 1
1918-
else
1919-
exit 1
1920-
fi
1921-
else
1922-
wanrouter stop
1923-
wanrouter start
1924-
fi
1925-
}
1926-
19271944
phreak_tree_module() { # $1 = file to patch, $2 = whether failure is acceptable
19281945
printf "Adding new module: %s\n" "$1"
19291946
wget -q "https://raw.githubusercontent.com/InterLinked1/phreakscript/master/$1" -O "$AST_SOURCE_PARENT_DIR/$AST_SRC_DIR/$1" --no-cache
@@ -2163,7 +2180,6 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
21632180
printf "Applying patches applicable to %s -> %d (~%s)\n" "$AST_ALT_VER" "$AST_MM_VER" "$AST_MAJOR_VER"
21642181

21652182
## merged into master, not yet in a release version (use asterisk_pr_if, e.g. asterisk_pr_if 399 210100 200600 182100)
2166-
#git_custom_patch "https://github.com/InterLinked1/asterisk/commit/d389a0b14569ab60daac73391e66d57fbbabdadb.diff" # astfd compiler fix
21672183
asterisk_pr_if 901 220100 210600 182600 # astfd compiler fix
21682184
asterisk_pr_if 903 220100 210600 182600 # voicemail pager email fix
21692185

@@ -2190,8 +2206,8 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
21902206
asterisk_pr_unconditional 414 # IAX2 loopback warning
21912207

21922208
# Unmerged
2193-
asterisk_pr_unconditional 272 # Call Waiting Deluxe
2194-
asterisk_pr_unconditional 438 # Last Number Redial
2209+
#asterisk_pr_unconditional 272 # Call Waiting Deluxe. This also now conflicts (with the latest revisions), so temp. disabled.
2210+
#asterisk_pr_unconditional 438 # Last Number Redial. This now conflicts with 272, so temp. disabled.
21952211

21962212
### TODO: Include ASTERISK-30339 and ASTERISK-30374 once resubmitted on GitHub
21972213

@@ -2811,6 +2827,10 @@ while true; do
28112827
esac
28122828
done
28132829

2830+
if [ "$FAST_COMPILE" = "1" ]; then
2831+
AST_MAKE="nice -15 $AST_MAKE" # -15 to speed up compilation by increasing CPU priority.
2832+
fi
2833+
28142834
if [ "$FLAG_TEST" = "1" ]; then
28152835
echog "Flag test successful."
28162836
exit 0
@@ -3200,10 +3220,7 @@ elif [ "$cmd" = "install" ]; then
32003220
gmake
32013221
cd ../..
32023222
fi
3203-
niceval=""
3204-
if [ "$FAST_COMPILE" = "1" ]; then
3205-
niceval="-15" # -15 to speed up compilation by increasing CPU priority.
3206-
fi
3223+
32073224
if [ "$OS_DIST_INFO" = "FreeBSD" ]; then
32083225
# For some reason, %%LIBSYSINFO%% is in the linking flags on FreeBSD, remove that from being added. libsysinfo is needed though.
32093226
# Same with HAVE_CRYPT_R, that's not available but gets detected, so undetect it
@@ -3212,14 +3229,14 @@ elif [ "$cmd" = "install" ]; then
32123229
sed -i '' '/HAVE_CRYPT_R/d' include/asterisk/autoconfig.h
32133230
sed -i "" -e 's|WRAP_LIBC_MALLOC|ASTMM_LIBC ASTMM_REDIRECT|g' addons/mp3/interface.c # for format_mp3
32143231
sed -i "" -e 's|\\s|s|g' build_tools/make_xml_documentation # fix sed command in this script to remove the backslash for BSD sed
3215-
nice $AST_MAKE "ASTLDFLAGS=-lcrypt -lsysinfo" main
3232+
$AST_MAKE "ASTLDFLAGS=-lcrypt -lsysinfo" main
32163233
if [ $? -eq 0 ]; then
3217-
nice $AST_MAKE -j$(nproc) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
3234+
$AST_MAKE -j$(nproc) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
32183235
fi
32193236
else
3220-
nice $AST_MAKE -j$(nproc) main # compile 'main' subdirectory first
3237+
$AST_MAKE -j$(nproc) main # compile 'main' subdirectory first
32213238
if [ $? -eq 0 ]; then
3222-
nice $AST_MAKE -j$(nproc) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
3239+
$AST_MAKE -j$(nproc) # compile Asterisk. This is the longest step, if you are installing for the first time. Also, don't let it take over the server.
32233240
fi
32243241
fi
32253242

0 commit comments

Comments
 (0)