Solved bsdinstall rootpass

Hi folks.

In my mind this fits right in with "Installing and Upgrading FreeBSD", but if this isn't the right place for this, I apologize.

I'm having some difficulty with bsdinstall and installerconfig. I can do anything else I need to with installerconfig (set the time, network, etc.), but calling rootpass ALWAYS results in an installation error.

Here's the installerconfig I'm using for testing:
Code:
DISTRIBUTIONS="kernel.txz base.txz"
PARTITIONS="ada0 { 512K freebsd-boot, 6G freebsd-ufs /, 1G freebsd-swap, auto freebsd-ufs /media/local }"

bsdinstall rootpass

#!/bin/sh

I can't find in the bsdinstall man page if the rootpass call needs to be somewhere other than the preamble. Is this where it's supposed to go? If not, where? Is there another way to set the root password without putting it in the script?

Thanks for your help.

Cheers!
Randall
 
Thanks to wblock@ for enlightening me on the expectations regarding formatting.

After some sleep, the answer seemed clear: check out what bsdinstall does. It's really not all that grand--it passes the arguments to the script named in the first argument in /usr/libexec/bsdinstall/.

For example, bsdinstall rootpass does the following: chroot $BSDINSTALL_CHROOT passwd root 2>&1

Seeing that, it was easy enough to realize that calling bsdinstall rootpass in the preamble changes root too early (causing subsequent actions expecting to be outside the target to fail) and after the shebang #!/bin/sh to a non-existant root (because it's already the root). It seems clear that bsdinstall isn't meant to be used to run multiple commands, since none of them exit the rooted directory upon completion.

With that bit of information, I added the bits I needed to the script after the shebang and it's all good. I ended up with etc/installerconfig:
Code:
DISTRIBUTIONS="kernel.txz base.txz"
PARTITIONS="ada0 { 512K freebsd-boot, 8G freebsd-ufs /, 1G freebsd-swap, auto freebsd-ufs /media/local }"

#!/bin/sh
echo "I: Detecting network interfaces"
netif=""
for interface in bge0 igb0 em0
do
    ifexists=`ifconfig $interface`
    if [ "$ifexists" != "" ]
    then
        netif=$interface
        break
    fi
done

echo "I: Getting MAC of current machine"
macaddr=`ifconfig $netif | grep ether | cut -d ' ' -f 2`
if [ "$macaddr" != "" ]
then
    host_name=`echo "freebsd-$macaddr" | sed -e 's/://g'`
else
    host_name="freebsd"
fi

echo "I: Hostname set to: $host_name"
echo hostname="$host_name" >> /etc/rc.conf

echo "I: Enabling SSH"
echo 'sshd_enable="YES"' >> /etc/rc.conf
sed -i .bk 's/\#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config

echo "I: Removing boot menu delay"
echo 'autoboot_delay="-1"' >> /boot/loader.conf

echo "I: Setting NIC to DHCP"
echo ifconfig_$netif="DHCP" >> /etc/rc.conf

echo "I: Setting timezone to America/Vancouver"
ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime

echo "P: Enter the root password"
passwd root 2>&1

I've only got PermitRootLogin enabled for testing.

Now I just need to incorporate my bootstrap.sh (used to install applications and configure the system for centralized authentication and NFS home directories) into it, leaving a usable system.

Cheers!
Randall
 
Back
Top