Project

General

Profile

Download (3.68 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 38809d47 Renato Botelho do Couto
# Copyright (c) 2004-2013 BSD Perimeter
7
# Copyright (c) 2013-2016 Electric Sheep Fencing
8 402c98a2 Reid Linnemann
# Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9 ac24dc24 Renato Botelho
# All rights reserved.
10
#
11 e5cd29a0 Scott Ullrich
# originally based on m0n0wall (http://neon1.net/m0n0wall)
12 c5d81585 Renato Botelho
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13 5b237745 Scott Ullrich
# All rights reserved.
14 ac24dc24 Renato Botelho
#
15 b12ea3fb Renato Botelho
# Licensed under the Apache License, Version 2.0 (the "License");
16
# you may not use this file except in compliance with the License.
17
# You may obtain a copy of the License at
18 ac24dc24 Renato Botelho
#
19 b12ea3fb Renato Botelho
# http://www.apache.org/licenses/LICENSE-2.0
20 ac24dc24 Renato Botelho
#
21 b12ea3fb Renato Botelho
# Unless required by applicable law or agreed to in writing, software
22
# distributed under the License is distributed on an "AS IS" BASIS,
23
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
# See the License for the specific language governing permissions and
25
# limitations under the License.
26 89c5f759 Scott Ullrich
27 f185e661 luckman212
# make sure the user can't kill us by pressing Ctrl-C, ctrl-z, etc.
28
trap : INT
29
trap : QUIT
30
trap : ILL
31 5b237745 Scott Ullrich
32 449fdf25 Renato Botelho do Couto
unset do_sleep
33 9c98ee85 Scott Ullrich
if [ -f /etc/rc.local ]; then
34 f185e661 luckman212
	if ! /bin/pgrep -qf 'rc.local$'; then
35 5f8e5e14 Scott Ullrich
		echo ">>> Launching rc.local in background..."
36 f185e661 luckman212
		/bin/sh /etc/rc.local &
37 449fdf25 Renato Botelho do Couto
		do_sleep=1
38
	fi
39 f185e661 luckman212
	if [ -f /etc/rc.local.running ] &&
40
	! /bin/pgrep -qf 'rc.local.running$'; then
41 449fdf25 Renato Botelho do Couto
		[ -n "${do_sleep}" ] && sleep 1
42
		echo ">>> Launching rc.local.running in background..."
43 f185e661 luckman212
		/bin/sh /etc/rc.local.running &
44 5f8e5e14 Scott Ullrich
	fi
45 9c98ee85 Scott Ullrich
fi
46
47 3329e8a1 Chris Buechler
# Parse command line parameters
48
while [ $# -gt 0 ]; do
49
	case $1 in
50 f185e661 luckman212
		-c)
51
			shift
52 0cf9ffc2 Emanuel Rietveld
			/bin/sh -c "$@"
53 3329e8a1 Chris Buechler
			exit
54
			;;
55 f185e661 luckman212
		*) : ;;
56 3329e8a1 Chris Buechler
	esac
57
	shift
58
done
59
60 5b237745 Scott Ullrich
# endless loop
61
while : ; do
62
63 7c961207 Scott Ullrich
if [ -f /tmp/ttybug ]; then
64 f185e661 luckman212
	/bin/rm /tmp/ttybug
65 7c961207 Scott Ullrich
	exit && exit && logout
66
fi
67
68 6a997de8 Scott Ullrich
/etc/rc.banner
69
70 e4121dde Renato Botelho
# Read product_name from $g, defaults to pfSense
71 573ec19d Renato Botelho do Couto
product_name=$(/usr/local/sbin/read_global_var product_name pfSense)
72
product_label=$(/usr/local/sbin/read_global_var product_label pfSense)
73 19525ae7 Scott Ullrich
74 61b2ed1c Chris Buechler
# Check to see if SSH is running.
75 f185e661 luckman212
if /bin/pgrep -qaF /var/run/sshd.pid sshd 2>/dev/null; then
76
	sshd_option='Disable'
77 2a5a9c6a Scott Ullrich
else
78 f185e661 luckman212
	sshd_option='Enable'
79 2a5a9c6a Scott Ullrich
fi
80
81 f185e661 luckman212
# display console menu
82 2db9a6d6 Scott Ullrich
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 573ec19d Renato Botelho do Couto
echo " 3) Reset webConfigurator password    12) PHP shell + ${product_label} tools"
87 761768a5 Stephen Beaver
echo " 4) Reset to factory defaults         13) Update from console"
88 f185e661 luckman212
echo " 5) Reboot system                     14) ${sshd_option} Secure Shell (sshd)"
89 5a42d9ef Renato Botelho
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 f9e8c833 jim-p
	/usr/bin/tail -F /var/log/filter.log
131 e173dd74 Phil Davis
	;;
132 f185e661 luckman212
11)
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 573ec19d Renato Botelho do Couto
	/bin/sh /usr/local/sbin/${product_name}-upgrade
140 e173dd74 Phil Davis
	;;
141
14)
142 f185e661 luckman212
	/usr/local/bin/php -f /etc/rc.initial.toggle_sshd
143 e173dd74 Phil Davis
	;;
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 f185e661 luckman212
	protocol=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/protocol)
152
	port=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/port)
153
	[ -z "$protocol" ] && protocol='http'
154
	if [ -z "$port" ]; then
155
		case $protocol in
156
			https) port=443;;
157
			*)     port=80;;
158
		esac
159 e173dd74 Phil Davis
	fi
160 f185e661 luckman212
	links "${protocol}://localhost:${port}"
161 e173dd74 Phil Davis
	;;
162 f185e661 luckman212
'')
163
	if [ -n "$SSH_CONNECTION" ]; then
164 a99dc521 David Wood
		exit
165
	else
166 f185e661 luckman212
		/bin/kill $PPID ; exit
167 a99dc521 David Wood
	fi
168 e173dd74 Phil Davis
	;;
169 5b237745 Scott Ullrich
esac
170
171 4c7856cf Scott Ullrich
done