diff options
author | Renato Botelho <renato@netgate.com> | 2015-08-17 17:02:01 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-08-17 17:05:29 -0300 |
commit | 8f400b8fdd6d4038928194799ef3f0852c86e6d4 (patch) | |
tree | a23d955ffe1e8103502d9a5b92119c9af611249a /usr/local | |
parent | 00b8b2eca28c5d7911b132ff581ed481e1d75abe (diff) | |
download | pfsense-8f400b8fdd6d4038928194799ef3f0852c86e6d4.zip pfsense-8f400b8fdd6d4038928194799ef3f0852c86e6d4.tar.gz |
Move scripts from /tmp -> /usr/local/share/pfSense
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/share/pfSense/post_upgrade_command | 64 | ||||
-rwxr-xr-x | usr/local/share/pfSense/post_upgrade_command.php | 31 | ||||
-rw-r--r-- | usr/local/share/pfSense/pre_upgrade_command | 58 |
3 files changed, 153 insertions, 0 deletions
diff --git a/usr/local/share/pfSense/post_upgrade_command b/usr/local/share/pfSense/post_upgrade_command new file mode 100755 index 0000000..eea691f --- /dev/null +++ b/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}tmp/post_upgrade_command.php... " >> /conf/upgrade_log.txt +if [ -x ${ROOT}tmp/post_upgrade_command.php ]; then + echo "Running ${ROOT}tmp/post_upgrade_command.php $1" >> /conf/upgrade_log.txt + ${ROOT}tmp/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}etc/installed_filesystem.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}etc/installed_filesystem.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/usr/local/share/pfSense/post_upgrade_command.php b/usr/local/share/pfSense/post_upgrade_command.php new file mode 100755 index 0000000..c2b6901 --- /dev/null +++ b/usr/local/share/pfSense/post_upgrade_command.php @@ -0,0 +1,31 @@ +#!/usr/local/bin/php -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/usr/local/share/pfSense/pre_upgrade_command b/usr/local/share/pfSense/pre_upgrade_command new file mode 100644 index 0000000..2ad365f --- /dev/null +++ b/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/* + |