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 |
2db9a6d6
|
Scott Ullrich
|
# Check to see if SSH is listening.
|
65 |
f73be85c
|
Ermal
|
SSHD=`/usr/bin/sockstat -4l | grep "*.22" | wc -l`
|
66 |
2a5a9c6a
|
Scott Ullrich
|
if [ "$SSHD" -gt 0 ]; then
|
67 |
2db9a6d6
|
Scott Ullrich
|
sshd_option="14) Disable Secure Shell (sshd)";
|
68 |
2a5a9c6a
|
Scott Ullrich
|
else
|
69 |
2db9a6d6
|
Scott Ullrich
|
sshd_option="14) Enable Secure Shell (sshd)";
|
70 |
2a5a9c6a
|
Scott Ullrich
|
fi
|
71 |
|
|
|
72 |
f321b3a2
|
Scott Ullrich
|
for i in /var/db/pfi/capable_*; do
|
73 |
|
|
if [ -f $i -a ! -L /cf/conf ]; then
|
74 |
2db9a6d6
|
Scott Ullrich
|
option98="98) Move configuration file to removable device"
|
75 |
f321b3a2
|
Scott Ullrich
|
break
|
76 |
4d28b3ec
|
Scott Ullrich
|
fi
|
77 |
f321b3a2
|
Scott Ullrich
|
done
|
78 |
2730fde3
|
Scott Ullrich
|
|
79 |
|
|
if [ "$PLATFORM" = "cdrom" ]; then
|
80 |
ec3e48f1
|
jim-p
|
option99="99) Install ${product} to a hard drive, etc."
|
81 |
2730fde3
|
Scott Ullrich
|
fi
|
82 |
5b237745
|
Scott Ullrich
|
|
83 |
2db9a6d6
|
Scott Ullrich
|
# display a cheap menu
|
84 |
|
|
echo ""
|
85 |
|
|
echo ""
|
86 |
|
|
echo " 0) Logout (SSH only) 8) Shell"
|
87 |
|
|
echo " 1) Assign Interfaces 9) pfTop"
|
88 |
|
|
echo " 2) Set interface(s) IP address 10) Filter Logs"
|
89 |
|
|
echo " 3) Reset webConfigurator password 11) Restart webConfigurator"
|
90 |
|
|
echo " 4) Reset to factory defaults 12) ${product} Developer Shell"
|
91 |
|
|
echo " 5) Reboot system 13) Upgrade from console"
|
92 |
|
|
echo " 6) Halt system ${sshd_option}"
|
93 |
133bd2b2
|
jim-p
|
echo " 7) Ping host 15) Restore recent configuration"
|
94 |
|
|
echo " ${option98}"
|
95 |
6141561c
|
Scott Ullrich
|
|
96 |
|
|
if [ "${option99}" != "" ]; then
|
97 |
|
|
/bin/echo "${option99}"
|
98 |
|
|
fi
|
99 |
2db9a6d6
|
Scott Ullrich
|
|
100 |
4d0a1ade
|
Scott Ullrich
|
echo
|
101 |
568af189
|
Colin Smith
|
read -p "Enter an option: " opmode
|
102 |
4df08112
|
Scott Ullrich
|
echo
|
103 |
5b237745
|
Scott Ullrich
|
|
104 |
|
|
# see what the user has chosen
|
105 |
|
|
case ${opmode} in
|
106 |
debddb24
|
Scott Ullrich
|
0)
|
107 |
c900e2dc
|
Scott Ullrich
|
exit && exit && logout
|
108 |
|
|
;;
|
109 |
5b237745
|
Scott Ullrich
|
1)
|
110 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.setports
|
111 |
|
|
;;
|
112 |
5b237745
|
Scott Ullrich
|
2)
|
113 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.setlanip
|
114 |
|
|
;;
|
115 |
5b237745
|
Scott Ullrich
|
3)
|
116 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.password
|
117 |
|
|
;;
|
118 |
5b237745
|
Scott Ullrich
|
4)
|
119 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.defaults
|
120 |
|
|
;;
|
121 |
5b237745
|
Scott Ullrich
|
5)
|
122 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.reboot
|
123 |
|
|
;;
|
124 |
5b237745
|
Scott Ullrich
|
6)
|
125 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.halt
|
126 |
|
|
;;
|
127 |
5b237745
|
Scott Ullrich
|
7)
|
128 |
c900e2dc
|
Scott Ullrich
|
/etc/rc.initial.ping
|
129 |
|
|
;;
|
130 |
97a741af
|
Scott Ullrich
|
8)
|
131 |
9607c2a4
|
Scott Ullrich
|
/bin/tcsh
|
132 |
c900e2dc
|
Scott Ullrich
|
;;
|
133 |
97a741af
|
Scott Ullrich
|
9)
|
134 |
c900e2dc
|
Scott Ullrich
|
/usr/local/sbin/pftop
|
135 |
|
|
;;
|
136 |
97a741af
|
Scott Ullrich
|
10)
|
137 |
33a33c3e
|
jim-p
|
/usr/sbin/tcpdump -s 256 -v -S -l -n -e -ttt -i pflog0
|
138 |
916c5001
|
Scott Ullrich
|
;;
|
139 |
e6702447
|
jim-p
|
11 | 111)
|
140 |
6c6f9253
|
jim-p
|
/usr/bin/killall -9 php; /usr/bin/killall -9 lighttpd; /etc/rc.restart_webgui
|
141 |
|
|
;;
|
142 |
dc7e008c
|
Scott Ullrich
|
12)
|
143 |
916c5001
|
Scott Ullrich
|
/usr/local/sbin/pfSsh.php
|
144 |
|
|
;;
|
145 |
f4feb493
|
Scott Ullrich
|
13)
|
146 |
916c5001
|
Scott Ullrich
|
php -f /etc/rc.initial.firmware_update
|
147 |
|
|
;;
|
148 |
069f9bae
|
Scott Ullrich
|
14)
|
149 |
|
|
php -f /etc/rc.initial.toggle_sshd
|
150 |
|
|
;;
|
151 |
|
|
15)
|
152 |
133bd2b2
|
jim-p
|
/etc/rc.restore_config_backup
|
153 |
|
|
;;
|
154 |
|
|
16)
|
155 |
916c5001
|
Scott Ullrich
|
/etc/rc.banner
|
156 |
|
|
;;
|
157 |
9eb7a7b4
|
Scott Ullrich
|
98)
|
158 |
916c5001
|
Scott Ullrich
|
if [ ! -f /tmp/config_moved ]; then
|
159 |
|
|
/etc/rc.initial.store_config_to_removable_device
|
160 |
|
|
fi
|
161 |
|
|
;;
|
162 |
c26023b4
|
Scott Ullrich
|
99)
|
163 |
916c5001
|
Scott Ullrich
|
if [ -e /dev/ukbd0 ]; then
|
164 |
|
|
env TERM=cons25 /scripts/lua_installer
|
165 |
|
|
else
|
166 |
|
|
/scripts/lua_installer
|
167 |
|
|
fi
|
168 |
|
|
;;
|
169 |
f446f817
|
Scott Ullrich
|
100)
|
170 |
916c5001
|
Scott Ullrich
|
if grep "$WORD" "$CONFIG"; then
|
171 |
|
|
links "https://localhost"
|
172 |
|
|
else
|
173 |
|
|
links "http://localhost"
|
174 |
|
|
fi
|
175 |
|
|
;;
|
176 |
d8d46c26
|
Scott Ullrich
|
"")
|
177 |
651e77c6
|
jim-p
|
kill $PPID ; exit
|
178 |
916c5001
|
Scott Ullrich
|
;;
|
179 |
5b237745
|
Scott Ullrich
|
esac
|
180 |
|
|
|
181 |
4c7856cf
|
Scott Ullrich
|
done
|