Created
December 9, 2022 20:30
-
-
Save emmaly/c536ab388ed6ae096758c4d43ea7edc2 to your computer and use it in GitHub Desktop.
DPMA Lookup and Reconfigure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ID="$1" | |
MAC=$(grep -Ei '^[A-Z0-9]+$' <<<"$ID") | |
if [ -z "$MAC" ]; then | |
MAC=$(/etc/asterisk/scj/sipmac.sh "$ID") | |
if [ -z "$MAC" ]; then | |
echo "$ID was not found" >&2 | |
exit 1 | |
fi | |
fi | |
CTL_FILE="/var/run/asterisk/asterisk.ctl" | |
if [ ! -w /var/run/asterisk/asterisk.ctl ]; then | |
echo "No permission to write to $CTL_FILE" >&2 | |
exit 2 | |
fi | |
/usr/sbin/rasterisk -x "digium_phones reconfigure phone $MAC" | |
exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SIPNAME=$1 | |
[ -z $SIPNAME ] && exit 1 | |
FILENAME=$(grep -li "^\s*line\s*=\s*${SIPNAME}\s*$" /etc/asterisk/scj/astgen/phone.d/*.phone.conf) | |
[ -z "$FILENAME" -o ! -f "$FILENAME" ] && exit 1 | |
MAC=$(grep -Ei '^\s*mac\s*=\s*[A-Z0-9]+\s*$' $FILENAME | cut -d= -f2 | sed 's/ *//g') | |
[ -z "$MAC" ] && exit 2 | |
echo $MAC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment