Reduce differences with root_skels in contrib.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / root_skels / installer / etc / rc.d / pfi
blob57ed0ed988f9a35ae24a5a13a8b812c549b5c7fa
1 #!/bin/sh
3 # $Id: pfi,v 1.12 2005/03/07 06:18:21 cpressey Exp $
4 # $DragonFly: src/contrib/bsdinstaller-1.1.6/root_skels/installer/etc/rc.d/Attic/pfi,v 1.1.1.1 2008/03/12 22:15:45 dave Exp $
6 # PROVIDE: pfi
7 # REQUIRE: mountoptional
8 # KEYWORD: DragonFly
10 . /etc/rc.subr
12 name=pfi
13 start_cmd="pfi_start"
14 stop_cmd=":"
16 get_pfi_config()
18 [ -r /etc/pfi.conf ] && return 0
20 if [ -r $1/pfi.conf ]; then
21 echo " found!"
22 tr -d "\r" < $1/pfi.conf > /etc/pfi.conf
23 echo "pfi_found_on_device='$2'" >> /etc/pfi.conf
25 # If the pfi.conf says to run a custom script from the pfi
26 # media, run it now, so that it has access to the pfi media.
28 if [ -r /etc/defaults/pfi.conf ]; then
29 . /etc/defaults/pfi.conf
31 . /etc/pfi.conf
32 if [ "$pfi_script" != "" -a -x "$1/$pfi_script" ]; then
33 $1/$pfi_script
35 return 0
36 else
37 return 1
41 get_authorized_hosts()
43 [ -r /root/.ssh/authorized_hosts ] && return 0
44 if [ -r $1/authorized_hosts ]; then
45 echo "authorized_hosts found!"
46 mkdir -p /root/.ssh/
47 tr -d "\r" < $1/authorized_hosts > /root/.ssh/authorized_hosts
51 look_for_pfi_config_msdos()
53 [ -r /etc/pfi.conf ] && return 0
55 for try_device in da0s1 da1s1 fd0 fd1; do
56 echo -n "Looking for pfi.conf on /dev/${try_device}..."
57 if [ ! -e /dev/${try_device} ]; then
58 ( cd /dev && ./MAKEDEV ${try_device} )
60 if mount_msdos -o rdonly /dev/$try_device /mnt ; then
61 echo -n " /dev/$try_device ok..."
62 if get_pfi_config /mnt /dev/$try_device; then
63 get_authorized_hosts /mnt
64 umount /mnt
65 return 0
67 umount /mnt
69 echo " not found"
70 done
71 return 1
74 look_for_pfi_config_cd9660()
76 [ -r /etc/pfi.conf ] && return 0
78 for try_device in acd0c; do
79 echo -n "Looking for pfi.conf on /dev/${try_device}..."
80 if [ ! -e /dev/${try_device} ]; then
81 ( cd /dev && ./MAKEDEV ${try_device} )
83 if mount_cd9660 /dev/$try_device /mnt ; then
84 echo -n " /dev/$try_device ok..."
85 if get_pfi_config /mnt /dev/$try_device; then
86 get_authorized_hosts /mnt
87 umount /mnt
88 return 0
90 umount /mnt
92 echo " not found"
93 done
94 return 1
97 pfi_start()
99 echo "Starting pfi..."
101 # Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
103 look_for_pfi_config_cd9660
104 look_for_pfi_config_msdos
106 # If the search was not successful, stub out a dummy pfi.conf.
108 if [ ! -r /etc/pfi.conf ]; then
109 echo '' >/etc/pfi.conf
112 # Append the contents of pfi.conf onto rc.conf, so that settings
113 # (such as ifconfig_dc0="DHCP") will be picked up by pfi_rc_actions.
115 cp /etc/rc.conf /etc/rc.conf.orig
116 cat /etc/pfi.conf >>/etc/rc.conf
118 # Read in the pfi.conf we either found or created for ourselves.
120 if [ -r /etc/defaults/pfi.conf ]; then
121 . /etc/defaults/pfi.conf
123 . /etc/pfi.conf
125 # We can perform any pre-install tasks here by
126 # examining the contents of pfi_* variables.
128 # Interpret pfi_sshd_* options. These basically add settings
129 # to /etc/ssh/sshd_config; it is assumed "sshd" will appear
130 # in pfi_rc_actions to restart sshd.
132 case ${pfi_sshd_permit_root_login} in
133 YES)
134 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
136 without-password)
137 echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
139 forced-commands-only)
140 echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
144 esac
146 case ${pfi_sshd_permit_empty_passwords} in
147 YES)
148 echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
152 esac
154 # Interpret pfi_set_root_password. If it is not empty, use
155 # it to set root's LiveCD password.
157 if [ "X$pfi_set_root_password" != "X" ]; then
158 echo "$pfi_set_root_password" | \
159 /usr/sbin/pw usermod root -h 0
162 # The most important pre-install task is to restart
163 # any RCNG scripts listed in pfi_rc_actions with any new
164 # settings that might have been set up by pfi.conf.
166 if [ "X$pfi_rc_actions" != "X" ]; then
167 rev_actions=`reverse_list $pfi_rc_actions`
169 for _rc_elem in ${rev_actions}; do
170 echo "Stopping ${_rc_elem}..."
171 rcstop ${_rc_elem}
172 done
173 for _rc_elem in ${pfi_rc_actions}; do
174 echo "Starting ${_rc_elem}..."
175 rcstart ${_rc_elem}
176 done
179 # Now restore the original pfi.conf.
181 mv /etc/rc.conf.orig /etc/rc.conf
183 # Set up auto-login if requested.
185 if [ "X$pfi_autologin" != "XNONE" ]; then
186 echo 'AL.pfi:\' >> /etc/gettytab
187 echo " :al=${pfi_autologin}:tc=Pc:" >> /etc/gettytab
188 sed -i '' 's|^ttyv0.*|ttyv0 "/usr/libexec/getty AL.pfi" cons25 on secure|' /etc/ttys
191 # Finally, start thttpd if the user wants to use
192 # the cgi frontend.
194 if [ "X$pfi_frontend" = "Xcgi" ]; then
195 echo "Starting thttpd..."
196 /usr/local/sbin/thttpd_wrapper &
200 load_rc_config $name
201 run_rc_command "$1"