3 # $Id: pfi,v 1.12 2005/03/07 06:18:21 cpressey Exp $
4 # $DragonFly: src/nrelease/installer/etc/rc.d/pfi,v 1.8 2005/12/10 00:11:08 swildner Exp $
8 # REQUIRE: mountoptional
18 [ -r /etc/pfi.conf ] && return 0
20 if [ -r $1/pfi.conf ]; then
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
32 if [ "$pfi_script" != "" -a -x "$1/$pfi_script" ]; then
41 get_authorized_hosts()
43 [ -r /root/.ssh/authorized_hosts ] && return 0
44 if [ -r $1/authorized_hosts ]; then
45 echo "authorized_hosts found!"
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 da8s1 fd0 fd1; do
56 echo -n "Looking for pfi.conf on /dev/${try_device}..."
57 if mount_msdos -o rdonly /dev/$try_device /mnt ; then
58 echo -n " /dev/$try_device ok..."
59 if get_pfi_config /mnt /dev/$try_device; then
60 get_authorized_hosts /mnt
71 look_for_pfi_config_cd9660()
73 [ -r /etc/pfi.conf ] && return 0
75 for try_device in acd0 cd0 acd1 cd1; do
76 echo -n "Looking for pfi.conf on /dev/${try_device}..."
77 if mount_cd9660 /dev/$try_device /mnt ; then
78 echo -n " /dev/$try_device ok..."
79 if get_pfi_config /mnt /dev/$try_device; then
80 get_authorized_hosts /mnt
93 echo "Starting pfi..."
95 # Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
97 look_for_pfi_config_cd9660
98 look_for_pfi_config_msdos
100 # If the search was not successful, stub out a dummy pfi.conf.
102 if [ ! -r /etc/pfi.conf ]; then
103 echo '' >/etc/pfi.conf
106 # Append the contents of pfi.conf onto rc.conf, so that settings
107 # (such as ifconfig_dc0="DHCP") will be picked up by pfi_rc_actions.
109 cp /etc/rc.conf /etc/rc.conf.orig
110 cat /etc/pfi.conf >>/etc/rc.conf
112 # Read in the pfi.conf we either found or created for ourselves.
114 if [ -r /etc/defaults/pfi.conf ]; then
115 . /etc/defaults/pfi.conf
119 # We can perform any pre-install tasks here by
120 # examining the contents of pfi_* variables.
122 # Interpret pfi_sshd_* options. These basically add settings
123 # to /etc/ssh/sshd_config; it is assumed "sshd" will appear
124 # in pfi_rc_actions to restart sshd.
126 case ${pfi_sshd_permit_root_login} in
128 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
131 echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
133 forced-commands-only)
134 echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
140 case ${pfi_sshd_permit_empty_passwords} in
142 echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
148 # Interpret pfi_set_root_password. If it is not empty, use
149 # it to set root's LiveCD password.
151 if [ "X$pfi_set_root_password" != "X" ]; then
152 echo "$pfi_set_root_password" | \
153 /usr/sbin/pw usermod root -h 0
156 # The most important pre-install task is to restart
157 # any RCNG scripts listed in pfi_rc_actions with any new
158 # settings that might have been set up by pfi.conf.
160 if [ "X$pfi_rc_actions" != "X" ]; then
161 rev_actions=`reverse_list $pfi_rc_actions`
163 for _rc_elem in ${rev_actions}; do
164 echo "Stopping ${_rc_elem}..."
167 for _rc_elem in ${pfi_rc_actions}; do
168 echo "Starting ${_rc_elem}..."
173 # Restore the original rc.conf.
175 mv /etc/rc.conf.orig /etc/rc.conf
177 # Set up auto-login if requested.
179 if [ "X$pfi_autologin" != "XNONE" ]; then
180 echo 'AL.pfi:\' >> /etc/gettytab
181 echo " :al=${pfi_autologin}:tc=Pc:" >> /etc/gettytab
182 sed -i '' 's|^ttyv0.*|ttyv0 "/usr/libexec/getty AL.pfi" cons25 on secure|' /etc/ttys
185 # Finally, start thttpd if the user wants to use
188 if [ "X$pfi_frontend" = "Xcgi" ]; then
189 echo "Starting thttpd..."
190 /usr/local/sbin/thttpd_wrapper &