Project

General

Profile

Download (3.39 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/bin/sh
2 ac24dc24 Renato Botelho
#
3
# rc.initial
4
#
5
# part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
# Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 ac24dc24 Renato Botelho
# All rights reserved.
8
#
9 e5cd29a0 Scott Ullrich
# originally based on m0n0wall (http://neon1.net/m0n0wall)
10 c5d81585 Renato Botelho
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11 5b237745 Scott Ullrich
# All rights reserved.
12 ac24dc24 Renato Botelho
#
13 b12ea3fb Renato Botelho
# Licensed under the Apache License, Version 2.0 (the "License");
14
# you may not use this file except in compliance with the License.
15
# You may obtain a copy of the License at
16 ac24dc24 Renato Botelho
#
17 b12ea3fb Renato Botelho
# http://www.apache.org/licenses/LICENSE-2.0
18 ac24dc24 Renato Botelho
#
19 b12ea3fb Renato Botelho
# Unless required by applicable law or agreed to in writing, software
20
# distributed under the License is distributed on an "AS IS" BASIS,
21
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
# See the License for the specific language governing permissions and
23
# limitations under the License.
24 89c5f759 Scott Ullrich
25 cd80a0a8 Scott Ullrich
# make sure the user can't kill us by pressing Ctrl-C,
26
# ctrl-z, etc.
27 533f3160 Renato Botelho
trap : 2
28
trap : 3
29
trap : 4
30 5b237745 Scott Ullrich
31 9c98ee85 Scott Ullrich
if [ -f /etc/rc.local ]; then
32 a32c7a23 Scott Ullrich
	RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
33 5f8e5e14 Scott Ullrich
	if [ "$RCLOCALPWD" = "" ]; then
34
		echo ">>> Launching rc.local in background..."
35
		sh /etc/rc.local &
36 c3ebb669 Scott Ullrich
		sleep 1
37
		sh /etc/rc.local.running &
38 32cd7c36 Scott Ullrich
	else
39
		if [ -f /etc/rc.local.running ]; then
40
			echo ">>> Launching rc.local.running in background..."
41
			sh /etc/rc.local.running &
42
		fi
43 5f8e5e14 Scott Ullrich
	fi
44 9c98ee85 Scott Ullrich
fi
45
46 3329e8a1 Chris Buechler
# Parse command line parameters
47
while [ $# -gt 0 ]; do
48
	case $1 in
49
		-c )	shift
50
			/bin/sh -c $1
51
			exit
52
			;;
53
		* )
54
	esac
55
	shift
56
done
57
58 89c5f759 Scott Ullrich
CONFIG="/cf/conf/config.xml"
59
WORD="https"
60
61 5b237745 Scott Ullrich
# endless loop
62
while : ; do
63
64 7c961207 Scott Ullrich
if [ -f /tmp/ttybug ]; then
65
	rm /tmp/ttybug
66
	exit && exit && logout
67
fi
68
69 6a997de8 Scott Ullrich
/etc/rc.banner
70
71 e4121dde Renato Botelho
# Read product_name from $g, defaults to pfSense
72
product=$(/usr/local/sbin/read_global_var product_name pfSense)
73 19525ae7 Scott Ullrich
74 61b2ed1c Chris Buechler
# Check to see if SSH is running.
75 8c366060 Renato Botelho
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
76 2db9a6d6 Scott Ullrich
	sshd_option="14) Disable Secure Shell (sshd)";
77 2a5a9c6a Scott Ullrich
else
78 2db9a6d6 Scott Ullrich
	sshd_option="14) Enable Secure Shell (sshd)";
