Project

General

Profile

Download (3.51 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 a68f7a3d Luiz Otavio O Souza
# Copyright (c) 2014-2024 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 3329e8a1 Chris Buechler
# Parse command line parameters
33
while [ $# -gt 0 ]; do
34
	case $1 in
35 f185e661 luckman212
		-c)
36
			shift
37 0cf9ffc2 Emanuel Rietveld
			/bin/sh -c "$@"
38 3329e8a1 Chris Buechler
			exit
39
			;;
40 f185e661 luckman212
		*) : ;;
41 3329e8a1 Chris Buechler
	esac
42
	shift
43
done
44
45 5b237745 Scott Ullrich
# endless loop
46
while : ; do
47
48 7c961207 Scott Ullrich
if [ -f /tmp/ttybug ]; then
49 f185e661 luckman212
	/bin/rm /tmp/ttybug
50 7c961207 Scott Ullrich
	exit && exit && logout
51
fi
52
53 6a997de8 Scott Ullrich
/etc/rc.banner
54
55 e4121dde Renato Botelho
# Read product_name from $g, defaults to pfSense
56 1f024511 Luiz Otavio O Souza
if [ -f /etc/product_name ]; then
57
	product_name=$(/bin/cat /etc/product_name)
58
else
59
	product_name=$(/usr/local/sbin/read_global_var product_name pfSense)
60
fi
61 19525ae7 Scott Ullrich
62 4061910c Renato Botelho do Couto
# Read product_label from $g, defaults to pfSense
63
if [ -f /etc/product_label ]; then
64
	product_label=$(/bin/cat /etc/product_label)
65
else
66
	product_label=$(/usr/local/sbin/read_global_var product_label pfSense)
67
fi
68
69 61b2ed1c Chris Buechler
# Check to see if SSH is running.
70 f185e661 luckman212
if /bin/pgrep -qaF /var/run/sshd.pid sshd 2>/dev/null; then
71
	sshd_option='Disable'
72 2a5a9c6a Scott Ullrich
else
73 f185e661 luckman212
	sshd_option='Enable'
74 2a5a9c6a Scott Ullrich
fi
75
76 f185e661 luckman212
# display console menu
77 2db9a6d6 Scott Ullrich
echo ""
78 898df056 lriley2020
echo " 0) Logout / Disconnect SSH            9) pfTop"
79 5a42d9ef Renato Botelho
echo " 1) Assign Interfaces                 10) Filter Logs"
80 97c86b9e jim-p
echo " 2) Set interface(s) IP address       11) Restart GUI"
81
echo " 3) Reset admin account and password  12) PHP shell + ${product_label} tools"
82 761768a5 Stephen Beaver
echo " 4) Reset to factory defaults         13) Update from console"
83 f185e661 luckman212
echo " 5) Reboot system                     14) ${sshd_option} Secure Shell (sshd)"
84 5a42d9ef Renato Botelho
echo " 6) Halt system                       15) Restore recent configuration"
85
echo " 7) Ping host                         16) Restart PHP-FPM"
86
echo " 8) Shell"
87 6141561c Scott Ullrich
88 4d0a1ade Scott Ullrich
echo
89 568af189 Colin Smith
read -p "Enter an option: " opmode
90 4df08112 Scott Ullrich
echo
91 5b237745 Scott Ullrich
92
# see what the user has chosen
93
case ${opmode} in
94 debddb24 Scott Ullrich
0)
95 e173dd74 Phil Davis
	exit && exit && logout
96
	;;
97 5b237745 Scott Ullrich
1)
98 e173dd74 Phil Davis
	/etc/rc.initial.setports
99
	;;
100 5b237745 Scott Ullrich
2)
101 e173dd74 Phil Davis
	/etc/rc.initial.setlanip
102
	;;
103 5b237745 Scott Ullrich
3)
104 e173dd74 Phil Davis
	/etc/rc.initial.password
105
	;;
106 5b237745 Scott Ullrich
4)
107 e173dd74 Phil Davis
	/etc/rc.initial.defaults
108
	;;
109 5b237745 Scott Ullrich
5)
110 e173dd74 Phil Davis
	/etc/rc.initial.reboot
111
	;;
112 5b237745 Scott Ullrich
6)
113 e173dd74 Phil Davis
	/etc/rc.initial.halt
114
	;;
115 5b237745 Scott Ullrich
7)
116 e173dd74 Phil Davis
	/etc/rc.initial.ping
117
	;;
118 97a741af Scott Ullrich
8)
119 e173dd74 Phil Davis
	/bin/tcsh
120
	;;
121 97a741af Scott Ullrich
9)
122 e173dd74 Phil Davis
	/usr/local/sbin/pftop
123
	;;
124 97a741af Scott Ullrich
10)
125 f9e8c833 jim-p
	/usr/bin/tail -F /var/log/filter.log
126 e173dd74 Phil Davis
	;;
127 f185e661 luckman212
11)
128 e173dd74 Phil Davis
	/etc/rc.restart_webgui
129
	;;
130 dc7e008c Scott Ullrich
12)
131 e173dd74 Phil Davis
	/usr/local/sbin/pfSsh.php
132
	;;
133
13)
134 573ec19d Renato Botelho do Couto
	/bin/sh /usr/local/sbin/${product_name}-upgrade
135 e173dd74 Phil Davis
	;;
136
14)
137 f185e661 luckman212
	/usr/local/bin/php -f /etc/rc.initial.toggle_sshd
138 e173dd74 Phil Davis
	;;
139 069f9bae Scott Ullrich
15)
140 e173dd74 Phil Davis
	/etc/rc.restore_config_backup
141
	;;
142 133bd2b2 jim-p
16)
143 e173dd74 Phil Davis
	/etc/rc.php-fpm_restart
144
	;;
145 f446f817 Scott Ullrich
100)
146 f185e661 luckman212
	protocol=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/protocol)
147
	port=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/port)
148
	[ -z "$protocol" ] && protocol='http'
149
	if [ -z "$port" ]; then
150
		case $protocol in
151
			https) port=443;;
152
			*)     port=80;;
153
		esac
154 e173dd74 Phil Davis
	fi
155 f185e661 luckman212
	links "${protocol}://localhost:${port}"
156 e173dd74 Phil Davis
	;;
157 f185e661 luckman212
'')
158
	if [ -n "$SSH_CONNECTION" ]; then
159 a99dc521 David Wood
		exit
160
	else
161 f185e661 luckman212
		/bin/kill $PPID ; exit
162 a99dc521 David Wood
	fi
163 e173dd74 Phil Davis
	;;
164 5b237745 Scott Ullrich
esac
165
166 4c7856cf Scott Ullrich
done