Project

General

Profile

Download (3.51 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
	else
32
		if [ -f /etc/rc.local.running ]; then
33
			echo ">>> Launching rc.local.running in background..."
34
			sh /etc/rc.local.running &
35
		fi
36
	fi
37
fi
38

    
39
CONFIG="/cf/conf/config.xml"
40
WORD="https"
41

    
42
# Set our operating platform
43
PLATFORM=`cat /etc/platform`
44

    
45
# endless loop
46
while : ; do
47

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

    
53
/etc/rc.banner
54

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

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

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

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

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

    
89
if [ "${option99}" != "" ]; then
90
	/bin/echo "${option99}"
91
fi
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/sbin/tcpdump -n -e -ttt -i pflog0
131
		;;
132
11)
133
		/etc/rc.restart_webgui
134
		;;
135
12)
136
		/usr/local/sbin/pfSsh.php
137
		;;
138
13) 
139
		php -f /etc/rc.initial.firmware_update
140
		;;
141
14) 
142
		php -f /etc/rc.initial.toggle_sshd
143
		;;	
144
15)
145
		/etc/rc.banner
146
		;;
147
98)
148
		if [ ! -f /tmp/config_moved ]; then
149
			/etc/rc.initial.store_config_to_removable_device
150
		fi
151
		;;
152
99)
153
		if [ -e /dev/ukbd0 ]; then
154
	    	env TERM=cons25 /scripts/lua_installer
155
		else
156
			/scripts/lua_installer
157
		fi
158
		;;
159
100)
160
    	if grep "$WORD" "$CONFIG"; then
161
			links "https://localhost"
162
    	else
163
			links "http://localhost"
164
    	fi
165
    	;;
166
"")
167
		kill $PPID ; exit
168
		;;
169
esac
170

    
171
done
172

    
(56-56/102)