Hi,

I have few scripts to save some work after an installation:

the install.site (pasted on the bottom) asks me if I want to
install a (D)esktop, (L)aptop or (S)erver and depending
on my choice copies the needed packages into /root

Then it puts "-s" into /etc/boot.conf (the idea is stolen from
Chris Kuethe I believe) and creates a custom /.profile. The latter
script installs then all the packages found in /root after the reboot
(into single user mode) and then restores the original /.profile

My problem are the packages: in each OpenBSD release their
versions get bumped up. So what I do now is to do an "ls" in
the packages dir of my older custom CD and replace all versions
by an asterisk:

   ls ~/3.7/server | perl -pe 's/\d+\.[\d.p]+\d/*/g' | tee server.txt

This is not perfect and I have to do some manual editing and also
to delete some duplicate package names (like autoconf-*.tgz).

And now my question: how to fetch the files if you have their list like:

    pref:current {671} cat server.txt
    freetype-*.tgz
    freetype-doc-*.tgz
    mod_perl-*.tgz
    p5-libapreq-1.3.tgz
    php5-core-*.tgz
    php5-gd-*-no_x11.tgz
    php5-pgsql-*.tgz

My current (awkward) script is:

    pref:current {672} cat fetch.sh
    #!/bin/sh

    PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/packages/i386

    if ! test -r "$1"; then
            echo "Please supply a list of packages"
            exit 1
    fi

    while read package; do
            echo ftp -a "$PKG_PATH/$package"
    done <$1

It isn't nice because it starts a new FTP connection for every fetched file.

I've read "man ftp" but didn't found any better solution (mget |"cat
server.txt" ??)

And especially I wonder how do others here approach this problem:
I think every one here has a list of packages they keep installing for
every new release. How do you do that? (Without using  /var/db/pkg/*)

Regards
Alex

PS: Excerpts from my current (ugly) scripts:

pref:current {673} cat install.site
#!/bin/sh -x

# tar cvfz ./3.7/i386/site37.tgz install.site *.profile common.sub
# ls ~/3.7/common | perl -pe 's/\d+\.[\d.p]+\d/*/g'

# copy packages from CDROM into /root
if ! mount -t cd9660 /dev/cd0a /mnt; then
        echo >&2 'Can not mount cd0'
        exit 1
fi

while : ; do
        echo -n '(D)esktop, (S)erver or (T)hinkpad? '
        read resp
        case "$resp" in
        [dD]*)  PROFILE=desktop
                ;;
        [sS]*) PROFILE=server
                ;;
        [tT]*)  PROFILE=thinkpad
                ;;
        *)
                continue
                ;;
        esac

        test -r "$PROFILE.profile" && break;
done

cp /mnt/common/* /root
test "$PROFILE" = thinkpad && cp /mnt/desktop/* /root
cp /mnt/$PROFILE/* /root
cp -R /mnt/config /root

# prepare booting in single user mode
mv /.profile /.profile.OLD && cp $PROFILE.profile /.profile
echo '-s' > /etc/boot.conf

umount /dev/cd0a
eject cd0
echo "Rebooting in 20 seconds..."
sleep 20
reboot

pref:current {674} cat server.profile
#!/bin/sh -x

. ./common.sub
install_packages
create_afarber

# create config files
cat >> /etc/rc.conf.local << EOF
#httpd_flags="-DSSL"
postgresql=NO
EOF

cat >> /etc/rc.shutdown << EOF
echo -n 'stopping local daemons:'

if [ -f /var/postgresql/data/postmaster.pid ]; then
        echo -n ' postgresql'
        su -l _postgresql -c "/usr/local/bin/pg_ctl stop \
                -m fast -D /var/postgresql/data"
        rm -f /var/postgresql/data/postmaster.pid
fi

echo '.'
EOF

restore_profile


#!/bin/sh -x

install_packages() {
        fsck -p / && mount -uw -o softdep /
        mkdir -p /usr/local/lib /usr/X11R6/lib
        ldconfig /usr/local/lib /usr/X11R6/lib
        pkg_add -v /root/*.tgz && rm /root/*.tgz
}

create_afarber() {
        useradd -s /usr/local/bin/tcsh -c 'A. Farber' -g users \
                -G wheel,wsrc -m -d /home/afarber -u 25323 afarber

        echo 'afarber   ALL=(ALL)       NOPASSWD: ALL' >> /etc/sudoers
}

restore_profile() {
        rm -f /etc/boot.conf
        rm -f install.site *.profile common.sub
        # restore the original single user /.profile
        mv -f /.profile.OLD /.profile
        echo "Rebooting in 20 seconds..."
        sleep 20
        reboot
}

Reply via email to