core/src/etc/rc.initial

94 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# Copyright (c) 2014-2016 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2004-2011 Scott Ullrich <sullrich@gmail.com>
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>
# All rights reserved.
# make sure the user can't kill us
trap : 2
trap : 3
# shell started with parameters, passthrough to real shell
if [ -n "${*}" ]; then
/bin/csh "${@}"
exit ${?}
fi
# endless loop
while : ; do
# We `set -e' to force exit if we encounter an error.
# This is mainly useful in case we lose our tty (happens when
# an ssh connection breaks, for example), in which case our stdout
# is closed and the `echo' commands in the while loop will silently fail.
# Failure to exit at that moment would lead to an infinite loop.
set -e
echo
echo " 0) Logout 7) Ping host"
echo " 1) Assign Interfaces 8) Shell"
echo " 2) Set interface(s) IP address 9) pfTop"
echo " 3) Reset the root password 10) Filter Logs"
echo " 4) Reset to factory defaults 11) Reload all services"
echo " 5) Power off system 12) Upgrade from console"
echo " 6) Reboot system 13) Restore a configuration"
echo
read -p "Enter an option: " OPCODE
echo
# The scripts we'll call below may return non-zero, don't exit if they do
set +e
# see what the user has chosen
case ${OPCODE} in
0|exit|logout|quit)
exit
;;
1)
/usr/local/etc/rc.initial.setports
;;
2)
/usr/local/etc/rc.initial.setlanip
;;
3)
/usr/local/etc/rc.initial.password
;;
4)
/usr/local/etc/rc.initial.defaults
;;
5)
/usr/local/etc/rc.initial.halt
;;
6)
/usr/local/etc/rc.initial.reboot
;;
7)
/usr/local/etc/rc.initial.ping
;;
8)
/bin/csh
;;
9)
/usr/local/sbin/pftop
;;
10)
/usr/sbin/tcpdump -s 256 -v -S -l -n -e -ttt -i pflog0
;;
11)
/usr/local/etc/rc.reload_all
;;
12)
/usr/local/etc/rc.initial.firmware
;;
13)
/usr/local/etc/rc.initial.restore
;;
*)
;;
esac
/usr/local/etc/rc.initial.banner
done