Project

General

Profile

Download (3.3 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# rc.initial
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2004-2013 BSD Perimeter
7
# Copyright (c) 2013-2016 Electric Sheep Fencing
8
# Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9
# All rights reserved.
10
#
11
# originally based on m0n0wall (http://neon1.net/m0n0wall)
12
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
# All rights reserved.
14
#
15
# 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
#
19
# http://www.apache.org/licenses/LICENSE-2.0
20
#
21
# 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

    
27
# 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

    
32
# Parse command line parameters
33
while [ $# -gt 0 ]; do
34
	case $1 in
35
		-c)
36
			shift
37
			/bin/sh -c "$@"
38
			exit
39
			;;
40
		*) : ;;
41
	esac
42
	shift
43
done
44

    
45
# endless loop
46
while : ; do
47

    
48
if [ -f /tmp/ttybug ]; then
49
	/bin/rm /tmp/ttybug
50
	exit && exit && logout
51
fi
52

    
53
/etc/rc.banner
54

    
55
# Read product_name from $g, defaults to pfSense
56
product_name=$(/usr/local/sbin/read_global_var product_name pfSense)
57
product_label=$(/usr/local/sbin/read_global_var product_label pfSense)
58

    
59
# Check to see if SSH is running.
60
if /bin/pgrep -qaF /var/run/sshd.pid sshd 2>/dev/null; then
61
	sshd_option='Disable'
62
else
63
	sshd_option='Enable'
64
fi
65

    
66
# display console menu
67
echo ""
68
echo " 0) Logout (SSH only)                  9) pfTop"
69
echo " 1) Assign Interfaces                 10) Filter Logs"
70
echo " 2) Set interface(s) IP address       11) Restart webConfigurator"
71
echo " 3) Reset webConfigurator password    12) PHP shell + ${product_label} tools"
72
echo " 4) Reset to factory defaults         13) Update from console"
73
echo " 5) Reboot system                     14) ${sshd_option} Secure Shell (sshd)"
74
echo " 6) Halt system                       15) Restore recent configuration"
75
echo " 7) Ping host                         16) Restart PHP-FPM"
76
echo " 8) Shell"
77

    
78
echo
79
read -p "Enter an option: " opmode
80
echo
81

    
82
# see what the user has chosen
83
case ${opmode} in
84
0)
85
	exit && exit && logout
86
	;;
87
1)
88
	/etc/rc.initial.setports
89
	;;
90
2)
91
	/etc/rc.initial.setlanip
92
	;;
93
3)
94
	/etc/rc.initial.password
95
	;;
96
4)
97
	/etc/rc.initial.defaults
98
	;;
99
5)
100
	/etc/rc.initial.reboot
101
	;;
102
6)
103
	/etc/rc.initial.halt
104
	;;
105
7)
106
	/etc/rc.initial.ping
107
	;;
108
8)
109
	/bin/tcsh
110
	;;
111
9)
112
	/usr/local/sbin/pftop
113
	;;
114
10)
115
	/usr/bin/tail -F /var/log/filter.log
116
	;;
117
11)
118
	/etc/rc.restart_webgui
119
	;;
120
12)
121
	/usr/local/sbin/pfSsh.php
122
	;;
123
13)
124
	/bin/sh /usr/local/sbin/${product_name}-upgrade
125
	;;
126
14)
127
	/usr/local/bin/php -f /etc/rc.initial.toggle_sshd
128
	;;
129
15)
130
	/etc/rc.restore_config_backup
131
	;;
132
16)
133
	/etc/rc.php-fpm_restart
134
	;;
135
100)
136
	protocol=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/protocol)
137
	port=$(/usr/local/sbin/read_xml_tag.sh string system/webgui/port)
138
	[ -z "$protocol" ] && protocol='http'
139
	if [ -z "$port" ]; then
140
		case $protocol in
141
			https) port=443;;
142
			*)     port=80;;
143
		esac
144
	fi
145
	links "${protocol}://localhost:${port}"
146
	;;
147
'')
148
	if [ -n "$SSH_CONNECTION" ]; then
149
		exit
150
	else
151
		/bin/kill $PPID ; exit
152
	fi
153
	;;
154
esac
155

    
156
done
(39-39/85)