Project

General

Profile

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

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

    
11
product=`cat /etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
12

    
13

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

    
24
if [ -e /usr/local/etc/rc.d/dev_bootstrap.sh ]; then
25
	echo
26
	echo "A developer bootstrap is most likely in progress."
27
	echo "This operation bootstraps all developer files from"
28
	echo "$product and also FreeBSD.org and builds a ISO"
29
	echo "to verify the environment is sane."
30
	echo
31
	echo "During this process, /usr/src is automatically downloaded"
32
	echo "and many supporting files are built, installed, etc."
33
	echo
34
	echo -n "Would you like to tail the progress (y/n) [n]? "
35
	read ANSWER
36
	if [ "$ANSWER" = "y" ]; then
37
		echo
38
		echo "Tailing developer bootstrap process."
39
		echo
40
		echo "Press CTRL-C to abort."
41
		echo
42
		echo "Note, this tailing process will exit once the operation is completed."
43
		echo
44
		tail -f /tmp/bootup_messages
45
	fi
46
fi
47

    
48
# make sure the user can't kill us by pressing Ctrl-C,
49
# ctrl-z, etc.
50
#trap : 2
51
#trap : 3
52
#trap : 4
53

    
54
CONFIG="/cf/conf/config.xml"
55
WORD="https"
56

    
57
# Document which terminal launched last
58
# so we can attempt to track down the
59
# rc.initial respawn issues.
60
echo `tty` > /tmp/last_term_seen
61

    
62
# Set our operating platform
63
PLATFORM=`cat /etc/platform`
64

    
65
# endless loop
66
while : ; do
67

    
68
if [ -f /tmp/ttybug ]; then
69
	rm /tmp/ttybug
70
	exit && exit && logout
71
fi
72

    
73
/etc/rc.banner
74

    
75
# display a cheap menu
76
echo
77
echo
78
echo " ${product} console setup "
79
echo "***************************"
80
echo " 0)  Logout (SSH only)"
81
echo " 1)  Assign Interfaces"
82
echo " 2)  Set LAN IP address"
83
echo " 3)  Reset webConfigurator password"
84
echo " 4)  Reset to factory defaults"
85
echo " 5)  Reboot system"
86
echo " 6)  Halt system"
87
echo " 7)  Ping host"
88
echo " 8)  Shell"
89
echo " 9)  PFtop"
90
echo "10)  Filter Logs"
91
echo "11)  Restart webConfigurator"
92
echo "12)  ${product} Developer Shell"
93
echo "13)  Upgrade from console"
94
SSHD=`netstat -an | grep "*.22" | wc -l`
95
if [ "$SSHD" -gt 0 ]; then
96
	echo "14)  Disable Secure Shell (sshd)";
97
else
98
	echo "14)  Enable Secure Shell (sshd)";
99
fi
100

    
101
for i in /var/db/pfi/capable_*; do
102
    if [ -f $i -a ! -L /cf/conf ]; then
103
	echo "98)  Move configuration file to removable device"
104
	break
105
    fi
106
done
107

    
108
if [ "$PLATFORM" = "cdrom" ]; then
109
    echo "99)  Install ${product} to a hard drive/memory drive, etc."
110
    echo
111
fi
112

    
113
echo
114
read -p "Enter an option: " opmode
115
echo
116

    
117
# see what the user has chosen
118
case ${opmode} in
119
0)
120
        exit && exit && logout
121
        ;;
122
1)
123
        /etc/rc.initial.setports ; sleep 10 ; killall login ; exit
124
        ;;
125
2)
126
        /etc/rc.initial.setlanip ; sleep 10 ; killall login ; exit
127
        ;;
128
3)
129
        /etc/rc.initial.password
130
        ;;
131
4)
132
        /etc/rc.initial.defaults ; sleep 10 ; killall login ; exit
133
        ;;
134
5)
135
        /etc/rc.initial.reboot
136
        ;;
137
6)
138
        /etc/rc.initial.halt
139
        ;;
140
7)
141
        /etc/rc.initial.ping
142
        ;;
143
8)
144
        /bin/tcsh
145
        ;;
146
9)
147
        /usr/local/sbin/pftop
148
        ;;
149
10)
150
		/usr/sbin/tcpdump -n -e -ttt -i pflog0
151
		;;
152
11)
153
		/etc/rc.restart_webgui
154
		;;
155
12)
156
		/usr/local/sbin/pfSsh.php
157
		;;
158
13) 
159
		php -f /etc/rc.initial.firmware_update
160
		;;
161
14) 
162
		php -f /etc/rc.initial.toggle_sshd
163
		;;		
164
15)
165
		/etc/rc.banner
166
		;;
167
98)
168
		if [ ! -f /tmp/config_moved ]; then
169
			/etc/rc.initial.store_config_to_removable_device
170
		fi
171
		;;
172
99)
173
		if [ -e /dev/ukbd0 ]; then
174
		    env TERM=cons25 /scripts/lua_installer
175
		else
176
	            /scripts/lua_installer
177
		fi
178
		;;
179
100)
180
	    if grep "$WORD" "$CONFIG"
181
	    then
182
	    	links "https://localhost"
183
	    else
184
	    	links "http://localhost"
185
	    fi
186
	    ;;
187
"")
188
		killall login ; exit
189
	;;
190
esac
191

    
192
done
193

    
(43-43/82)