79 2a5a9c6a Scott Ullrich
fi
80
81 2db9a6d6 Scott Ullrich
# display a cheap menu
82
echo ""
83 5a42d9ef Renato Botelho
echo " 0) Logout (SSH only)                  9) pfTop"
84
echo " 1) Assign Interfaces                 10) Filter Logs"
85
echo " 2) Set interface(s) IP address       11) Restart webConfigurator"
86 02705019 stilez
echo " 3) Reset webConfigurator password    12) PHP shell + ${product} tools"
87 761768a5 Stephen Beaver
echo " 4) Reset to factory defaults         13) Update from console"
88 5a42d9ef Renato Botelho
echo " 5) Reboot system                     ${sshd_option}"
89
echo " 6) Halt system                       15) Restore recent configuration"
90
echo " 7) Ping host                         16) Restart PHP-FPM"
91
echo " 8) Shell"
92 6141561c Scott Ullrich
93 4d0a1ade Scott Ullrich
echo
94 568af189 Colin Smith
read -p "Enter an option: " opmode
95 4df08112 Scott Ullrich
echo
96 5b237745 Scott Ullrich
97
# see what the user has chosen
98
case ${opmode} in
99 debddb24 Scott Ullrich
0)
100 e173dd74 Phil Davis
	exit && exit && logout
101
	;;
102 5b237745 Scott Ullrich
1)
103 e173dd74 Phil Davis
	/etc/rc.initial.setports
104
	;;
105 5b237745 Scott Ullrich
2)
106 e173dd74 Phil Davis
	/etc/rc.initial.setlanip
107
	;;
108 5b237745 Scott Ullrich
3)
109 e173dd74 Phil Davis
	/etc/rc.initial.password
110
	;;
111 5b237745 Scott Ullrich
4)
112 e173dd74 Phil Davis
	/etc/rc.initial.defaults
113
	;;
114 5b237745 Scott Ullrich
5)
115 e173dd74 Phil Davis
	/etc/rc.initial.reboot
116
	;;
117 5b237745 Scott Ullrich
6)
118 e173dd74 Phil Davis
	/etc/rc.initial.halt
119
	;;
120 5b237745 Scott Ullrich
7)
121 e173dd74 Phil Davis
	/etc/rc.initial.ping
122
	;;
123 97a741af Scott Ullrich
8)
124 e173dd74 Phil Davis
	/bin/tcsh
125
	;;
126 97a741af Scott Ullrich
9)
127 e173dd74 Phil Davis
	/usr/local/sbin/pftop
128
	;;
129 97a741af Scott Ullrich
10)
130 e173dd74 Phil Davis
	/usr/local/sbin/clog -f /var/log/filter.log
131
	;;
132 e6702447 jim-p
11 | 111)
133 e173dd74 Phil Davis
	/etc/rc.restart_webgui
134
	;;
135 dc7e008c Scott Ullrich
12)
136 e173dd74 Phil Davis
	/usr/local/sbin/pfSsh.php
137
	;;
138
13)
139 c580e34c Renato Botelho
	/bin/sh /usr/local/sbin/${product}-upgrade
140 e173dd74 Phil Davis
	;;
141
14)
142
	php -f /etc/rc.initial.toggle_sshd
143
	;;
144 069f9bae Scott Ullrich
15)
145 e173dd74 Phil Davis
	/etc/rc.restore_config_backup
146
	;;
147 133bd2b2 jim-p
16)
148 e173dd74 Phil Davis
	/etc/rc.php-fpm_restart
149
	;;
150 f446f817 Scott Ullrich
100)
151 e173dd74 Phil Davis
	if grep "$WORD" "$CONFIG"; then
152
		links "https://localhost"
153
	else
154
		links "http://localhost"
155
	fi
156
	;;
157 d8d46c26 Scott Ullrich
"")
158 a99dc521 David Wood
	ps -o command='' -c -p $PPID | grep -E '^sshd$' > /dev/null
159
	if [ $? -eq 0 ]; then
160
		exit
161
	else
162
		kill $PPID ; exit
163
	fi
164 e173dd74 Phil Davis
	;;
165 5b237745 Scott Ullrich
esac
166
167 4c7856cf Scott Ullrich
done