Skip to content

Commit 363e8ab

Browse files
committed
install: Add option to install radio modules.
Add an option (--rpt) to install the radio modules (e.g. app_rpt, etc.). These modules used to be in the Asterisk tree, but were removed in commit asterisk/asterisk@4585000 and a few other commits. The modules are currently being maintained in a third-party repo, and this option pulls the files into the source tree.
1 parent adab607 commit 363e8ab

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

phreaknet.sh

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ CHAN_SIP=0
242242
ENHANCED_CHAN_SIP=0
243243
SIP_CISCO=0
244244
CHAN_SCCP=0
245+
RPT_MODULES=0
245246
CHAN_DAHDI=0
246247
DAHDI_OLD_DRIVERS=0
247248
EMPULSE=1 # Automatically enable EMPULSE, cause why not?
@@ -606,6 +607,7 @@ Options:
606607
--lightweight install: Only install basic, required modules for basic Asterisk functionality
607608
--alsa install: Ensure ALSA library detection exists in the build system. This does NOT readd the deprecated/removed chan_alsa module.
608609
--cisco install: Add full support for Cisco Call Manager phones (chan_sip only)
610+
--rpt install: Add radio repeater modules
609611
--sccp install: Install chan_sccp channel driver (Cisco Skinny)
610612
--drivers install: Also install DAHDI drivers removed in 2018
611613
--generic install: Use generic kernel headers that do not match the installed kernel version
@@ -951,13 +953,16 @@ install_prereq() {
951953
PREREQ_PACKAGES="$PREREQ_PACKAGES libnewt-dev dwarves"
952954
fi
953955
if [ "$1" = "1" ]; then
954-
PREREQ_PACKAGES="$PREREQ_PACKAGES curl subversion libcurl4-openssl-dev"
956+
PREREQ_PACKAGES="$PREREQ_PACKAGES curl subversion libcurl4-openssl-dev libvpb1"
955957
if [ "$ENHANCED_INSTALL" = "1" ]; then
956958
PREREQ_PACKAGES="$PREREQ_PACKAGES dnsutils bc mpg123 ntp tcpdump festival"
957959
fi
958960
if [ "$DEVMODE" = "1" ]; then
959961
PREREQ_PACKAGES="$PREREQ_PACKAGES xmlstarlet" # only needed in developer mode for doc validation.
960962
fi
963+
if [ "$RPT_MODULES" = "1" ]; then
964+
PREREQ_PACKAGES="$PREREQ_PACKAGES libusb-dev"
965+
fi
961966
fi
962967
PREREQ_PACKAGES="$PREREQ_PACKAGES libedit-dev" # Ubuntu also needs this package
963968
# apt-get install libcurl3-gnutls=7.64.0-4+deb10u2 # fix git clone not working: upvoted comment at https://superuser.com/a/1642989
@@ -1499,9 +1504,12 @@ dahdi_patch() {
14991504

15001505
git_patch() {
15011506
printf "Applying git patch: %s\n" "$1"
1507+
if [ "$GIT_REPO_PATH" = "" ]; then
1508+
die "Variable GIT_REPO_PATH is empty... bug!"
1509+
fi
15021510
cp "$GIT_REPO_PATH/patches/$1" "/tmp/$1"
15031511
if [ $? -ne 0 ]; then
1504-
die "File $1 does not exist"
1512+
die "File $GIT_REPO_PATH/patches/$1 does not exist"
15051513
fi
15061514
git apply "/tmp/$1"
15071515
if [ $? -ne 0 ]; then
@@ -2333,8 +2341,6 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
23332341
### Inject custom PhreakNet patches to add additional functionality and features.
23342342
### If/when/as these are integrated upstream, they will be removed from this function.
23352343

2336-
instantiate_repo
2337-
23382344
cd $AST_SOURCE_PARENT_DIR/$2
23392345

23402346
## Add Standalone PhreakNet Modules
@@ -2959,6 +2965,9 @@ get_source() {
29592965
printf "chan_sip was not natively present in this version of Asterisk\n"
29602966
ENHANCED_CHAN_SIP=1 # chan_sip isn't present anymore, we need to readd it ourselves (if we're going to build chan_sip at all)
29612967
fi
2968+
2969+
instantiate_repo
2970+
29622971
if [ "$CHAN_SIP" = "1" ]; then # somebody still wants chan_sip, okay...
29632972
if [ "$ENHANCED_CHAN_SIP" != "1" ]; then
29642973
echoerr "chan_sip is deprecated and was removed in Asterisk 21. Consider migrating to chan_pjsip at your convenience."
@@ -2970,9 +2979,40 @@ get_source() {
29702979
./chan_sip_reinclude.sh
29712980
fi
29722981
fi
2982+
if [ "$RPT_MODULES" = "1" ]; then
2983+
ALSA=1 # ALSA support in the build system is required for the USB radio channel drivers
2984+
modprobe snd-pcm-oss # /dev/dsp1 needs to exist for chan_simpleusb and chan_usbradio to work
2985+
grep "snd-pcm-oss" /etc/modules
2986+
if [ $? -ne 0 ]; then
2987+
echo "snd-pcm-oss" >> /etc/modules # load module at startup for USB
2988+
fi
2989+
if [ -d $AST_SOURCE_PARENT_DIR/app_rpt ]; then
2990+
cd $AST_SOURCE_PARENT_DIR/app_rpt
2991+
git pull
2992+
else
2993+
cd $AST_SOURCE_PARENT_DIR
2994+
git clone --depth 1 https://github.com/AllStarLink/app_rpt.git
2995+
fi
2996+
cd $AST_SOURCE_PARENT_DIR/$AST_SRC_DIR
2997+
# Patch in the radio modules
2998+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/apps/Makefile.diff
2999+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/channels/Makefile.diff
3000+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/res/Makefile.diff
3001+
git apply $AST_SOURCE_PARENT_DIR/app_rpt/utils/Makefile.diff
3002+
mkdir apps/app_rpt
3003+
mkdir channels/xpmr
3004+
cp $AST_SOURCE_PARENT_DIR/app_rpt/apps/*.c apps
3005+
cp $AST_SOURCE_PARENT_DIR/app_rpt/apps/app_rpt/* apps/app_rpt
3006+
cp $AST_SOURCE_PARENT_DIR/app_rpt/channels/*.c $AST_SOURCE_PARENT_DIR/app_rpt/channels/*.h channels
3007+
cp $AST_SOURCE_PARENT_DIR/app_rpt/channels/xpmr/* channels/xpmr
3008+
cp $AST_SOURCE_PARENT_DIR/app_rpt/configs/samples/*.conf.sample configs/samples
3009+
cp $AST_SOURCE_PARENT_DIR/app_rpt/include/asterisk/*.h include/asterisk
3010+
cp $AST_SOURCE_PARENT_DIR/app_rpt/res/*.c $AST_SOURCE_PARENT_DIR/app_rpt/res/*.in res
3011+
cp $AST_SOURCE_PARENT_DIR/app_rpt/utils/*.c utils
3012+
fi
29733013
if [ "$ALSA" = "1" ]; then
29743014
# chan_alsa was removed in Asterisk 21, and with it, the support for ALSA lib detection in the build system. Add it back if needed.
2975-
lines=$(grep "HAVE_ALSA" include/asterisk/autoconfig.h | wc -l)
3015+
lines=$(grep "HAVE_ALSA" include/asterisk/autoconfig.h.in | wc -l)
29763016
if [ $lines -eq 0 ]; then
29773017
printf "Patching build system to detect ALSA library\n"
29783018
git_patch "alsa.diff"
@@ -3024,7 +3064,7 @@ else
30243064
fi
30253065

30263066
FLAG_TEST=0
3027-
PARSED_ARGUMENTS=$(getopt -n phreaknet -o bc:u:dfhostu:v:w -l backtraces,cc:,dahdi,force,flag-test,help,sip,testsuite,user:,version:,weaktls,alsa,cisco,sccp,clli:,debug:,devmode,disa:,drivers,experimental,extcodecs,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe -- "$@")
3067+
PARSED_ARGUMENTS=$(getopt -n phreaknet -o bc:u:dfhostu:v:w -l backtraces,cc:,dahdi,force,flag-test,help,sip,testsuite,user:,version:,weaktls,alsa,cisco,rpt,sccp,clli:,debug:,devmode,disa:,drivers,experimental,extcodecs,fast,freepbx,generic,autokvers,lightweight,api-key:,rotate,audit,boilerplate,upstream:,manselect,minimal,vanilla,wanpipe -- "$@")
30283068
VALID_ARGUMENTS=$?
30293069
if [ "$VALID_ARGUMENTS" != "0" ]; then
30303070
usage
@@ -3057,6 +3097,7 @@ while true; do
30573097
--alsa ) ALSA=1; shift ;;
30583098
--audit ) PKG_AUDIT=1; shift ;;
30593099
--cisco ) SIP_CISCO=1; shift ;;
3100+
--rpt ) RPT_MODULES=1; shift ;;
30603101
--sccp ) CHAN_SCCP=1; shift ;;
30613102
--boilerplate ) BOILERPLATE_SOUNDS=1; shift ;;
30623103
--clli ) PHREAKNET_CLLI=$2; shift 2;;
@@ -3373,7 +3414,6 @@ elif [ "$cmd" = "install" ]; then
33733414
# Install Pre-Reqs
33743415
if [ "$PAC_MAN" = "apt-get" ]; then
33753416
printf "%s %d" "libvpb1 libvpb1/countrycode string" "$AST_CC" | debconf-set-selections -v
3376-
apt-get install -y libvpb1
33773417
fi
33783418
./contrib/scripts/install_prereq install
33793419

@@ -3558,6 +3598,19 @@ elif [ "$cmd" = "install" ]; then
35583598
fi
35593599
$AST_MAKE install # actually install modules and binary
35603600

3601+
if [ "$RPT_MODULES" = "1" ]; then
3602+
# Also install the radio sounds
3603+
if [ ! -d $AST_SOUNDS_DIR/rpt ]; then
3604+
printf "RPT sounds don't exist yet, adding them now...\n"
3605+
mkdir $AST_SOUNDS_DIR/rpt
3606+
cd $AST_SOUNDS_DIR/rpt
3607+
wget "http://downloads.allstarlink.org/asterisk-asl-sounds-en-ulaw.tar.gz"
3608+
# Sounds are extracted directly into the dir
3609+
tar -xvzf asterisk-asl-sounds-en-ulaw.tar.gz
3610+
rm asterisk-asl-sounds-en-ulaw.tar.gz
3611+
fi
3612+
fi
3613+
35613614
# Debugging: see where Asterisk got installed
35623615
which asterisk
35633616
which rasterisk
@@ -3774,7 +3827,7 @@ elif [ "$cmd" = "sounds" ]; then
37743827
cd /tmp
37753828
mkdir -p patfleet
37763829
cd patfleet
3777-
git clone https://github.com/hharte/PatFleet-asterisk/
3830+
git clone --depth 1 https://github.com/hharte/PatFleet-asterisk/
37783831
cd PatFleet-asterisk/pa
37793832
mv dictate/* $AST_SOUNDS_DIR/dictate
37803833
mv digits/* $AST_SOUNDS_DIR/digits
@@ -3912,7 +3965,7 @@ elif [ "$cmd" = "mkdocs" ]; then
39123965
git pull
39133966
rm -rf /tmp/documentation/temp/site
39143967
else
3915-
git clone https://github.com/asterisk/documentation.git --depth 1
3968+
git clone --depth 1 https://github.com/asterisk/documentation.git
39163969
cd documentation
39173970
fi
39183971

@@ -3937,7 +3990,7 @@ elif [ "$cmd" = "pubdocs" ]; then
39373990
if [ -d publish-docs ]; then
39383991
rm -rf publish-docs
39393992
fi
3940-
git clone https://github.com/asterisk/publish-docs.git
3993+
git clone --depth 1 https://github.com/asterisk/publish-docs.git
39413994
cd publish-docs
39423995
echo $AST_SOURCE_PARENT_DIR
39433996
printf "%s\n" "Generating Confluence markup..."

0 commit comments

Comments
 (0)