|
|
|
@ -1,39 +1,42 @@
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
#ajw v1.2 - jukebox for asterisk wizard
|
|
|
|
|
#Jay Moore/NQ4T - https://git.pickmy.org/dewdude/ajw
|
|
|
|
|
|
|
|
|
|
#ajw v1.50 - jukebox for asterisk wizard
|
|
|
|
|
#Jay Moore/NQ4T - https://git.pickmy.org/dewdude/Asterisk_Jukebox
|
|
|
|
|
#Twitter: @Music_OnHold
|
|
|
|
|
#Licensed under GPL-3.0-or-later
|
|
|
|
|
|
|
|
|
|
# USAGE:
|
|
|
|
|
# Interactive: ./ajw.sh
|
|
|
|
|
# Non-Interactive: ./ajw.sh name relative/path-to-juke introfile goodbye loop# [sec-delay volume]
|
|
|
|
|
# (sec-delay default is none. volume is -3. If you specify volume, you must at least 0 sec-delay)
|
|
|
|
|
|
|
|
|
|
# Works like this:
|
|
|
|
|
# Put all your albums in your Asterisk sounds directory: /var/lib/asterisk/sounds/en/(jukeboxesdir)/jukebox root/album/track#.ulaw
|
|
|
|
|
# Run script, enter prompts. (jukeboxesdir) is an optional sub-folder in case your jukeboxes are in a extra subdirectory
|
|
|
|
|
# Copy .conf, include in extensions.conf, assign extension.
|
|
|
|
|
|
|
|
|
|
# asd defines the default location of your asterisk sounds
|
|
|
|
|
|
|
|
|
|
asd=/var/lib/asterisk/sounds/en/
|
|
|
|
|
|
|
|
|
|
# main context configuation
|
|
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
|
printf "[%s-main]\nexten = s,1,Answer()\nsame =n,Set(VOLUME(TX)=%s)\nsame = n,Set(c=%s-main)\nsame = n(return),Set(m=1)\nsame = n(loop),Background(%s/%s)\n" "$name" "$vol" "$name" "$rootfolder" "$introfile"
|
|
|
|
|
[ -n "$delay" ] && printf "same = n,WaitExten(%s)\n" "$delay"
|
|
|
|
|
printf "same = n,Set(m=\$[\${m} + 1])\nsame = n,GoToIf(\$[\"\${m}\" > \"%s\"]?loop)\nsame = n(goodbye),Background(%s/%s)\nsame = n,Hangup()\n\n" "$loop" "$rootfolder" "$goodbye"
|
|
|
|
|
} >> $name-juke.conf
|
|
|
|
|
printf "same = n,Set(m=\$[\${m} + 1])\nsame = n,GoToIf(\$[\"\${m}\" > \"%s\"]?loop)\nsame = n(goodbye),Background(%s/%s)\nsame = n,Hangup()\n\nexten = i,1,Playback(option-is-invalid)\nsame = n,GoTo(s,return)\n\n" "$loop" "$rootfolder" "$goodbye"
|
|
|
|
|
} >> "$name"-juke.conf
|
|
|
|
|
|
|
|
|
|
# album selections
|
|
|
|
|
|
|
|
|
|
album() {
|
|
|
|
|
printf "exten = _%02dXX,1,Set(aa=%s/%s)\n" "$a" "$rootfolder" "$folder"
|
|
|
|
|
[ -z "$ld" ] && printf "same = n,GoToIf(\$[\"\${EXTEN:-2}\" = \"00\"]?8track-player,#%s,1)\n" "$tc" || printf "same = n,GoToIf(\$[\"\${EXTEN:-2}\" = \"00\"]?8track-player,*%s,1)\n" "$tc"
|
|
|
|
|
printf "same = n,GoToIf(\$[\"\${EXTEN:-2}\" > \"%s\"]?9999)\n" "$limit"
|
|
|
|
|
printf "same = n,GoToIf(\$[\"\${EXTEN:-2}\" > \"%s\"]?i,1)\n" "$limit"
|
|
|
|
|
[ -z "$ld" ] && printf "same = n,GoToIf(\$[\"\${EXTEN:-2}\" < \"10\"]?cart-player,#\${EXTEN:-1},1)\n"
|
|
|
|
|
printf "same = n,GoTo(cart-player,*\${EXTEN:-2},1)\nsame = 9999,Playback(option-is-invalid)\nsame =n,GoTo(%s-main,s,1)\n\n" "$name"
|
|
|
|
|
} >> $name-juke.conf
|
|
|
|
|
printf "same = n,GoTo(cart-player,*\${EXTEN:-2},1)\n\n"
|
|
|
|
|
} >> "$name"-juke.conf
|
|
|
|
|
|
|
|
|
|
# main
|
|
|
|
|
|
|
|
|
|
printf "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |a|j|w| - asterisk jukebox wizard\n version 1.10 - Jay Moore/NQ4T\n https://git.pickmy.org/dewdude/jaw\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n\n"
|
|
|
|
|
interactive() {
|
|
|
|
|
printf "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |a|j|w| - asterisk jukebox wizard\n version 1.50 - Jay Moore/NQ4T\ngit.pickmy.org/dewdude/Asterisk_Jukebox\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n\n"
|
|
|
|
|
printf "Pick a name/identifier for this jukebox: "
|
|
|
|
|
read -r name
|
|
|
|
|
printf "\nEnter the folder your jukebox roots live under. (Leave blank if they're under %s): " "$asd"
|
|
|
|
@ -50,25 +53,48 @@ printf "\nEnter the filename of your exit file: "
|
|
|
|
|
read -r goodbye
|
|
|
|
|
printf "\nEnter a channel volume. (I recommend -3, also the default if you leave this blank): "
|
|
|
|
|
read -r vol
|
|
|
|
|
[ -n "$vol" ] && vol="-3"
|
|
|
|
|
[ -z "$vol" ] && vol=-3 # Change the -3 if you want a different default
|
|
|
|
|
printf "\nWriting Basic Configuration.\n\nAuto-Generating Albums\n\n"
|
|
|
|
|
[ -n "$sd" ] && rootfolder=$sd/$rootfolder
|
|
|
|
|
setup;
|
|
|
|
|
loop;
|
|
|
|
|
bye;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# album context loop
|
|
|
|
|
|
|
|
|
|
dir=$(find $asd/$rootfolder -mindepth 1 -type d -printf '%f\n' | sort -n)
|
|
|
|
|
loop() {
|
|
|
|
|
dir=$(find "$asd""$rootfolder" -mindepth 1 -type d -printf '%f\n' | sort -n)
|
|
|
|
|
a=0
|
|
|
|
|
for folder in $dir
|
|
|
|
|
do
|
|
|
|
|
limit=$(find $asd/$rootfolder/$folder/ -name "*.ulaw" | wc -l)
|
|
|
|
|
ulaw=$(find $asd/"$rootfolder"/"$folder"/ -name "*.ulaw" -printf "%f\n")
|
|
|
|
|
limit=$(printf "%s\n" "$ulaw" | wc -l)
|
|
|
|
|
ld=$(printf "%s\n" "$ulaw" | awk '/^0/')
|
|
|
|
|
tracks=$((limit + 1))
|
|
|
|
|
tc=$(printf "%02d" $tracks)
|
|
|
|
|
ld=$(find $asd/$rootfolder/$folder/ -name "*.ulaw" -printf "%f\n" | awk '/^0/')
|
|
|
|
|
#[ -z "$ld" ] && lz=0 || lz=1
|
|
|
|
|
album;
|
|
|
|
|
a=$((a + 1))
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# GTFO, BYE
|
|
|
|
|
bye() {
|
|
|
|
|
printf "\n\nDone.\n\n\nYour jukebox is located at %s-juke.conf.\n" "$name"
|
|
|
|
|
printf "Make sure to include it and the player conf in your dial plan somewhere.\n\n\n\n"
|
|
|
|
|
printf "Make sure to include it and the player conf in your dial plan somewhere.\n\n"
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# do stuff, or don't do stuff; then do stuff.
|
|
|
|
|
[ -z "$1" ] && interactive;
|
|
|
|
|
[[ "$#" -lt 5 ]] && printf "Invalid configuration. Entire required arguments or with none for interactive mode.\n" && exit
|
|
|
|
|
name=$1
|
|
|
|
|
rootfolder=$2 # this is the full path relative to the sounds dir
|
|
|
|
|
introfile=$3
|
|
|
|
|
goodbye=$4
|
|
|
|
|
loop=$5
|
|
|
|
|
[[ -n "$6" && $6 -ne 0 ]] && delay=$6 || delay= # Delay should be null if not needed
|
|
|
|
|
[ -n "$7" ] && vol=$7 || vol=-3 # You can change the default volume here.
|
|
|
|
|
printf "|a|j|w| 1.50 - PRO USER MODE ACTIVATE\n"
|
|
|
|
|
setup;
|
|
|
|
|
loop;
|
|
|
|
|
bye;
|