1
|
#!/bin/sh
|
2
|
|
3
|
# /etc/rc.initial
|
4
|
# part of pfSense by Scott Ullrich
|
5
|
# Copyright (C) 2004-2011 Scott Ullrich, All rights reserved.
|
6
|
# originally based on m0n0wall (http://neon1.net/m0n0wall)
|
7
|
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8
|
# All rights reserved.
|
9
|
|
10
|
# make sure the user can't kill us by pressing Ctrl-C,
|
11
|
# ctrl-z, etc.
|
12
|
#trap : 2
|
13
|
#trap : 3
|
14
|
#trap : 4
|
15
|
|
16
|
# 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
|
if [ -f /etc/rc.local ]; then
|
27
|
RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
|
28
|
if [ "$RCLOCALPWD" = "" ]; then
|
29
|
echo ">>> Launching rc.local in background..."
|
30
|
sh /etc/rc.local &
|
31
|
sleep 1
|
32
|
sh /etc/rc.local.running &
|
33
|
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
|
fi
|
39
|
fi
|
40
|
|
41
|
CONFIG="/cf/conf/config.xml"
|
42
|
WORD="https"
|
43
|
|
44
|
# Set our operating platform
|
45
|
PLATFORM=`cat /etc/platform`
|
46
|
|
47
|
if [ "$PLATFORM" = "jail" ]; then
|
48
|
exit
|
49
|
fi
|
50
|
|
51
|
# endless loop
|
52
|
while : ; do
|
53
|
|
54
|
if [ -f /tmp/ttybug ]; then
|
55
|
rm /tmp/ttybug
|
56
|
exit && exit && logout
|
57
|
fi
|
58
|
|
59
|
/etc/rc.banner
|
60
|
|
61
|
product=`grep product_name /etc/inc/globals.inc | cut -d'"' -f4`
|
62
|
hidebanner=`grep hidebanner /etc/inc/globals.inc | cut -d'"' -f4`
|
63
|
|
64
|
# Check to see if SSH is running.
|
65
|
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
|
66
|
sshd_option="14) Disable Secure Shell (sshd)";
|
67
|
else
|
68
|
sshd_option="14) Enable Secure Shell (sshd)";
|
69
|
fi
|
70
|
|
71
|
for i in /var/db/pfi/capable_*; do
|
72
|
if [ -f $i -a ! -L /cf/conf ]; then
|
73
|
option98="98) Move configuration file to removable device"
|
74
|
break
|
75
|
fi
|
76
|
done
|
77
|
|
78
|
if [ "$PLATFORM" = "cdrom" ]; then
|
79
|
option99="99) Install ${product} to a hard drive, etc."
|
80
|
fi
|
81
|
|
82
|
# display a cheap menu
|
83
|
echo ""
|
84
|
echo " 0) Logout (SSH only) 8) Shell"
|
85
|
echo " 1) Assign Interfaces 9) pfTop"
|
86
|
echo " 2) Set interface(s) IP address 10) Filter Logs"
|
87
|
echo " 3) Reset webConfigurator password 11) Restart webConfigurator"
|
88
|
echo " 4) Reset to factory defaults 12) ${product} Developer Shell"
|
89
|
echo " 5) Reboot system 13) Upgrade from console"
|
90
|
echo " 6) Halt system ${sshd_option}"
|
91
|
echo " 7) Ping host 15) Restore recent configuration"
|
92
|
echo " 17) Restart PHP-FPM "
|
93
|
echo " ${option98} "
|
94
|
|
95
|
if [ "${option99}" != "" ]; then
|
96
|
/bin/echo "${option99}"
|
97
|
fi
|
98
|
|
99
|
echo
|
100
|
read -p "Enter an option: " opmode
|
101
|
echo
|
102
|
|
103
|
# see what the user has chosen
|
104
|
case ${opmode} in
|
105
|
0)
|
106
|
exit && exit && logout
|
107
|
;;
|
108
|
1)
|
109
|
/etc/rc.initial.setports
|
110
|
;;
|
111
|
2)
|
112
|
/etc/rc.initial.setlanip
|
113
|
;;
|
114
|
3)
|
115
|
/etc/rc.initial.password
|
116
|
;;
|
117
|
4)
|
118
|
/etc/rc.initial.defaults
|
119
|
;;
|
120
|
5)
|
121
|
/etc/rc.initial.reboot
|
122
|
;;
|
123
|
6)
|
124
|
/etc/rc.initial.halt
|
125
|
;;
|
126
|
7)
|
127
|
/etc/rc.initial.ping
|
128
|
;;
|
129
|
8)
|
130
|
/bin/tcsh
|
131
|
;;
|
132
|
9)
|
133
|
/usr/local/sbin/pftop
|
134
|
;;
|
135
|
10)
|
136
|
/usr/sbin/tcpdump -s 256 -v -S -l -n -e -ttt -i pflog0
|
137
|
;;
|
138
|
11 | 111)
|
139
|
/etc/rc.restart_webgui
|
140
|
;;
|
141
|
12)
|
142
|
/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
|
15)
|
151
|
/etc/rc.restore_config_backup
|
152
|
;;
|
153
|
16)
|
154
|
/etc/rc.banner
|
155
|
;;
|
156
|
17)
|
157
|
/etc/rc.php-fpm_restart
|
158
|
;;
|
159
|
98)
|
160
|
if [ ! -f /tmp/config_moved ]; then
|
161
|
/etc/rc.initial.store_config_to_removable_device
|
162
|
fi
|
163
|
;;
|
164
|
99)
|
165
|
if [ -e /dev/ukbd0 ]; then
|
166
|
env TERM=cons25 /scripts/lua_installer
|
167
|
else
|
168
|
/scripts/lua_installer
|
169
|
fi
|
170
|
;;
|
171
|
100)
|
172
|
if grep "$WORD" "$CONFIG"; then
|
173
|
links "https://localhost"
|
174
|
else
|
175
|
links "http://localhost"
|
176
|
fi
|
177
|
;;
|
178
|
"")
|
179
|
kill $PPID ; exit
|
180
|
;;
|
181
|
esac
|
182
|
|
183
|
done
|
184
|
|