summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/etc/rc24
-rwxr-xr-xsrc/etc/rc.embedded8
-rwxr-xr-xsrc/etc/rc.php_ini_setup22
-rwxr-xr-xsrc/etc/rc.reboot4
-rwxr-xr-xsrc/etc/rc.shutdown4
-rw-r--r--src/etc/skel/dot.shrc4
-rw-r--r--src/etc/skel/dot.tcshrc4
-rw-r--r--src/root/.shrc4
-rw-r--r--src/root/.tcshrc4
-rwxr-xr-xsrc/sbin/dhclient-script4
-rwxr-xr-xsrc/usr/local/bin/beep.sh4
-rwxr-xr-xsrc/usr/local/sbin/ntpdate_sync_once.sh4
-rwxr-xr-xsrc/usr/local/sbin/ppp-linkup6
-rwxr-xr-xsrc/usr/local/sbin/read_xml_tag.sh32
14 files changed, 84 insertions, 44 deletions
diff --git a/src/etc/rc b/src/etc/rc
index b036deb..22dec60 100755
--- a/src/etc/rc
+++ b/src/etc/rc
@@ -103,8 +103,8 @@ if [ ! "${PLATFORM}" = "cdrom" ]; then
fi
fi
- USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml`
- if [ "${PLATFORM}" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then
+ USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
+ if [ "${PLATFORM}" = "nanobsd" ] || [ "${USE_MFS_TMPVAR}" = "true" ]; then
/etc/rc.embedded
fi
fi
@@ -153,7 +153,7 @@ varrunpath=$(cat ${globals_inc} | \
head -n 1 | \
sed 's/^.*=>* *//; s/["\;,]*//g')
-if [ "$PLATFORM" = "${product}" ] && [ ${USE_MFS_TMPVAR} -eq 0 ]; then
+if [ "$PLATFORM" = "${product}" ] && [ "${USE_MFS_TMPVAR}" != "true" ]; then
/sbin/mdmfs -S -M -s 4m md $varrunpath
fi
@@ -175,13 +175,13 @@ echo
if [ "$PLATFORM" = "${product}" ]; then
# If use MFS var is disabled, move files back to place
- if [ ${USE_MFS_TMPVAR} -eq 0 -a -d /root/var/db/pkg ]; then
+ if [ "${USE_MFS_TMPVAR}" != "true" -a -d /root/var/db/pkg ]; then
rm -rf /var/db/pkg 2>/dev/null
rm -rf /var/cache/pkg 2>/dev/null
mv /root/var/db/pkg /var/db
mv /root/var/cache/pkg /var/cache
# If use MFS var is enabled, move files to a safe place
- elif [ ${USE_MFS_TMPVAR} -gt 0 -a ! -d /root/var/db/pkg ]; then
+ elif [ "${USE_MFS_TMPVAR}" = "true" -a ! -d /root/var/db/pkg ]; then
/bin/mkdir -p /root/var/db /root/var/cache
mv /var/db/pkg /root/var/db
mv /var/cache/pkg /root/var/cache
@@ -293,21 +293,19 @@ trap "echo 'Reboot interrupted'; exit 1" 3
/bin/rm -f /var/etc/nameserver*
echo -n "."
-DISABLESYSLOGCLOG=`/usr/bin/grep -c disablesyslogclog /cf/conf/config.xml`
-ENABLEFIFOLOG=`/usr/bin/grep -c usefifolog /cf/conf/config.xml`
+DISABLESYSLOGCLOG=$(/usr/local/sbin/read_xml_tag.sh boolean system/disablesyslogclog)
+ENABLEFIFOLOG=$(/usr/local/sbin/read_xml_tag.sh boolean system/usefifolog)
LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppp relayd wireless lighttpd ntpd gateways resolver routing"
-DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//pfsense/syslog/logfilesize)' /conf/config.xml`
-if [ ! ${DEFAULT_LOG_FILE_SIZE} ]; then
- DEFAULT_LOG_FILE_SIZE=511488
-fi
+DEFAULT_LOG_FILE_SIZE=$(/usr/local/sbin/read_xml_tag.sh string syslog/logfilesize)
+DEFAULT_LOG_FILE_SIZE=${DEFAULT_LOG_FILE_SIZE:-"511488"}
for logfile in $LOG_FILES; do
- if [ "$DISABLESYSLOGCLOG" -gt "0" ]; then
+ if [ "$DISABLESYSLOGCLOG" = "true" ]; then
/usr/bin/touch /var/log/$logfile.log
else
if [ ! -f /var/log/$logfile.log ]; then
- if [ "$ENABLEFIFOLOG" -gt "0" ]; then
+ if [ "$ENABLEFIFOLOG" = "true" ]; then
# generate fifolog files
/usr/sbin/fifolog_create -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
else
diff --git a/src/etc/rc.embedded b/src/etc/rc.embedded
index 663822d..f08c0ef 100755
--- a/src/etc/rc.embedded
+++ b/src/etc/rc.embedded
@@ -4,16 +4,16 @@
# For pfSense
# Size of /tmp
-USE_MFS_TMP_SIZE=`/usr/bin/grep use_mfs_tmp_size /cf/conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'`
-if [ ! -z ${USE_MFS_TMP_SIZE} ] && [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then
+USE_MFS_TMP_SIZE=$(/usr/local/sbin/read_xml_tag.sh string system/use_mfs_tmp_size)
+if [ -n "${USE_MFS_TMP_SIZE}" ] && [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then
tmpsize="${USE_MFS_TMP_SIZE}m"
else
tmpsize="40m"
fi
# Size of /var
-USE_MFS_VAR_SIZE=`/usr/bin/grep use_mfs_var_size /cf/conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'`
-if [ ! -z ${USE_MFS_VAR_SIZE} ] && [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then
+USE_MFS_VAR_SIZE=$(/usr/local/sbin/read_xml_tag.sh string system/use_mfs_var_size)
+if [ -n "${USE_MFS_VAR_SIZE}" ] && [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then
varsize="${USE_MFS_VAR_SIZE}m"
else
varsize="60m"
diff --git a/src/etc/rc.php_ini_setup b/src/etc/rc.php_ini_setup
index f456e6b..2fd5add 100755
--- a/src/etc/rc.php_ini_setup
+++ b/src/etc/rc.php_ini_setup
@@ -165,16 +165,19 @@ if [ -f /usr/local/lib/php.ini ]; then
fi
LOADED_MODULES=`/usr/local/bin/php-cgi -m | /usr/bin/grep -v "\["`
+unset TIMEZONE
# Fetch the timezone from /var/db/zoneinfo if present
if [ -f /var/db/zoneinfo ]; then
TIMEZONE=$(cat /var/db/zoneinfo)
-# Second option is from config.xml
-elif grep -q '<timezone>' /cf/conf/config.xml; then
- TIMEZONE=$(/usr/bin/sed -E \
- '/<timezone>/!d; s,^.*<timezone>,,; s,<.*,,' \
- /cf/conf/config.xml)
-# Last option, use default value
-else
+fi
+
+if [ -z "${TIMEZONE}" ]; then
+ # Second option is from config.xml
+ TIMEZONE=$(/usr/local/sbin/read_xml_tag.sh string system/timezone)
+fi
+
+if [ -z "${TIMEZONE}" ]; then
+ # Last option, use default value
globals_inc="/etc/inc/globals.inc"
if [ -f /etc/inc/globals_override.inc ]; then
globals_inc="/etc/inc/globals_override.inc ${globals_inc}"
@@ -185,6 +188,11 @@ else
sed 's/^.*=>* *//; s/["\;,]*//g')
fi
+if [ -z "${TIMEZONE}" ]; then
+ # It it's still blank, lets avoid PHP errors
+ TIMEZONE="Etc/UTC"
+fi
+
# Get a loaded module list in the stock php
# Populate a dummy php.ini to avoid
# the file being clobbered and the firewall
diff --git a/src/etc/rc.reboot b/src/etc/rc.reboot
index 3b77520..1dae0d2 100755
--- a/src/etc/rc.reboot
+++ b/src/etc/rc.reboot
@@ -28,11 +28,11 @@ if [ "$PLATFORM" = "${product}" ]; then
rm -rf /tmp/*
fi
-USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml`
+USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
-if [ "${PLATFORM}" != "${product}" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then
+if [ "${PLATFORM}" != "${product}" ] || [ "${USE_MFS_TMPVAR}" = "true" ] || [ "${DISK_TYPE}" = "md" ]; then
/etc/rc.backup_rrd.sh
/etc/rc.backup_dhcpleases.sh
fi
diff --git a/src/etc/rc.shutdown b/src/etc/rc.shutdown
index bf79683..55133f0 100755
--- a/src/etc/rc.shutdown
+++ b/src/etc/rc.shutdown
@@ -37,11 +37,11 @@ if [ "$PLATFORM" = "${product}" ]; then
find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1
fi
-USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml`
+USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
-if [ "${PLATFORM}" != "${product}" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then
+if [ "${PLATFORM}" != "${product}" ] || [ "${USE_MFS_TMPVAR}" = "true" ] || [ "${DISK_TYPE}" = "md" ]; then
/etc/rc.backup_rrd.sh
/etc/rc.backup_dhcpleases.sh
fi
diff --git a/src/etc/skel/dot.shrc b/src/etc/skel/dot.shrc
index 6f3c2fc..d3c9208 100644
--- a/src/etc/skel/dot.shrc
+++ b/src/etc/skel/dot.shrc
@@ -1,6 +1,6 @@
-HTTP_PROXY=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml`
+HTTP_PROXY=`/usr/local/sbin/read_xml_tag.sh string system/proxyurl`
if [ "${HTTP_PROXY}" != "" ]; then
- HTTP_PROXY_PORT=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml`
+ HTTP_PROXY_PORT=`/usr/local/sbin/read_xml_tag.sh string system/proxyport`
if [ "${HTTP_PROXY_PORT}" != "" ]; then
HTTP_PROXY="${HTTP_PROXY}:${HTTP_PROXY_PORT}"
fi
diff --git a/src/etc/skel/dot.tcshrc b/src/etc/skel/dot.tcshrc
index 38cf897..a643e3b 100644
--- a/src/etc/skel/dot.tcshrc
+++ b/src/etc/skel/dot.tcshrc
@@ -20,9 +20,9 @@ if ($term == "xterm" || $term == "vt100" || $term == "vt102" || $term == "vt220"
bindkey "\e[8~" end-of-line # End rxvt/konsole
endif
-set http_proxy=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml`
+set http_proxy=`/usr/local/sbin/read_xml_tag.sh string system/proxyurl`
if (${http_proxy} != "") then
- set http_proxy_port=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml`
+ set http_proxy_port=`/usr/local/sbin/read_xml_tag.sh string system/proxyport`
if (${http_proxy_port} != "") then
set http_proxy="${http_proxy}:${http_proxy_port}"
endif
diff --git a/src/root/.shrc b/src/root/.shrc
index 6f3c2fc..d3c9208 100644
--- a/src/root/.shrc
+++ b/src/root/.shrc
@@ -1,6 +1,6 @@
-HTTP_PROXY=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml`
+HTTP_PROXY=`/usr/local/sbin/read_xml_tag.sh string system/proxyurl`
if [ "${HTTP_PROXY}" != "" ]; then
- HTTP_PROXY_PORT=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml`
+ HTTP_PROXY_PORT=`/usr/local/sbin/read_xml_tag.sh string system/proxyport`
if [ "${HTTP_PROXY_PORT}" != "" ]; then
HTTP_PROXY="${HTTP_PROXY}:${HTTP_PROXY_PORT}"
fi
diff --git a/src/root/.tcshrc b/src/root/.tcshrc
index 38cf897..a643e3b 100644
--- a/src/root/.tcshrc
+++ b/src/root/.tcshrc
@@ -20,9 +20,9 @@ if ($term == "xterm" || $term == "vt100" || $term == "vt102" || $term == "vt220"
bindkey "\e[8~" end-of-line # End rxvt/konsole
endif
-set http_proxy=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml`
+set http_proxy=`/usr/local/sbin/read_xml_tag.sh string system/proxyurl`
if (${http_proxy} != "") then
- set http_proxy_port=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml`
+ set http_proxy_port=`/usr/local/sbin/read_xml_tag.sh string system/proxyport`
if (${http_proxy_port} != "") then
set http_proxy="${http_proxy}:${http_proxy_port}"
endif
diff --git a/src/sbin/dhclient-script b/src/sbin/dhclient-script
index 9d71aaf..98e4aa8 100755
--- a/src/sbin/dhclient-script
+++ b/src/sbin/dhclient-script
@@ -268,12 +268,12 @@ add_new_resolv_conf() {
fi
if [ -n "$new_domain_name_servers" ]; then
/bin/rm -f /var/etc/nameserver_$interface
- ALLOWOVERRIDE=`/usr/bin/grep dnsallowoverride /conf/config.xml | /usr/bin/wc -l`
+ ALLOWOVERRIDE=$(/usr/local/sbin/read_xml_tag.sh boolean system/dnsallowoverride)
for nameserver in $new_domain_name_servers; do
# Add a route to the nameserver out the correct interface
# so that mulitple wans work correctly with multiple dns
# also backup the nameserver for later route removal
- if [ $ALLOWOVERRIDE -gt 0 ]; then
+ if [ "$ALLOWOVERRIDE" = "true" ]; then
echo $nameserver >>/var/etc/nameserver_$interface
$ROUTE add $nameserver -iface $interface
fi
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 $?
OpenPOWER on IntegriCloud