Project

General

Profile

Download (3.55 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
# /etc/rc.initial
4
# part of pfSense by Scott Ullrich
5
# Copyright (C) 2004-2011 Scott Ullrich, All rights reserved.
6
# originally based on m0n0wall (http://neon1.net/m0n0wall)
7
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
# All rights reserved.
9

    
10
# make sure the user can't kill us by pressing Ctrl-C,
11
# ctrl-z, etc.
12
#trap : 2
13
#trap : 3
14
#trap : 4
15

    
16
# If recovery console shell option has been specified
17
if [ -f "/tmp/donotbootup" ]; then
18
	/usr/bin/env prompt="%B[%n@%m]%b%/(%h)||RecoveryConsoleShell: " /bin/tcsh
19
	rm "/tmp/donotbootup"
20
	echo "Rebooting in 5 seconds... CTRL-C to abort..."
21
	sleep 5
22
	/etc/rc.reboot
23
	exit
24
fi
25

    
26
if [ -f /etc/rc.local ]; then
27
	RCLOCALPWD=`ps awux | grep rc.local | grep -v grep | awk '{ print $2 }'`
28
	if [ "$RCLOCALPWD" = "" ]; then
29
		echo ">>> Launching rc.local in background..."
30
		sh /etc/rc.local &
31
		sleep 1
32
		sh /etc/rc.local.running &
33
	else
34
		if [ -f /etc/rc.local.running ]; then
35
			echo ">>> Launching rc.local.running in background..."
36
			sh /etc/rc.local.running &
37
		fi
38
	fi
39
fi
40

    
41
CONFIG="/cf/conf/config.xml"
42
WORD="https"
43

    
44
# Set our operating platform
45
PLATFORM=`cat /etc/platform`
46

    
47
# endless loop
48
while : ; do
49

    
50
if [ -f /tmp/ttybug ]; then
51
	rm /tmp/ttybug
52
	exit && exit && logout
53
fi
54

    
55
/etc/rc.banner
56

    
57
product=`grep product_name /etc/inc/globals.inc | cut -d'"' -f4`
58
hidebanner=`grep hidebanner /etc/inc/globals.inc | cut -d'"' -f4`
59

    
60
# Check to see if SSH is listening.
61
SSHD=`/usr/bin/sockstat -4l | grep "*.22" | wc -l`
62
if [ "$SSHD" -gt 0 ]; then
63
	sshd_option="14) Disable Secure Shell (sshd)";
64
else
65
	sshd_option="14) Enable Secure Shell (sshd)";
66
fi
67

    
68
for i in /var/db/pfi/capable_*; do
69
    if [ -f $i -a ! -L /cf/conf ]; then
70
	option98="98) Move configuration file to removable device"
71
	break
72
    fi
73
done
74

    
75
if [ "$PLATFORM" = "cdrom" ]; then
76
    option99="99) Install ${product} to a hard drive, etc."
77
fi
78

    
79
# display a cheap menu
80
echo ""
81
echo ""
82
echo " 0) Logout (SSH only)                  8) Shell"
83
echo " 1) Assign Interfaces                  9) pfTop"
84
echo " 2) Set interface(s) IP address       10) Filter Logs"
85
echo " 3) Reset webConfigurator password    11) Restart webConfigurator"
86
echo " 4) Reset to factory defaults         12) ${product} Developer Shell"
87
echo " 5) Reboot system                     13) Upgrade from console"
88
echo " 6) Halt system                       ${sshd_option}"
89
echo " 7) Ping host                         ${option98}"
90

    
91
if [ "${option99}" != "" ]; then
92
	/bin/echo "${option99}"
93
fi
94

    
95
echo
96
read -p "Enter an option: " opmode
97
echo
98

    
99
# see what the user has chosen
100
case ${opmode} in
101
0)
102
        exit && exit && logout
103
        ;;
104
1)
105
        /etc/rc.initial.setports
106
        ;;
107
2)
108
        /etc/rc.initial.setlanip
109
        ;;
110
3)
111
        /etc/rc.initial.password
112
        ;;
113
4)
114
        /etc/rc.initial.defaults
115
        ;;
116
5)
117
        /etc/rc.initial.reboot
118
        ;;
119
6)
120
        /etc/rc.initial.halt
121
        ;;
122
7)
123
        /etc/rc.initial.ping
124
        ;;
125
8)
126
        /bin/tcsh
127
        ;;
128
9)
129
        /usr/local/sbin/pftop
130
        ;;
131
10)
132
		/usr/sbin/tcpdump -n -e -ttt -i pflog0
133
		;;
134
11)
135
		/etc/rc.restart_webgui
136
		;;
137
12)
138
		/usr/local/sbin/pfSsh.php
139
		;;
140
13) 
141
		php -f /etc/rc.initial.firmware_update
142
		;;
143
14) 
144
		php -f /etc/rc.initial.toggle_sshd
145
		;;	
146
15)
147
		/etc/rc.banner
148
		;;
149
98)
150
		if [ ! -f /tmp/config_moved ]; then
151
			/etc/rc.initial.store_config_to_removable_device
152
		fi
153
		;;
154
99)
155
		if [ -e /dev/ukbd0 ]; then
156
	    	env TERM=cons25 /scripts/lua_installer
157
		else
158
			/scripts/lua_installer
159
		fi
160
		;;
161
100)
162
    	if grep "$WORD" "$CONFIG"; then
163
			links "https://localhost"
164
    	else
165
			links "http://localhost"
166
    	fi
167
    	;;
168
"")
169
		kill $PPID ; exit
170
		;;
171
esac
172

    
173
done
174

    
(56-56/102)