Project

General

Profile

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