Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Created November 29, 2013 13:23
Show Gist options
  • Save tlatsas/7705629 to your computer and use it in GitHub Desktop.
Save tlatsas/7705629 to your computer and use it in GitHub Desktop.
#!/bin/sh
#Get the first IP from ifconfig. Ignore loopback.
SYSIP=$(ifconfig | awk -F'[: ]+' '/inet addr/ {print $4}' | grep -v "127.0.0.1" | head -n1)
if [ -z "${SYSIP}" ]; then
#THE SKY IS FALLING!
#Okay, not really. Couldn't determine IP address.
TEXT="To configure networking, login as 'root' and run the \`setup\` command."
else
if [ -f /var/lib/asterisk/static-http/index.html ]; then
#Asterisk-GUI
# Get the bindport from http.conf. Use 8088 if unset.
p=`awk -F'[= \t]' '/^bindport[ \t]?=[ \t]?/ {print $NF}' /etc/asterisk/http.conf`
PORT=${p:-8088}
up=`awk -F'[= \t]' '/^prefix[ \t]?=[ \t]?/ {print $NF}' /etc/asterisk/http.conf`
URIPREFIX=${up:+"${up}"/}
TEXT="To configure AsteriskNOW with Asterisk-GUI, point your web browser to http://${SYSIP}:${PORT}/${URIPREFIX}static/config/index.html"
elif [ -d /var/www/html/admin/ ]; then
#FreePBX
TEXT="To configure AsteriskNOW with FreePBX, point your web browser to http://${SYSIP}/"
else
#No GUI
TEXT="The IP address of your AsteriskNOW system is ${SYSIP}"
fi
fi
cat /etc/asterisknow-version > /etc/issue
echo -e "\n${TEXT}\n" >> /etc/issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment