rc.initial 2.19 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1 2
#!/bin/sh

3 4 5
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2004-2011 Scott Ullrich <sullrich@gmail.com>
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>
Ad Schellevis's avatar
Ad Schellevis committed
6 7
# All rights reserved.

8 9 10
# make sure the user can't kill us
trap : 2
trap : 3
Ad Schellevis's avatar
Ad Schellevis committed
11 12 13

# If recovery console shell option has been specified
if [ -f "/tmp/donotbootup" ]; then
14 15
	rm /tmp/donotbootup
	/bin/csh
16
	/usr/local/etc/rc.reboot
17
	# no coming back from here
Ad Schellevis's avatar
Ad Schellevis committed
18 19
fi

20 21 22 23 24
# shell started with parameters, passthrough to real shell
if [ -n "${*}" ]; then
	/bin/csh "${@}"
	exit ${?}
fi
25

Ad Schellevis's avatar
Ad Schellevis committed
26 27 28
# endless loop
while : ; do

29 30
echo

31
# If we are on the install media advertise that fact
32 33 34 35
if _tmpdir=$(mktemp -d -q /.diskless.XXXXXX); then
	rmdir ${_tmpdir}
else
	option99="99) Launch the installer"
Ad Schellevis's avatar
Ad Schellevis committed
36 37
fi

38 39 40 41 42
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) Restart web interface"
43 44
echo " 5) Halt system                       12) Upgrade from console"
echo " 6) Reboot system                     13) Restore a configuration"
45 46 47
if [ -n "${option99}" ]; then
# flat for alignment...
echo "                                      ${option99}"
Ad Schellevis's avatar
Ad Schellevis committed
48 49 50
fi

echo
51
read -p "Enter an option: " OPCODE
Ad Schellevis's avatar
Ad Schellevis committed
52 53 54
echo

# see what the user has chosen
55 56
case ${OPCODE} in
0|exit|logout|quit)
57
        exit
Ad Schellevis's avatar
Ad Schellevis committed
58 59
        ;;
1)
60
        /usr/local/etc/rc.initial.setports
Ad Schellevis's avatar
Ad Schellevis committed
61 62
        ;;
2)
63
        /usr/local/etc/rc.initial.setlanip
Ad Schellevis's avatar
Ad Schellevis committed
64 65
        ;;
3)
66
        /usr/local/etc/rc.initial.password
Ad Schellevis's avatar
Ad Schellevis committed
67 68
        ;;
4)
69
        /usr/local/etc/rc.initial.defaults
Ad Schellevis's avatar
Ad Schellevis committed
70 71
        ;;
5)
72
        /usr/local/etc/rc.initial.halt
Ad Schellevis's avatar
Ad Schellevis committed
73 74
        ;;
6)
75
        /usr/local/etc/rc.initial.reboot
Ad Schellevis's avatar
Ad Schellevis committed
76 77
        ;;
7)
78
        /usr/local/etc/rc.initial.ping
Ad Schellevis's avatar
Ad Schellevis committed
79 80
        ;;
8)
81
        /bin/csh
Ad Schellevis's avatar
Ad Schellevis committed
82 83 84 85 86
        ;;
9)
        /usr/local/sbin/pftop
        ;;
10)
87 88 89
	/usr/sbin/tcpdump -s 256 -v -S -l -n -e -ttt -i pflog0
	;;
11)
90
	/usr/local/etc/rc.restart_webgui
91
	;;
Ad Schellevis's avatar
Ad Schellevis committed
92
12)
93
	/usr/local/etc/rc.initial.firmware
94
	;;
95
13)
Franco Fichtner's avatar
Franco Fichtner committed
96
	/usr/local/etc/rc.restore_config_backup
97
	;;
Ad Schellevis's avatar
Ad Schellevis committed
98
99)
99
	/usr/local/etc/rc.installer
100 101
	;;
*)
102
	/bin/sh -c "${OPCODE}"
103
	;;
Ad Schellevis's avatar
Ad Schellevis committed
104 105
esac

106 107 108
/usr/local/etc/rc.initial.banner

done