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 if [ -c /dev/${try_device} ]; then
57 echo -n "Looking for pfi.conf on /dev/${try_device}..."
58 if mount_msdos -o rdonly /dev/$try_device /mnt ; then
59 echo -n " /dev/$try_device ok..."
60 if get_pfi_config /mnt /dev/$try_device; then
61 get_authorized_hosts /mnt
73 look_for_pfi_config_cd9660()
75 [ -r /etc/pfi.conf ] && return 0
77 for try_device in acd0 cd0 acd1 cd1; do
78 if [ -c /dev/${try_device} ]; then
79 echo -n "Looking for pfi.conf on /dev/${try_device}..."
80 if mount_cd9660 /dev/$try_device /mnt ; then
81 echo -n " /dev/$try_device ok..."
82 if get_pfi_config /mnt /dev/$try_device; then
83 get_authorized_hosts /mnt
97 echo "Starting pfi..."
99 # Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
101 look_for_pfi_config_cd9660
102 look_for_pfi_config_msdos
104 # If the search was not successful, stub out a dummy pfi.conf.
106 if [ ! -r /etc/pfi.conf ]; then
107 echo '' >/etc/pfi.conf
110 # Append the contents of pfi.conf onto rc.conf, so that settings
111 # (such as ifconfig_dc0="DHCP") will be picked up by pfi_rc_actions.
113 cp /etc/rc.conf /etc/rc.conf.orig
114 cat /etc/pfi.conf >>/etc/rc.conf
116 # Read in the pfi.conf we either found or created for ourselves.
118 if [ -r /etc/defaults/pfi.conf ]; then
119 . /etc/defaults/pfi.conf
123 # We can perform any pre-install tasks here by
124 # examining the contents of pfi_* variables.
126 # Interpret pfi_sshd_* options. These basically add settings
127 # to /etc/ssh/sshd_config; it is assumed "sshd" will appear
128 # in pfi_rc_actions to restart sshd.
130 case ${pfi_sshd_permit_root_login} in
132 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
135 echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
137 forced-commands-only)
138 echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
144 case ${pfi_sshd_permit_empty_passwords} in
146 echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
152 # Interpret pfi_set_root_password. If it is not empty, use
153 # it to set root's LiveCD password.
155 if [ "X$pfi_set_root_password" != "X" ]; then
156 echo "$pfi_set_root_password" | \
157 /usr/sbin/pw usermod root -h 0
160 # The most important pre-install task is to restart
161 # any RCNG scripts listed in pfi_rc_actions with any new
162 # settings that might have been set up by pfi.conf.
164 if [ "X$pfi_rc_actions" != "X" ]; then
165 rev_actions=`reverse_list $pfi_rc_actions`
167 for _rc_elem in ${rev_actions}; do
168 echo "Stopping ${_rc_elem}..."
171 for _rc_elem in ${pfi_rc_actions}; do
172 echo "Starting ${_rc_elem}..."
177 # Restore the original rc.conf.
179 mv /etc/rc.conf.orig /etc/rc.conf
181 # Set up auto-login if requested.
183 if [ "X$pfi_autologin" != "XNONE" ]; then
184 echo 'AL.pfi:\' >> /etc/gettytab
185 echo " :al=${pfi_autologin}:tc=Pc:" >> /etc/gettytab
186 sed -i '' 's|^ttyv0.*|ttyv0 "/usr/libexec/getty AL.pfi" cons25 on secure|' /etc/ttys
189 # Finally, start thttpd if the user wants to use
192 if [ "X$pfi_frontend" = "Xcgi" ]; then
193 echo "Starting thttpd..."
194 /usr/local/sbin/thttpd_wrapper &