3 # $Id: pfi,v 1.4 2004/08/06 23:26:05 cpressey Exp $
4 # $DragonFly: src/nrelease/installer/etc/rc.d/pfi,v 1.6 2005/03/07 18:02:07 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
25 if [ -r /etc/defaults/pfi.conf ]; then
26 . /etc/defaults/pfi.conf
29 if [ "$pfi_script" != "" -a -x "$1/$pfi_script" ]; then
38 get_authorized_hosts()
40 [ -r /root/.ssh/authorized_hosts ] && return 0
41 if [ -r $1/authorized_hosts ]; then
42 echo "authorized_hosts found!"
44 tr -d "\r" < $1/authorized_hosts > /root/.ssh/authorized_hosts
48 look_for_pfi_config_msdos()
50 [ -r /etc/pfi.conf ] && return 0
52 for try_device in da0s1 da1s1 fd0 fd1; do
53 echo -n "Looking for pfi.conf on /dev/${try_device}..."
54 if [ ! -e /dev/${try_device} ]; then
55 ( cd /dev && ./MAKEDEV ${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 acd0c; do
76 echo -n "Looking for pfi.conf on /dev/${try_device}..."
77 if [ ! -e /dev/${try_device} ]; then
78 ( cd /dev && ./MAKEDEV ${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
96 echo "Starting pfi..."
98 # Get the pfi.conf file off the pfi media and into /etc/pfi.conf.
100 look_for_pfi_config_cd9660
101 look_for_pfi_config_msdos
103 if [ ! -r /etc/pfi.conf ]; then
104 echo '' >/etc/pfi.conf
107 # Tack pfi.conf onto the end of rc.conf, so that variables in
108 # pfi.conf are available to the rc subsystem (for pfi_rc_actions.)
110 cp /etc/rc.conf /etc/rc.conf.orig
111 cat /etc/pfi.conf >>/etc/rc.conf
113 if [ -r /etc/defaults/pfi.conf ]; then
114 . /etc/defaults/pfi.conf
118 # We can perform any pre-install tasks here by
119 # examining the contents of pfi_* variables.
121 # Interpret pfi_sshd_* options. These basically add settings
122 # to /etc/ssh/sshd_config; it is assumed "sshd" will appear
123 # in pfi_rc_actions to restart sshd.
125 case ${pfi_sshd_permit_root_login} in
127 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
130 echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config
132 forced-commands-only)
133 echo "PermitRootLogin forced-commands-only" >> /etc/ssh/sshd_config
139 case ${pfi_sshd_permit_empty_passwords} in
141 echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
147 # Interpret pfi_set_root_password. If it is not empty, use
148 # it to set root's LiveCD password.
150 if [ "X$pfi_set_root_password" != "X" ]; then
151 echo "$pfi_set_root_password" | \
152 /usr/sbin/pw usermod root -h 0
155 # The most important pre-install task is to restart
156 # any RCNG scripts listed in pfi_rc_actions with any new
157 # settings that might have been set up by pfi.conf.
159 if [ "X$pfi_rc_actions" != "X" ]; then
160 rev_actions=`reverse_list $pfi_rc_actions`
162 for _rc_elem in ${rev_actions}; do
163 echo "Stopping ${_rc_elem}..."
166 for _rc_elem in ${pfi_rc_actions}; do
167 echo "Starting ${_rc_elem}..."
172 # Restore the original rc.conf.
174 mv /etc/rc.conf.orig /etc/rc.conf
176 # Set up auto-login if requested.
178 if [ "X$pfi_autologin" != "XNONE" ]; then
179 echo 'AL.pfi:\' >> /etc/gettytab
180 echo " :al=${pfi_autologin}:tc=Pc:" >> /etc/gettytab
181 sed -i '' 's|^ttyv0.*|ttyv0 "/usr/libexec/getty AL.pfi" cons25 on secure|' /etc/ttys
184 # Finally, start thttpd if the user wants to use
187 if [ "X$pfi_frontend" = "Xcgi" ]; then
188 echo "Starting thttpd..."
189 /usr/local/sbin/thttpd_wrapper &