Project

General

Profile

Download (3.51 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/bin/sh
2
3
# /etc/rc.initial
4 99227fad Scott Ullrich
# part of pfSense by Scott Ullrich
5 2ba6c4ab Scott Ullrich
# Copyright (C) 2004-2011 Scott Ullrich, All rights reserved.
6 e5cd29a0 Scott Ullrich
# originally based on m0n0wall (http://neon1.net/m0n0wall)
7 5b237745 Scott Ullrich
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
# All rights reserved.
9 89c5f759 Scott Ullrich
10 cd80a0a8 Scott Ullrich
# make sure the user can't kill us by pressing Ctrl-C,
11
# ctrl-z, etc.
12 e8b82b81 Scott Ullrich
#trap : 2
13
#trap : 3
14
#trap : 4
15 5b237745 Scott Ullrich
16 d1f9da0a Scott Ullrich
# If recovery console shell option has been specified
17
if [ -f "/tmp/donotbootup" ]; then
18
	/usr/bin/env prompt="%B[%n@%m]%b%/(%h)||RecoveryConsoleShell: " /bin/tcsh
19
	rm "/tmp/donotbootup"
20
	echo "Rebooting in 5 seconds... CTRL-C to abort..."
21
	sleep 5
22
	/etc/rc.reboot
23
	exit
24
fi
25
26 9c98ee85 Scott Ullrich
if [ -f /etc/rc.local ]; then
27 a32c7a23 Scott Ullrich
	RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
28 5f8e5e14 Scott Ullrich
	if [ "$RCLOCALPWD" = "" ]; then
29
		echo ">>> Launching rc.local in background..."
30
		sh /etc/rc.local &
31 c3ebb669 Scott Ullrich
		sleep 1
32
		sh /etc/rc.local.running &
33 32cd7c36 Scott Ullrich
	else
34
		if [ -f /etc/rc.local.running ]; then
35
			echo ">>> Launching rc.local.running in background..."
36
			sh /etc/rc.local.running &
37
		fi
38 5f8e5e14 Scott Ullrich
	fi
39 9c98ee85 Scott Ullrich
fi
40
41 89c5f759 Scott Ullrich
CONFIG="/cf/conf/config.xml"
42
WORD="https"
43
44 c0c27851 Scott Ullrich
# Set our operating platform
45
PLATFORM=`cat /etc/platform`
46
47 7734aea6 Andrew Thompson
if [ "$PLATFORM" = "jail" ]; then
48
	exit
49
fi
50
51 5b237745 Scott Ullrich
# endless loop
52
while : ; do
53
54 7c961207 Scott Ullrich
if [ -f /tmp/ttybug ]; then
55
	rm /tmp/ttybug
56
	exit && exit && logout
57
fi
58
59 6a997de8 Scott Ullrich
/etc/rc.banner
60
61 2580f584 Chris Buechler
product=`grep product_name /etc/inc/globals.inc | cut -d'"' -f4`
62
hidebanner=`grep hidebanner /etc/inc/globals.inc | cut -d'"' -f4`
63 19525ae7 Scott Ullrich
64 61b2ed1c Chris Buechler
# Check to see if SSH is running.
65 8c366060 Renato Botelho
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
66 2db9a6d6 Scott Ullrich
	sshd_option="14) Disable Secure Shell (sshd)";
67 2a5a9c6a Scott Ullrich
else
68 2db9a6d6 Scott Ullrich
	sshd_option="14) Enable Secure Shell (sshd)";
69 2a5a9c6a Scott Ullrich
fi
70
71 f321b3a2 Scott Ullrich
for i in /var/db/pfi/capable_*; do
72 e173dd74 Phil Davis
	if [ -f $i -a ! -L /cf/conf ]; then
73
		option98="98) Move configuration file to removable device"
74
		break
75
	fi
76 f321b3a2 Scott Ullrich
done
77 2730fde3 Scott Ullrich
78
if [ "$PLATFORM" = "cdrom" ]; then
79 e173dd74 Phil Davis
	option99="99) Install ${product} to a hard drive, etc."
80 2730fde3 Scott Ullrich
fi
81 5b237745 Scott Ullrich
82 2db9a6d6 Scott Ullrich
# display a cheap menu
83
echo ""
84 5a42d9ef Renato Botelho
echo " 0) Logout (SSH only)                  9) pfTop"
85
echo " 1) Assign Interfaces                 10) Filter Logs"
86
echo " 2) Set interface(s) IP address       11) Restart webConfigurator"
87
echo " 3) Reset webConfigurator password    12) ${product} Developer Shell"
88
echo " 4) Reset to factory defaults         13) Upgrade from console"
89
echo " 5) Reboot system                     ${sshd_option}"
90
echo " 6) Halt system                       15) Restore recent configuration"
91
echo " 7) Ping host                         16) Restart PHP-FPM"
92
echo " 8) Shell"
93 a3cc8dcc Ermal
echo " ${option98} "
94 6141561c Scott Ullrich
95
if [ "${option99}" != "" ]; then
96
	/bin/echo "${option99}"
97
fi
98 2db9a6d6 Scott Ullrich
99 4d0a1ade Scott Ullrich
echo
100 568af189 Colin Smith
read -p "Enter an option: " opmode
101 4df08112 Scott Ullrich
echo
102 5b237745 Scott Ullrich
103
# see what the user has chosen
104
case ${opmode} in
105 debddb24 Scott Ullrich
0)
106 e173dd74 Phil Davis
	exit && exit && logout
