Project

General

Profile

Download (3.39 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-2016 Rubicon Communications, LLC (Netgate)
7
# All rights reserved.
8
#
9
# originally based on m0n0wall (http://neon1.net/m0n0wall)
10
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
# All rights reserved.
12
#
13
# 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
#
17
# http://www.apache.org/licenses/LICENSE-2.0
18
#
19
# 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

    
25
# make sure the user can't kill us by pressing Ctrl-C,
26
# ctrl-z, etc.
27
trap : 2
28
trap : 3
29
trap : 4
30

    
31
if [ -f /etc/rc.local ]; then
32
	RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
33
	if [ "$RCLOCALPWD" = "" ]; then
34
		echo ">>> Launching rc.local in background..."
35
		sh /etc/rc.local &
36
		sleep 1
37
		sh /etc/rc.local.running &
38
	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
	fi
44
fi
45

    
46
# 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
CONFIG="/cf/conf/config.xml"
59
WORD="https"
60

    
61
# endless loop
62
while : ; do
63

    
64
if [ -f /tmp/ttybug ]; then
65
	rm /tmp/ttybug
66
	exit && exit && logout
67
fi
68

    
69
/etc/rc.banner
70

    
71
# Read product_name from $g, defaults to pfSense
72
product=$(/usr/local/sbin/read_global_var product_name pfSense)
73

    
74
# Check to see if SSH is running.
75
if pgrep -q -a -F /var/run/sshd.pid sshd >/dev/null 2>&1; then
76
	sshd_option="14) Disable Secure Shell (sshd)";
77
else
78
	sshd_option="14) Enable Secure Shell (sshd)";
79
fi
80

    
81
# display a cheap menu
82
echo ""
83
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
echo " 3) Reset webConfigurator password    12) PHP shell + ${product} tools"
87
echo " 4) Reset to factory defaults         13) Update from console"
88
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

    
93
echo
94
read -p "Enter an option: " opmode
95
echo
96

    
97
# see what the user has chosen
98
case ${opmode} in
99
0)
100
	exit && exit && logout
101
	;;
102
1)
103
	/etc/rc.initial.setports
104
	;;
105
2)
106
	/etc/rc.initial.setlanip
107
	;;
108
3)
109
	/etc/rc.initial.password
110
	;;
111
4)
112
	/etc/rc.initial.defaults
113
	;;
114
5)
115
	/etc/rc.initial.reboot
116
	;;
117
6)
118
	/etc/rc.initial.halt
119
	;;
120
7)
121
	/etc/rc.initial.ping
122
	;;
123
8)
124
	/bin/tcsh
125
	;;
126
9)
127
	/usr/local/sbin/pftop
128
	;;
129
10)
130
	/usr/local/sbin/clog -f /var/log/filter.log
131
	;;
132
11 | 111)
133
	/etc/rc.restart_webgui
134
	;;
135
12)
136
	/usr/local/sbin/pfSsh.php
137
	;;
138
13)
139
	/bin/sh /usr/local/sbin/${product}-upgrade
140
	;;
141
14)
142
	php -f /etc/rc.initial.toggle_sshd
143
	;;
144
15)
145
	/etc/rc.restore_config_backup
146
	;;
147
16)
148
	/etc/rc.php-fpm_restart
149
	;;
150
100)
151
	if grep "$WORD" "$CONFIG"; then
152
		links "https://localhost"
153
	else
154
		links "http://localhost"
155
	fi
156
	;;
157
"")
158
	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
	;;
165
esac
166

    
167
done
168

    
(37-37/79)