summaryrefslogtreecommitdiffstats
path: root/src/usr/local/share/pfSense
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/share/pfSense')
-rwxr-xr-xsrc/usr/local/share/pfSense/post_upgrade_command64
-rwxr-xr-xsrc/usr/local/share/pfSense/post_upgrade_command.php31
-rw-r--r--src/usr/local/share/pfSense/pre_upgrade_command58
3 files changed, 153 insertions, 0 deletions
diff --git a/src/usr/local/share/pfSense/post_upgrade_command b/src/usr/local/share/pfSense/post_upgrade_command
new file mode 100755
index 0000000..097bc5c
--- /dev/null
+++ b/src/usr/local/share/pfSense/post_upgrade_command
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+/etc/rc.conf_mount_rw
+
+PFSENSETYPE=`cat /etc/platform`
+
+if [ "${PFSENSETYPE}" = "pfSense" -o "${PFSENSETYPE}" = "nanobsd" ]; then
+ touch /conf/needs_package_sync
+fi
+
+# Detect interactive logins and display the shell
+detect_command='[ -n "$SSH_TTY" -o "$TERM" = "cons25" ] && exec /etc/rc.initial'
+echo "${detect_command}" > ${CVS_CO_DIR}/root/.shrc
+echo "${detect_command}" >> ${CVS_CO_DIR}/root/.profile
+
+if [ "${PFSENSETYPE}" = "nanobsd" ]; then
+ ROOT=/tmp/${1}/
+else
+ ROOT=/
+fi
+
+# Now turn on or off serial console as needed
+echo "Checking for ${ROOT}usr/local/share/pfSense/post_upgrade_command.php... " >> /conf/upgrade_log.txt
+if [ -x ${ROOT}usr/local/share/pfSense/post_upgrade_command.php ]; then
+ echo "Running ${ROOT}usr/local/share/pfSense/post_upgrade_command.php $1" >> /conf/upgrade_log.txt
+ ${ROOT}usr/local/share/pfSense/post_upgrade_command.php $1 >> /conf/upgrade_log.txt 2>&1
+fi
+
+# Remove any previous MD5 sum files
+rm -f /root/*.md5 >/dev/null 2>&1
+
+# Fixup permissions on installed files
+if [ -f ${ROOT}usr/local/share/pfSense/base.mtree ]; then
+ if [ -x "/tmp/mtree.old" ]; then
+ MTREE_BIN=/tmp/mtree.old
+ else
+ MTREE_BIN=/usr/sbin/mtree
+ fi
+ ${MTREE_BIN} -U -e -q -f ${ROOT}usr/local/share/pfSense/base.mtree -p ${ROOT} > /conf/mtree.log
+fi
+
+# Make sure to preserve existing time zone
+if [ "${PFSENSETYPE}" = "nanobsd" -a -f /etc/localtime ]; then
+ /bin/cp -p /etc/localtime ${ROOT}etc/localtime 2>/dev/null
+fi
+
+# Files may contain spaces
+oIFS=${IFS}
+IFS="
+"
+# Obsolete files - nanobsd doesn't need it since a new image is installed
+# on the other partition
+if [ "${PFSENSETYPE}" != "nanobsd" -a -f /etc/pfSense.obsoletedfiles ]; then
+ for f in $(cat /etc/pfSense.obsoletedfiles); do
+ if [ -n "${f}" -a -f "${f}" ]; then
+ rm -f "${f}"
+ elif [ -n "${f}" -a -d "${f}" ]; then
+ rm -rf "${f}"
+ fi
+ done
+fi
+
+# Restore IFS
+IFS=${oIFS}
diff --git a/src/usr/local/share/pfSense/post_upgrade_command.php b/src/usr/local/share/pfSense/post_upgrade_command.php
new file mode 100755
index 0000000..4a0215a
--- /dev/null
+++ b/src/usr/local/share/pfSense/post_upgrade_command.php
@@ -0,0 +1,31 @@
+#!/usr/local/bin/php-cgi -f
+<?php
+
+ /* upgrade embedded users serial console */
+ require_once("globals.inc");
+ require_once("config.inc");
+ require_once("functions.inc");
+
+ if (file_exists("/usr/local/bin/git") && isset($config['system']['gitsync']['synconupgrade'])) {
+ if (!empty($config['system']['gitsync']['repositoryurl'])) {
+ exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url " . escapeshellarg($config['system']['gitsync']['repositoryurl']));
+ }
+ if (!empty($config['system']['gitsync']['branch'])) {
+ system("pfSsh.php playback gitsync " . escapeshellarg($config['system']['gitsync']['branch']) . " --upgrading");
+ }
+ }
+
+ $newslicedir = "";
+ if (isset($argv[1]) && $argv[1] != "") {
+ $newslicedir = '/tmp/' . $argv[1];
+ }
+
+ if ($g['enableserial_force'] || file_exists("{$newslicedir}/enableserial_force")) {
+ $config['system']['enableserial'] = true;
+ write_config();
+ }
+
+ system("echo \"Adding serial port settings ({$newslicedir})...\" >> /conf/upgrade_log.txt");
+ setup_serial_port("upgrade", $newslicedir);
+
+?>
diff --git a/src/usr/local/share/pfSense/pre_upgrade_command b/src/usr/local/share/pfSense/pre_upgrade_command
new file mode 100644
index 0000000..2ad365f
--- /dev/null
+++ b/src/usr/local/share/pfSense/pre_upgrade_command
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+/etc/rc.conf_mount_rw
+
+# Record the previous version
+PRIOR_VERSION=`uname -r | cut -d'.' -f1`
+echo $PRIOR_VERSION > /tmp/pre_upgrade_version
+
+# De-activate sync on root filesystem. See ticket #4523
+# Back up original fstab
+/bin/cp /etc/fstab /etc/fstab.orig
+# De-activate sync on the root slice only. This will not match NanoBSD since it already has sync,noatime
+/usr/bin/sed -i '' 's/^\(\/.*[[:space:]]*\/[[:space:]]*ufs[[:space:]]*\)rw,sync\([[:space:]]*[[:digit:]][[:space:]]*[[:digit:]]\)$/\1rw\2/' /etc/fstab
+
+# Hack to workaround ticket #3749
+if [ ${PRIOR_VERSION} -le 8 ] && grep -q 'sh /etc/rc.reboot' /etc/rc.firmware; then
+ PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
+ PID=''
+ IMG=''
+ if [ -n "${PROC}" ]; then
+ PID=$(echo "${PROC}" | awk '{print $1}')
+ IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
+ fi
+
+ if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
+ cp -fp /bin/sh /tmp/sh.old
+ kill ${PID} >/dev/null 2>&1
+ kill -9 ${PID} >/dev/null 2>&1
+ sed -i '' -e 's,sh /,/tmp/sh.old /,' \
+ -e 's,/usr/sbin/mtree,/tmp/mtree.old,' /etc/rc.firmware
+ # To avoid restarting rc.firmware twice because of #4328
+ sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
+ /etc/rc.firmware pfSenseupgrade "${IMG}"
+ exit
+ fi
+fi
+
+# One more hack to workaround #4328
+if grep -q 'mtree *-PU' /etc/rc.firmware; then
+ PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
+ PID=''
+ IMG=''
+ if [ -n "${PROC}" ]; then
+ PID=$(echo "${PROC}" | awk '{print $1}')
+ IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
+ fi
+
+ if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
+ kill ${PID} >/dev/null 2>&1
+ kill -9 ${PID} >/dev/null 2>&1
+ sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
+ /etc/rc.firmware pfSenseupgrade "${IMG}"
+ exit
+ fi
+fi
+
+rm /boot/kernel/*
+
OpenPOWER on IntegriCloud