summaryrefslogtreecommitdiffstats
path: root/src/etc/rc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-10-01 10:21:43 -0300
committerRenato Botelho <renato@netgate.com>2015-10-01 10:21:43 -0300
commita5c36eb22154a2f17bba4329ee85627eeb64b664 (patch)
treec3bfe52067f1af8586dd85c2118cb66f55d2b227 /src/etc/rc
parent339b88930513dec2bc986df7c0cd7255b6815d56 (diff)
downloadpfsense-a5c36eb22154a2f17bba4329ee85627eeb64b664.zip
pfsense-a5c36eb22154a2f17bba4329ee85627eeb64b664.tar.gz
Introduce read_xml_tag.sh
Create /usr/local/sbin/read_xml_tag.sh, that will read a xml tag from config file using xmllint. Replace all direct read using cat, grep, sed, ... by this script
Diffstat (limited to 'src/etc/rc')
-rwxr-xr-xsrc/etc/rc24
1 files changed, 11 insertions, 13 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
OpenPOWER on IntegriCloud