107
	;;
108 5b237745 Scott Ullrich
1)
109 e173dd74 Phil Davis
	/etc/rc.initial.setports
110
	;;
111 5b237745 Scott Ullrich
2)
112 e173dd74 Phil Davis
	/etc/rc.initial.setlanip
113
	;;
114 5b237745 Scott Ullrich
3)
115 e173dd74 Phil Davis
	/etc/rc.initial.password
116
	;;
117 5b237745 Scott Ullrich
4)
118 e173dd74 Phil Davis
	/etc/rc.initial.defaults
119
	;;
120 5b237745 Scott Ullrich
5)
121 e173dd74 Phil Davis
	/etc/rc.initial.reboot
122
	;;
123 5b237745 Scott Ullrich
6)
124 e173dd74 Phil Davis
	/etc/rc.initial.halt
125
	;;
126 5b237745 Scott Ullrich
7)
127 e173dd74 Phil Davis
	/etc/rc.initial.ping
128
	;;
129 97a741af Scott Ullrich
8)
130 e173dd74 Phil Davis
	/bin/tcsh
131
	;;
132 97a741af Scott Ullrich
9)
133 e173dd74 Phil Davis
	/usr/local/sbin/pftop
134
	;;
135 97a741af Scott Ullrich
10)
136 e173dd74 Phil Davis
	/usr/local/sbin/clog -f /var/log/filter.log
137
	;;
138 e6702447 jim-p
11 | 111)
139 e173dd74 Phil Davis
	/etc/rc.restart_webgui
140
	;;
141 dc7e008c Scott Ullrich
12)
142 e173dd74 Phil Davis
	/usr/local/sbin/pfSsh.php
143
	;;
144
13)
145
	php -f /etc/rc.initial.firmware_update
146
	;;
147
14)
148
	php -f /etc/rc.initial.toggle_sshd
149
	;;
150 069f9bae Scott Ullrich
15)
151 e173dd74 Phil Davis
	/etc/rc.restore_config_backup
152
	;;
153 133bd2b2 jim-p
16)
154 e173dd74 Phil Davis
	/etc/rc.php-fpm_restart
155
	;;
156 9eb7a7b4 Scott Ullrich
98)
157 e173dd74 Phil Davis
	if [ ! -f /tmp/config_moved ]; then
158
		/etc/rc.initial.store_config_to_removable_device
159
	fi
160
	;;
161 c26023b4 Scott Ullrich
99)
162 e173dd74 Phil Davis
	if [ -e /dev/ukbd0 ]; then
163
		env TERM=cons25 /scripts/lua_installer
164
	else
165
		/scripts/lua_installer
166
	fi
167
	;;
168 f446f817 Scott Ullrich
100)
169 e173dd74 Phil Davis
	if grep "$WORD" "$CONFIG"; then
170
		links "https://localhost"
171
	else
172
		links "http://localhost"
173
	fi
174
	;;
175 d8d46c26 Scott Ullrich
"")
176 e173dd74 Phil Davis
	kill $PPID ; exit
177
	;;
178 5b237745 Scott Ullrich
esac
179
180 4c7856cf Scott Ullrich
done