diff options
Diffstat (limited to 'src/usr')
-rwxr-xr-x | src/usr/local/bin/beep.sh | 4 | ||||
-rwxr-xr-x | src/usr/local/sbin/ntpdate_sync_once.sh | 4 | ||||
-rwxr-xr-x | src/usr/local/sbin/ppp-linkup | 6 | ||||
-rwxr-xr-x | src/usr/local/sbin/read_xml_tag.sh | 32 |
4 files changed, 40 insertions, 6 deletions
diff --git a/src/usr/local/bin/beep.sh b/src/usr/local/bin/beep.sh index ed9382d..4a7cd59 100755 --- a/src/usr/local/bin/beep.sh +++ b/src/usr/local/bin/beep.sh @@ -1,8 +1,8 @@ #!/bin/sh -BEEP=`/usr/bin/grep -c disablebeep /conf/config.xml` -if [ $BEEP -gt 0 ]; then +BEEP=$(/usr/local/sbin/read_xml_tag.sh boolean system/disablebeep) +if [ "$BEEP" = "true" ]; then exit; fi diff --git a/src/usr/local/sbin/ntpdate_sync_once.sh b/src/usr/local/sbin/ntpdate_sync_once.sh index c183b79..3372745 100755 --- a/src/usr/local/sbin/ntpdate_sync_once.sh +++ b/src/usr/local/sbin/ntpdate_sync_once.sh @@ -2,8 +2,8 @@ NOTSYNCED="true" MAX_ATTEMPTS=3 -SERVER=`/bin/cat /cf/conf/config.xml | /usr/bin/grep timeservers | /usr/bin/cut -d">" -f2 | /usr/bin/cut -d"<" -f1` -if [ "${SERVER}" = "" ]; then +SERVER=$(/usr/local/sbin/read_xml_tag.sh string system/timeservers) +if [ -z "${SERVER}" ]; then exit fi diff --git a/src/usr/local/sbin/ppp-linkup b/src/usr/local/sbin/ppp-linkup index 2d1eb33..e6604a3 100755 --- a/src/usr/local/sbin/ppp-linkup +++ b/src/usr/local/sbin/ppp-linkup @@ -2,6 +2,8 @@ export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin +DNSALLOWOVERRIDE=$(/usr/local/sbin/read_xml_tag.sh boolean system/dnsallowoverride) + if [ "${2}" == "inet" ]; then OLD_ROUTER=`cat /tmp/${1}_router` @@ -16,7 +18,7 @@ if [ "${2}" == "inet" ]; then echo ${3} > /tmp/${1}_ip touch /tmp/${1}up - if grep -q dnsallowoverride /conf/config.xml; then + if [ "${DNSALLOWOVERRIDE}" = "true" ]; then # write nameservers to file echo -n "" > /var/etc/nameserver_${1} if echo "${6}" | grep -q dns1; then @@ -40,7 +42,7 @@ elif [ "${2}" == "inet6" ]; then echo ${3} |cut -d% -f1 > /tmp/${1}_ipv6 touch /tmp/${1}upv6 - if grep -q dnsallowoverride /conf/config.xml; then + if [ "${DNSALLOWOVERRIDE}" = "true" ]; then # write nameservers to file echo -n "" > /var/etc/nameserver_v6${1} if echo "${6}" | grep -q dns1; then diff --git a/src/usr/local/sbin/read_xml_tag.sh b/src/usr/local/sbin/read_xml_tag.sh new file mode 100755 index 0000000..a2d9092 --- /dev/null +++ b/src/usr/local/sbin/read_xml_tag.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +if [ -z "$1" -o -z "$2" ]; then + echo "ERROR: Missing parameters" >&2 + exit 1 +fi + +type="${1}" +path="${2}" +config="${3}" +config=${config:-"/cf/conf/config.xml"} + +if [ ! -f "$config" ]; then + echo "ERROR: Config file not found" >&2 + exit 1 +fi + +# Get xml_rootobj +globals_inc="/etc/inc/globals.inc" +if [ -f /etc/inc/globals_override.inc ]; then + globals_inc="/etc/inc/globals_override.inc ${globals_inc}" +fi +xml_rootobj=$(cat ${globals_inc} | \ + grep xml_rootobj | \ + head -n 1 | \ + sed 's/^.*=>* *//; s/["\;,]*//g') + +# defaults to pfsense +xml_rootobj=${product:-"pfsense"} + +/usr/local/bin/xmllint --xpath "${type}(//${xml_rootobj}/${path})" ${config} +exit $? |