Commit c076d1c7 authored by Franco Fichtner's avatar Franco Fichtner

rc: change install media workflow

* Boot into the installer by default; it can still be aborted.

* Remove the dysfunct rescue installer.  The normal installer
  now has a better rescue tool called "Import configuration".

* Move and rework the installer launcher as rc.installer.  It
  can be called at any time if needed.
parent 46251a02
......@@ -31,21 +31,19 @@
POSSIBILITY OF SUCH DAMAGE.
*/
function rescue_detect_keypress() {
// How long do you want the script to wait before moving on (in seconds)
$timeout=9;
function rescue_detect_keypress()
{
$timeout = 9;
echo "\n";
echo "[ Press R to enter recovery mode or ]\n";
echo "[ press I to launch the installer ]\n\n";
echo "(R)ecovery mode can assist by rescuing config.xml\n";
echo "from a broken hard disk installation, etc.\n\n";
echo "(I)nstaller may be invoked now if you do \n";
echo "not wish to boot into the liveCD environment at this time.\n\n";
echo "(C) continues the LiveCD bootup without further pause.\n\n";
echo "(I)nstaller will be invoked by default.\n\n";
echo "(C)ontinue with LiveCD bootup instead.\n\n";
echo "(R)ecovery mode escapes to a root shell.\n\n";
echo "Timeout before auto boot continues (seconds): {$timeout}";
$key = null;
exec("/bin/stty erase " . chr(8));
while(!in_array($key, array("c", "C", "r","R", "i", "I", "~", "!"))) {
while (!in_array($key, array("c", "C", "r","R", "i", "I"))) {
echo chr(8) . "{$timeout}";
`/bin/stty -icanon min 0 time 25`;
$key = trim(`KEY=\`dd count=1 2>/dev/null\`; echo \$KEY`);
......@@ -53,30 +51,26 @@ function rescue_detect_keypress() {
// Decrement our timeout value
$timeout--;
// If we have reached 0 exit and continue on
if ($timeout == 0)
break;
if ($timeout == 0) {
break;
}
}
// If R or I was pressed do our logic here
echo "\n\n";
if (in_array($key, array("r", "R"))) {
putenv("TERM=cons25");
echo "\n\nRecovery mode selected...\n";
passthru("/usr/bin/env TERM=cons25 /bin/csh -c /usr/local/installer/lua_installer_rescue");
} elseif (in_array($key, array("i", "I"))) {
putenv("TERM=cons25");
echo "\n\nInstaller mode selected...\n";
passthru("/usr/bin/env TERM=cons25 /bin/csh -c /usr/local/installer/lua_installer");
if(file_exists("/tmp/install_complete")) {
passthru("/usr/local/etc/rc.reboot");
exit;
}
} elseif (in_array($key, array("!", "~"))) {
putenv("TERM=cons25");
echo "\n\nRecovery shell selected...\n";
echo "\n";
echo "Recovery shell selected...\n\n";
touch("/tmp/donotbootup");
exit;
} elseif (in_array($key, array("c", "C"))) {
/* nothing */
} else {
echo "\n\n";
echo "Installer mode selected...\n";
passthru("/usr/local/etc/rc.installer");
if (file_exists("/tmp/install_complete")) {
passthru("/usr/local/etc/rc.reboot");
exit;
}
}
}
......
......@@ -14,25 +14,15 @@
# If recovery console shell option has been specified
if [ -f "/tmp/donotbootup" ]; then
/usr/bin/env prompt="%B[%n@%m]%b%/(%h)||RecoveryConsoleShell: " /bin/csh
rm "/tmp/donotbootup"
echo "Rebooting in 5 seconds... CTRL-C to abort..."
sleep 5
rm /tmp/donotbootup
/bin/csh
/usr/local/etc/rc.reboot
exit
# no coming back from here
fi
CONFIG="/cf/conf/config.xml"
WORD="https"
# Set our operating platform
PLATFORM=`cat /usr/local/etc/platform`
# endless loop
while : ; do
product=`grep product_name /usr/local/etc/inc/globals.inc | cut -d'"' -f4`
# Check to see if SSH is running.
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
sshd_option="14) Disable Secure Shell (sshd)";
......@@ -40,21 +30,24 @@ else
sshd_option="14) Enable Secure Shell (sshd)";
fi
if [ "$PLATFORM" = "cdrom" ]; then
option99="99) Install ${product} to a hard drive, etc."
# If we are on the LiveCD advertise the installer
if _tmpdir=$(mktemp -d -q /.diskless.XXXXXX); then
rmdir ${_tmpdir}
else
option99="99) Launch the installer"
fi
# display a cheap menu
echo " 0) Logout 8) Shell"
echo " 1) Assign Interfaces 9) pfTop"
echo " 2) Set interface(s) IP address 10) Filter Logs"
echo " 3) Reset webConfigurator password 11) Restart webConfigurator"
echo " 4) Reset to factory defaults 12) ${product} Developer Shell"
echo " 3) Reset the root password 11) Restart web interface"
echo " 4) Reset to factory defaults 12) Developer Shell"
echo " 5) Reboot system 13) Upgrade from console"
echo " 6) Halt system ${sshd_option}"
echo " 7) Ping host 15) Restore recent configuration"
if [ "${option99}" != "" ]; then
/bin/echo "${option99}"
echo " 7) Ping host 15) Restore a configuration"
if [ -n "${option99}" ]; then
# flat for alignment...
echo " ${option99}"
fi
echo
......@@ -112,18 +105,13 @@ case ${opmode} in
/usr/local/etc/rc.restore_config_backup
;;
99)
if [ -e /dev/ukbd0 ]; then
env TERM=cons25 /usr/local/installer/lua_installer
else
/usr/local/installer/lua_installer
fi
/usr/local/etc/rc.installer
;;
*)
;;
esac
/usr/local/etc/rc.initial.banner
echo
done
......@@ -5,14 +5,14 @@
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
......@@ -24,85 +24,34 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
product=`cat /usr/local/etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
factory_shipped_password=`cat /usr/local/etc/inc/globals.inc | grep factory_shipped_password | cut -d'"' -f4`
factory_shipped_username=`cat /usr/local/etc/inc/globals.inc | grep factory_shipped_username | cut -d'"' -f4`
echo
echo "Launching ${product} Installer..."
echo
# Ensure install-session.sh exists where the installtion was recorded to
touch /tmp/install-session.sh
PRODUCT=`grep product_name /usr/local/etc/inc/globals.inc | cut -d'"' -f4`
USERNAME=`grep factory_shipped_username /usr/local/etc/inc/globals.inc | cut -d'"' -f4`
PASSWORD=`grep factory_shipped_password /usr/local/etc/inc/globals.inc | cut -d'"' -f4`
/sbin/sysctl kern.geom.debugflags=16
/sbin/sysctl kern.geom.debugflags=16 >/dev/null
/sbin/sysctl net.link.ether.inet.log_arp_wrong_iface=0 >/dev/null
/sbin/ifconfig lo0 127.0.0.1/24
/sbin/ifconfig lo0 up
# Check if host is running on VMware -- early boot
if [ `dmesg -a | grep VMware | wc -l` -gt 0 ]; then
touch /var/IS_VMWARE
fi
# Start the backend in the background (must mute all the ouput)
LUA_CPATH='/usr/local/lib/lua/5.0/?.so' /usr/local/bin/lua50 \
-l/usr/local/share/lua/5.0/compat-5.1.lua \
/usr/local/share/dfuibe_lua/main.lua \
/usr/local/share/dfuibe_lua/conf/BSDInstaller.lua \
/usr/local/share/dfuibe_lua/conf/FreeBSD.lua \
/usr/local/share/dfuibe_lua/conf/pfSense.lua > /dev/null 2>&1 &
# Check if host is running on VMware
if [ -f /var/log/dmesg.boot ]; then
if [ `cat /var/log/dmesg.boot | /usr/bin/grep VMware | /usr/bin/wc -l` -gt 0 ]; then
echo -n "VMware detected. The installer will make changes to tune this host."
touch /var/IS_VMWARE
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo "."
fi
/sbin/conscontrol mute on > /dev/null
# Check if host is running on pfSenseDEV
if [ `/sbin/sysctl -n kern.bootfile | /usr/bin/grep pfSense_Dev | /usr/bin/wc -l` -gt 0 ]; then
echo -n "${product} developer iso detected."
touch /var/pfSenseDEV
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo "."
fi
# Launch the frontend goo (must include cons25 for first boot)
TERM=cons25 /usr/local/sbin/dfuife_curses
if [ -f /var/run/dmesg.boot ]; then
ln -s /var/log/dmesg.boot /var/run/dmesg.boot
fi
fi
echo "One moment please..."
echo
echo -n "LUA_CPATH='/usr/local/lib/lua/5.0/?.so' exec /usr/local/bin/lua50 -l/usr/local/share/lua/5.0/compat-5.1.lua " > /tmp/lua50c51
echo "/usr/local/share/dfuibe_lua/main.lua \
/usr/local/share/dfuibe_lua/conf/BSDInstaller.lua \
/usr/local/share/dfuibe_lua/conf/FreeBSD.lua \
/usr/local/share/dfuibe_lua/conf/pfSense.lua " >> /tmp/lua50c51
#/sbin/conscontrol mute on >/dev/null 2>&1
sh /tmp/lua50c51 >/dev/null 2>&1 &
sleep 1
echo Launching Installer NCurses frontend...
/usr/local/sbin/dfuife_curses
#/sbin/conscontrol mute off >/dev/null 2>&1
/sbin/conscontrol mute off > /dev/null
if [ ! -f /tmp/install_complete ]; then
echo Installation did not finish correctly.
echo "The installation was aborted."
echo
exit
fi
......@@ -123,7 +72,7 @@ echo
echo
echo
echo
echo "${product} is now rebooting"
echo "${PRODUCT} is now rebooting"
echo
echo "After the reboot is complete, open a web browser and"
echo "enter https://192.168.1.1 (or the LAN IP Address) in the"
......@@ -133,23 +82,14 @@ echo "You might need to acknowledge the HTTPS certificate if "
echo "your browser reports it as untrusted. This is normal"
echo "as a self-signed certificate is used by default."
echo
echo "*DEFAULT Username*: ${factory_shipped_username}"
echo "*DEFAULT Password*: ${factory_shipped_password}"
echo "*DEFAULT Username*: ${USERNAME}"
echo "*DEFAULT Password*: ${PASSWORD}"
echo
echo Rebooting in 5 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 4 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 3 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 2 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 1 second.. CTRL-C to abort.
sleep 1
echo
echo ${product} is now rebooting.
for n in 5 4 3 2 1; do
echo Rebooting in $n seconds. CTRL-C to abort.
sleep 1
done
echo
reboot
#!/bin/sh
#
# Launch BSD Installer with fake "installer root"
# Copyright 2004-2009 Scott Ullrich
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
product=`cat /usr/local/etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
factory_shipped_password=`cat /usr/local/etc/inc/globals.inc | grep factory_shipped_password | cut -d'"' -f4`
factory_shipped_username=`cat /usr/local/etc/inc/globals.inc | grep factory_shipped_username | cut -d'"' -f4`
echo
echo "Launching ${product} Installer config.xml rescue..."
echo
echo "One moment please..."
echo
# Ensure install-session.sh exists where the installtion was recorded to
touch /tmp/install-session.sh
/sbin/sysctl kern.geom.debugflags=16
/sbin/sysctl net.link.ether.inet.log_arp_wrong_iface=0 >/dev/null
/sbin/ifconfig lo0 127.0.0.1/24
/sbin/ifconfig lo0 up
# Check if host is running on VMware
if [ -f /var/log/dmesg.boot ]; then
if [ `cat /var/log/dmesg.boot | /usr/bin/grep VMware | /usr/bin/wc -l` -gt 0 ]; then
echo -n "VMware detected. The installer will make changes to tune this host."
touch /var/IS_VMWARE
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo "."
fi
# Check if host is running on pfSenseDEV
if [ `/sbin/sysctl -n kern.bootfile | /usr/bin/grep pfSense_Dev | /usr/bin/wc -l` -gt 0 ]; then
echo -n "${product} developer iso detected."
touch /var/pfSenseDEV
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo "."
fi
if [ -f /var/run/dmesg.boot ]; then
ln -s /var/log/dmesg.boot /var/run/dmesg.boot
fi
fi
echo Launching LUA Installer...
echo -n "LUA_CPATH='/usr/local/lib/lua/5.0/?.so' exec /usr/local/bin/lua50 -l/usr/local/share/lua/5.0/compat-5.1.lua " > /tmp/lua50c51
echo "/usr/local/share/dfuibe_lua/main.lua \
/usr/local/share/dfuibe_lua/conf/BSDInstaller.lua \
/usr/local/share/dfuibe_lua/conf/FreeBSD.lua \
/usr/local/share/dfuibe_lua/conf/pfSense_rescue.lua " >> /tmp/lua50c51
#/sbin/conscontrol mute on >/dev/null 2>&1
sh /tmp/lua50c51 >/dev/null 2>&1 &
sleep 1
echo Launching Installer NCurses frontend...
/usr/local/sbin/dfuife_curses
#/sbin/conscontrol mute off >/dev/null 2>&1
if [ ! -f /tmp/install_complete ]; then
echo Installation did not finish correctly.
exit
fi
clear
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo "${product} is now rebooting"
echo
echo "After the reboot is complete, open a web browser and"
echo "enter http://192.168.1.1 (or the LAN IP Address) in the"
echo "location bar."
echo
echo "*DEFAULT Username*: ${factory_shipped_username}"
echo "*DEFAULT Password*: ${factory_shipped_password}"
echo
echo Rebooting in 5 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 4 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 3 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 2 seconds. CTRL-C to abort.
sleep 1
echo Rebooting in 1 second.. CTRL-C to abort.
sleep 1
echo
echo ${product} is now rebooting.
echo
reboot
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment