mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 00:07:27 +00:00
etc: permanent location for installer glue
This commit is contained in:
parent
93e613c511
commit
9bc667c6f6
@ -144,9 +144,9 @@ case ${opmode} in
|
||||
;;
|
||||
99)
|
||||
if [ -e /dev/ukbd0 ]; then
|
||||
env TERM=cons25 /scripts/lua_installer
|
||||
env TERM=cons25 /usr/local/installer/lua_installer
|
||||
else
|
||||
/scripts/lua_installer
|
||||
/usr/local/installer/lua_installer
|
||||
fi
|
||||
;;
|
||||
100)
|
||||
|
||||
@ -60,11 +60,11 @@ function rescue_detect_keypress() {
|
||||
if (in_array($key, array("r", "R"))) {
|
||||
putenv("TERM=cons25");
|
||||
echo "\n\nRecovery mode selected...\n";
|
||||
passthru("/usr/bin/env TERM=cons25 /bin/tcsh -c /scripts/lua_installer_rescue");
|
||||
passthru("/usr/bin/env TERM=cons25 /bin/tcsh -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/tcsh -c /scripts/lua_installer");
|
||||
passthru("/usr/bin/env TERM=cons25 /bin/tcsh -c /usr/local/installer/lua_installer");
|
||||
if(file_exists("/tmp/install_complete")) {
|
||||
passthru("/etc/rc.reboot");
|
||||
exit;
|
||||
|
||||
@ -15,7 +15,7 @@ for i in tmp varmfs etcmfs; do
|
||||
done
|
||||
|
||||
# Start PFI
|
||||
/bin/sh /scripts/pfi start
|
||||
/bin/sh /usr/local/installer/pfi start
|
||||
|
||||
# If PFI did not find a config, we should create
|
||||
# a tiny mfs under /conf and populate with stock
|
||||
|
||||
44
usr/local/installer/after_installation_routines.sh
Executable file
44
usr/local/installer/after_installation_routines.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copy the current running systems config.xml to the target installation area.
|
||||
mkdir -p /mnt/cf/conf
|
||||
cp -r /cf/conf/* /mnt/cf/conf/
|
||||
touch /mnt/cf/conf/trigger_initial_wizard
|
||||
|
||||
# Updating boot loader
|
||||
echo autoboot_delay=\"3\" >> /mnt/boot/loader.conf
|
||||
echo vm.kmem_size=\"435544320\" >> /mnt/boot/loader.conf
|
||||
echo vm.kmem_size_max=\"535544320\" >> /mnt/boot/loader.conf
|
||||
|
||||
echo kern.ipc.nmbclusters=\"0\" >> /mnt/boot/loader.conf
|
||||
|
||||
# Hide usbus# from network interfaces list on pfSense >= 2.1
|
||||
VERSION=`head -n 1 /mnt/etc/version | cut -c 1-3`; if [ "${VERSION}" != "1.2" -a "${VERSION}" != "2.0" ]; then echo hw.usb.no_pf=\"1\" >> /mnt/boot/loader.conf; fi;
|
||||
|
||||
# Set platform back to pfSense to prevent freesbie_1st from running
|
||||
echo "pfSense" > /mnt/usr/local/etc/platform
|
||||
|
||||
# Let parent script know that a install really happened
|
||||
touch /tmp/install_complete
|
||||
|
||||
chmod a-w /mnt/boot/loader.rc
|
||||
chflags schg /mnt/boot/loader.rc
|
||||
|
||||
mkdir -p /mnt/var/installer_logs
|
||||
cp /tmp/install.disklabel /mnt/var/installer_logs
|
||||
cp /tmp/install.disklabel* /mnt/var/installer_logs
|
||||
cp /tmp/installer.log /mnt/var/installer_logs
|
||||
cp /tmp/install-session.sh /mnt/var/installer_logs
|
||||
cp /tmp/new.fdisk /mnt/var/installer_logs
|
||||
|
||||
mkdir -p /mnt/var/db/pkg
|
||||
cd /var/db/pkg ; tar -cpf - . | (cd /mnt/var/db/pkg ; tar -xpf -)
|
||||
|
||||
# If the platform is vmware, lets do some fixups.
|
||||
if [ -f /var/IS_VMWARE ]; then echo "" >> /mnt/etc/sysctl.conf; echo "kern.timecounter.hardware=i8254" >> /mnt/etc/sysctl.conf; echo kern.hz="100" >> /mnt/boot/loader.conf; fi;
|
||||
|
||||
# Fixup permissions on installed files
|
||||
if [ -f /etc/installed_filesystem.mtree ]; then /usr/sbin/mtree -U -e -q -f /etc/installed_filesystem.mtree -p /mnt/ > /mnt/conf/mtree.log; fi;
|
||||
|
||||
#Sync disks
|
||||
/bin/sync
|
||||
13
usr/local/installer/cleargpt.sh
Executable file
13
usr/local/installer/cleargpt.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
DISK=$1
|
||||
if [ "$DISK" = "" ]; then
|
||||
echo "You must specify the disk that should be formatted/cleared."
|
||||
exit 1
|
||||
fi
|
||||
for PART in `gpart show $DISK | grep -v '=>' | awk '{ print $3 }'`; do
|
||||
if [ "$PART" != "" ]; then
|
||||
/sbin/gpart delete -i $PART $DISK >/dev/null
|
||||
fi
|
||||
done
|
||||
/sbin/gpart destroy $DISK >/dev/null
|
||||
exit 0
|
||||
155
usr/local/installer/lua_installer
Executable file
155
usr/local/installer/lua_installer
Executable file
@ -0,0 +1,155 @@
|
||||
#!/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..."
|
||||
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 -- early boot
|
||||
if [ `dmesg -a | grep VMware | wc -l` -gt 0 ]; then
|
||||
touch /var/IS_VMWARE
|
||||
fi
|
||||
|
||||
# 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 "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
|
||||
|
||||
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 https://192.168.1.1 (or the LAN IP Address) in the"
|
||||
echo "location bar."
|
||||
echo
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
146
usr/local/installer/lua_installer_rescue
Executable file
146
usr/local/installer/lua_installer_rescue
Executable file
@ -0,0 +1,146 @@
|
||||
#!/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
|
||||
|
||||
252
usr/local/installer/pfi
Executable file
252
usr/local/installer/pfi
Executable file
@ -0,0 +1,252 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $Id$
|
||||
# $DragonFly: src/nrelease/installer/etc/rc.d/pfi,v 1.2 2004/07/11 18:55:20 cpressey Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: pfi
|
||||
# REQUIRE: mountoptional
|
||||
# KEYWORD: FreeBSD
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=pfi
|
||||
start_cmd="pfi_start"
|
||||
stop_cmd=":"
|
||||
thttpd_location="/scripts/thttpd"
|
||||
|
||||
touch /etc/rc.conf
|
||||
|
||||
get_config_xml()
|
||||
{
|
||||
if [ -r $1/conf/config.xml ]; then
|
||||
echo -n "[config.xml on $1]"
|
||||
# Now that we have found config.xml lets mount
|
||||
# the device in nullfs under /cf/conf and /conf
|
||||
mount_nullfs /tmp/mnt/cf /cf
|
||||
mount_nullfs /tmp/mnt/cf/conf /conf
|
||||
if [ ! -r /cf/conf/config.xml ]; then
|
||||
echo
|
||||
echo "Something went wrong. Launching shell!";
|
||||
/bin/sh
|
||||
fi
|
||||
echo
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
look_for_config_xml_config_msdos()
|
||||
{
|
||||
mkdir -p /tmp/mnt/cf
|
||||
echo -n "Looking for config.xml on "
|
||||
for try_device in da0 da0s1 da1 da1s1 da2 da2s1 da3 da3s1 da4 da4s1 da5 da5s1 fd0 fd1; do
|
||||
if [ ! -e /dev/${try_device} ]; then
|
||||
continue
|
||||
fi
|
||||
echo -n "$try_device "
|
||||
if mount -t msdos /dev/$try_device /tmp/mnt/cf 2>/dev/null ; then
|
||||
echo -n "[found msdos] "
|
||||
# Note for later that this device is capable
|
||||
# of having config.xml on it for perm. storage
|
||||
/bin/mkdir -p /var/db/pfi/
|
||||
/usr/bin/touch /var/db/pfi/capable_${try_device}
|
||||
# look for config.xml, if its found return 0
|
||||
if get_config_xml /tmp/mnt/cf /dev/$try_device; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "done."
|
||||
return 1
|
||||
}
|
||||
|
||||
get_pfi_config()
|
||||
{
|
||||
[ -r /etc/pfi.conf ] && return 0
|
||||
|
||||
if [ -r $1/pfi.conf ]; then
|
||||
echo -n "Found pfi.conf on $1"
|
||||
tr -d "\r" < $1/pfi.conf > /etc/pfi.conf
|
||||
echo "pfi_found_on_device='$2'" >> /etc/pfi.conf
|
||||
echo "#@@@@@" >>/etc/rc.conf
|
||||
cat /etc/pfi.conf >>/etc/rc.conf
|
||||
if [ -r /etc/defaults/pfi.conf ]; then
|
||||
. /etc/defaults/pfi.conf
|
||||
fi
|
||||
. /etc/pfi.conf
|
||||
if [ "$pfi_script" != "" -a -x "$1/$pfi_script" ]; then
|
||||
$1/$pfi_script
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_authorized_hosts()
|
||||
{
|
||||
[ -r /root/authorized_hosts ] && return 0
|
||||
if [ -r $1/authorized_hosts ]; then
|
||||
echo "Authorized_hosts found on $1"
|
||||
mkdir -p ~root/.ssh/
|
||||
tr -d "\r" < $1/authorized_hosts > /root/.ssh/authorized_hosts
|
||||
fi
|
||||
}
|
||||
|
||||
look_for_pfi_config_msdos()
|
||||
{
|
||||
[ -r /etc/pfi.conf ] && return 0
|
||||
echo -n "Looking for pfi.conf on "
|
||||
for try_device in da0 da1 da0s1 da1s1 fd0 fd1; do
|
||||
if [ ! -e /dev/${try_device} ]; then
|
||||
continue
|
||||
fi
|
||||
echo -n "${try_device} "
|
||||
if mount -t msdos -o rdonly /dev/$try_device /tmp/mnt 2>/dev/null ; then
|
||||
echo -n "[found] "
|
||||
get_authorized_hosts
|
||||
if get_pfi_config /tmp/mnt /dev/$try_device; then
|
||||
umount /tmp/mnt
|
||||
echo -n "[found] "
|
||||
return 0
|
||||
fi
|
||||
umount /tmp/mnt
|
||||
fi
|
||||
done
|
||||
echo "done. "
|
||||
return 1
|
||||
}
|
||||
|
||||
look_for_pfi_config_cd9660()
|
||||
{
|
||||
[ -r /etc/pfi.conf ] && return 0
|
||||
echo -n "Looking for pfi.conf on "
|
||||
for try_device in acd0c; do
|
||||
echo -n "${try_device} "
|
||||
if [ ! -e /dev/${try_device} ]; then
|
||||
echo "done. "
|
||||
return 1
|
||||
#( cd /dev && ./MAKEDEV ${try_device} )
|
||||
fi
|
||||
if mount_cd9660 /dev/$try_device /tmp/mnt ; then
|
||||
echo -n "[found] "
|
||||
get_authorized_hosts
|
||||
if get_pfi_config /tmp/mnt /dev/$try_device; then
|
||||
umount /tmp/mnt
|
||||
echo -n "[found]"
|
||||
return 0
|
||||
fi
|
||||
umount /tmp/mnt
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
pfi_start()
|
||||
{
|
||||
|
||||
# Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
|
||||
|
||||
look_for_pfi_config_cd9660
|
||||
look_for_pfi_config_msdos
|
||||
look_for_config_xml_config_msdos # look for pfsense config.xml
|
||||
|
||||
if [ ! -r /etc/pfi.conf ]; then
|
||||
echo '' >/etc/pfi.conf
|
||||
fi
|
||||
|
||||
if [ -r /etc/defaults/pfi.conf ]; then
|
||||
. /etc/defaults/pfi.conf
|
||||
fi
|
||||
. /etc/pfi.conf
|
||||
|
||||
# We can perform any pre-install tasks here by
|
||||
# examining the contents of pfi_* variables.
|
||||
|
||||
# Interpret pfi_sshd_* options. These basically add settings
|
||||
# to /etc/ssh/sshd_config; it is assumed "sshd" will appear
|
||||
# in pfi_rc_actions to restart sshd.
|
||||
|
||||
case ${pfi_sshd_permit_root_login} in
|
||||
YES)
|
||||
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
|
||||
;;
|
||||
without-password)
|
||||
echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
|
||||
;;
|
||||
forced-commands-only)
|
||||
echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${pfi_sshd_permit_empty_passwords} in
|
||||
YES)
|
||||
echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Interpret pfi_set_root_password. If it is not empty, use
|
||||
# it to set root's LiveCD password.
|
||||
|
||||
if [ "X$pfi_set_root_password" != "X" ]; then
|
||||
echo "$pfi_set_root_password" | \
|
||||
/usr/sbin/pw usermod root -h 0
|
||||
fi
|
||||
|
||||
# The most important pre-install task is to restart
|
||||
# any RCNG scripts listed in pfi_rc_actions with any new
|
||||
# settings that might have been set up by pfi.conf.
|
||||
|
||||
if [ "X$pfi_rc_actions" != "X" ]; then
|
||||
rev_actions=`reverse_list $pfi_rc_actions`
|
||||
|
||||
for _rc_elem in ${rev_actions}; do
|
||||
echo "Stopping ${_rc_elem}..."
|
||||
/etc/rc.d/${_rc_elem} stop
|
||||
#rcstop ${_rc_elem}
|
||||
done
|
||||
for _rc_elem in ${pfi_rc_actions}; do
|
||||
echo "Starting ${_rc_elem}..."
|
||||
/etc/rc.d/${_rc_elem} start
|
||||
#rcstart ${_rc_elem}
|
||||
done
|
||||
fi
|
||||
|
||||
# Now remove the copy of pfi.conf that we tacked onto
|
||||
# the end of rc.conf so the above would work
|
||||
|
||||
awk '$1=="#@@@@@" || cut { cut = 1 } !cut { print $0 }' \
|
||||
</etc/rc.conf >/etc/rc.conf.new
|
||||
mv /etc/rc.conf.new /etc/rc.conf
|
||||
|
||||
# Set up auto-login if requested.
|
||||
|
||||
if [ "X$pfi_autologin" != "XNONE" ]; then
|
||||
echo 'autologin|al.9600:\' >> /etc/gettytab
|
||||
echo " :al=${pfi_autologin}:tc=std.9600:" >> /etc/gettytab
|
||||
sed -i '' 's/^ttyv0=.*/ttyv0 "\/usr\/libexec\/getty Al" cons25 on secure/' /etc/ttys
|
||||
fi
|
||||
|
||||
# Finally, start thttpd if the user wants to use
|
||||
# the cgi frontend.
|
||||
|
||||
if [ "X$pfi_frontend" = "Xcgi" ]; then
|
||||
echo "Starting thttpd..."
|
||||
echo dir=/usr/local/www > /tmp/thttpd.conf
|
||||
echo user=root >> /tmp/thttpd.conf
|
||||
echo cgipat=*.cgi >> /tmp/thttpd.conf
|
||||
echo logfile=/var/log/thttpd.log >> /tmp/thttpd.conf
|
||||
echo pidfile=/var/run/thttpd.pid >> /tmp/thttpd.conf
|
||||
$thttpd_location -C /tmp/thttpd.conf
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user