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.7 2005/08/02 17:02:59 cpressey Exp $
8 # REQUIRE: mountoptional
19 [ -r /etc/pfi.conf ] && return 0
21 if [ -r $1/pfi.conf ]; then
23 tr -d "\r" < $1/pfi.conf > /etc/pfi.conf
24 echo "pfi_found_on_device='$2'" >> /etc/pfi.conf
26 # If the pfi.conf says to run a custom script from the pfi
27 # media, run it now, so that it has access to the pfi media.
29 if [ -r /etc/defaults/pfi.conf ]; then
30 . /etc/defaults/pfi.conf
33 if [ "$pfi_script" != "" -a -x "$1/$pfi_script" ]; then
42 get_authorized_hosts()
44 [ -r /root/.ssh/authorized_hosts ] && return 0
45 if [ -r $1/authorized_hosts ]; then
46 echo "authorized_hosts found!"
48 tr -d "\r" < $1/authorized_hosts > /root/.ssh/authorized_hosts
52 look_for_pfi_config_msdos()
54 [ -r /etc/pfi.conf ] && return 0
56 for try_device in da0s1 da1s1 fd0 fd1; do
57 echo -n "Looking for pfi.conf on /dev/${try_device}..."
58 if [ ! -e /dev/${try_device} ]; then
59 ( cd /dev && ./MAKEDEV ${try_device} )
61 if mount_msdos -o rdonly /dev/$try_device /mnt ; then
62 echo -n " /dev/$try_device ok..."
63 if get_pfi_config /mnt /dev/$try_device; then
64 get_authorized_hosts /mnt
75 look_for_pfi_config_cd9660()
77 [ -r /etc/pfi.conf ] && return 0
79 for try_device in acd0c; do
80 echo -n "Looking for pfi.conf on /dev/${try_device}..."
81 if [ ! -e /dev/${try_device} ]; then
82 ( cd /dev && ./MAKEDEV ${try_device} )
84 if mount_cd9660 /dev/$try_device /mnt ; then
85 echo -n " /dev/$try_device ok..."
86 if get_pfi_config /mnt /dev/$try_device; then
87 get_authorized_hosts /mnt
100 echo "Starting pfi..."
102 # Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
104 look_for_pfi_config_cd9660
105 look_for_pfi_config_msdos
107 # If the search was not successful, stub out a dummy pfi.conf.
109 if [ ! -r /etc/pfi.conf ]; then
110 echo '' >/etc/pfi.conf
113 # Append the contents of pfi.conf onto rc.conf, so that settings
114 # (such as ifconfig_dc0="DHCP") will be picked up by pfi_rc_actions.
116 cp /etc/rc.conf /etc/rc.conf.orig
117 cat /etc/pfi.conf >>/etc/rc.conf
119 # Read in the pfi.conf we either found or created for ourselves.
121 if [ -r /etc/defaults/pfi.conf ]; then
122 . /etc/defaults/pfi.conf
126 # We can perform any pre-install tasks here by
127 # examining the contents of pfi_* variables.
129 # Interpret pfi_sshd_* options. These basically add settings
130 # to /etc/ssh/sshd_config; it is assumed "sshd" will appear
131 # in pfi_rc_actions to restart sshd.
133 case ${pfi_sshd_permit_root_login} in
135 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
138 echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
140 forced-commands-only)
141 echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
147 case ${pfi_sshd_permit_empty_passwords} in
149 echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
155 # Interpret pfi_set_root_password. If it is not empty, use
156 # it to set root's LiveCD password.
158 if [ "X$pfi_set_root_password" != "X" ]; then
159 echo "$pfi_set_root_password" | \
160 /usr/sbin/pw usermod root -h 0
163 # The most important pre-install task is to restart
164 # any RCNG scripts listed in pfi_rc_actions with any new
165 # settings that might have been set up by pfi.conf.
167 if [ "X$pfi_rc_actions" != "X" ]; then
168 rev_actions=`reverse_list $pfi_rc_actions`
170 for _rc_elem in ${rev_actions}; do
171 echo "Stopping ${_rc_elem}..."
174 for _rc_elem in ${pfi_rc_actions}; do
175 echo "Starting ${_rc_elem}..."
180 # Restore the original rc.conf.
182 mv /etc/rc.conf.orig /etc/rc.conf
184 # Set up auto-login if requested.
186 if [ "X$pfi_autologin" != "XNONE" ]; then
187 echo 'AL.pfi:\' >> /etc/gettytab
188 echo " :al=${pfi_autologin}:tc=Pc:" >> /etc/gettytab
189 sed -i '' 's|^ttyv0.*|ttyv0 "/usr/libexec/getty AL.pfi" cons25 on secure|' /etc/ttys
192 # Finally, start thttpd if the user wants to use
195 if [ "X$pfi_frontend" = "Xcgi" ]; then
196 echo "Starting thttpd..."
197 /usr/local/sbin/thttpd_wrapper &