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 [ -f /etc/rc.local ]; then
|
17
|
RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
|
18
|
if [ "$RCLOCALPWD" = "" ]; then
|
19
|
echo ">>> Launching rc.local in background..."
|
20
|
sh /etc/rc.local &
|
21
|
sleep 1
|
22
|
sh /etc/rc.local.running &
|
23
|
else
|
24
|
if [ -f /etc/rc.local.running ]; then
|
25
|
echo ">>> Launching rc.local.running in background..."
|
26
|
sh /etc/rc.local.running &
|
27
|
fi
|
28
|
fi
|
29
|
fi
|
30
|
|
31
|
# Parse command line parameters
|
32
|
while [ $# -gt 0 ]; do
|
33
|
case $1 in
|
34
|
-c ) shift
|
35
|
/bin/sh -c $1
|
36
|
exit
|
37
|
;;
|
38
|
* )
|
39
|
esac
|
40
|
shift
|
41
|
done
|
42
|
|
43
|
CONFIG="/cf/conf/config.xml"
|
44
|
WORD="https"
|
45
|
|
46
|
# Set our operating platform
|
47
|
PLATFORM=`cat /etc/platform`
|
48
|
|
49
|
# endless loop
|
50
|
while : ; do
|
51
|
|
52
|
if [ -f /tmp/ttybug ]; then
|
53
|
rm /tmp/ttybug
|
54
|
exit && exit && logout
|
55
|
fi
|
56
|
|
57
|
/etc/rc.banner
|
58
|
|
59
|
# Read product_name from $g, defaults to pfSense
|
60
|
product=$(/usr/local/sbin/read_global_var product_name pfSense)
|
61
|
|
62
|
# Check to see if SSH is running.
|
63
|
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
|
64
|
sshd_option="14) Disable Secure Shell (sshd)";
|
65
|
else
|
66
|
sshd_option="14) Enable Secure Shell (sshd)";
|
67
|
fi
|
68
|
|
69
|
for i in /var/db/pfi/capable_*; do
|
70
|
if [ -f $i -a ! -L /cf/conf ]; then
|
71
|
option98="98) Move configuration file to removable device"
|
72
|
break
|
73
|
fi
|
74
|
done
|
75
|
|
76
|
if [ "$PLATFORM" = "cdrom" ]; then
|
77
|
option99="99) Install ${product} to a hard drive, etc."
|
78
|
fi
|
79
|
|
80
|
# display a cheap menu
|
81
|
echo ""
|
82
|
echo " 0) Logout (SSH only) 9) pfTop"
|
83
|
echo " 1) Assign Interfaces 10) Filter Logs"
|
84
|
echo " 2) Set interface(s) IP address 11) Restart webConfigurator"
|
85
|
echo " 3) Reset webConfigurator password 12) ${product} Developer Shell"
|
86
|
echo " 4) Reset to factory defaults 13) Update from console"
|
87
|
echo " 5) Reboot system ${sshd_option}"
|
88
|
echo " 6) Halt system 15) Restore recent configuration"
|
89
|
echo " 7) Ping host 16) Restart PHP-FPM"
|
90
|
echo " 8) Shell"
|
91
|
echo " ${option98} "
|
92
|
|
93
|
if [ "${option99}" != "" ]; then
|
94
|
/bin/echo "${option99}"
|
95
|
fi
|
96
|
|
97
|
echo
|
98
|
read -p "Enter an option: " opmode
|
99
|
echo
|
100
|
|
101
|
# see what the user has chosen
|
102
|
case ${opmode} in
|
103
|
0)
|
104
|
exit && exit && logout
|
105
|
;;
|
106
|
1)
|
107
|
/etc/rc.initial.setports
|
108
|
;;
|
109
|
2)
|
110
|
/etc/rc.initial.setlanip
|
111
|
;;
|
112
|
3)
|
113
|
/etc/rc.initial.password
|
114
|
;;
|
115
|
4)
|
116
|
/etc/rc.initial.defaults
|
117
|
;;
|
118
|
5)
|
119
|
/etc/rc.initial.reboot
|
120
|
;;
|
121
|
6)
|
122
|
/etc/rc.initial.halt
|
123
|
;;
|
124
|
7)
|
125
|
/etc/rc.initial.ping
|
126
|
;;
|
127
|
8)
|
128
|
/bin/tcsh
|
129
|
;;
|
130
|
9)
|
131
|
/usr/local/sbin/pftop
|
132
|
;;
|
133
|
10)
|
134
|
/usr/local/sbin/clog -f /var/log/filter.log
|
135
|
;;
|
136
|
11 | 111)
|
137
|
/etc/rc.restart_webgui
|
138
|
;;
|
139
|
12)
|
140
|
/usr/local/sbin/pfSsh.php
|
141
|
;;
|
142
|
13)
|
143
|
/bin/sh /usr/local/sbin/${product}-upgrade
|
144
|
;;
|
145
|
14)
|
146
|
php -f /etc/rc.initial.toggle_sshd
|
147
|
;;
|
148
|
15)
|
149
|
/etc/rc.restore_config_backup
|
150
|
;;
|
151
|
16)
|
152
|
/etc/rc.php-fpm_restart
|
153
|
;;
|
154
|
98)
|
155
|
if [ ! -f /tmp/config_moved ]; then
|
156
|
/etc/rc.initial.store_config_to_removable_device
|
157
|
fi
|
158
|
;;
|
159
|
99)
|
160
|
if [ -e /dev/ukbd0 ]; then
|
161
|
env TERM=cons25 /scripts/lua_installer
|
162
|
else
|
163
|
/scripts/lua_installer
|
164
|
fi
|
165
|
;;
|
166
|
100)
|
167
|
if grep "$WORD" "$CONFIG"; then
|
168
|
links "https://localhost"
|
169
|
else
|
170
|
links "http://localhost"
|
171
|
fi
|
172
|
;;
|
173
|
"")
|
174
|
kill $PPID ; exit
|
175
|
;;
|
176
|
esac
|
177
|
|
178
|
done
|
179
|
|