Updated scripts to update any OpenBSD release version to stable (tested on 5.0, 5.1, 5.2 and 5.3, i386, amd64 and sparc64 )

I’ve updated my cvsupgrade and makeworld scripts to automatically check the version of OpenBSD running.  I’ve personally tested this on 5.0 and 5.1-release.

The process to update from release to stable is as easy as running cvsupgrade as root, rebooting, then running makeworld as root and rebooting.

WordPress seems to format text in a weird way, so I’ve uploaded this scripts to pastebin.com.

cvsupgrade

#!/bin/sh
#variables
KERNEL=$(uname -v | sed -e ‘s/#.*//’)
VERSION=”OPENBSD_”$(uname -r | sed ‘s/[.]/_/g’)
ARCH=$(uname -m)
CVSROOT=anoncvs@anoncvs.comstyle.com:/cvs
     echo “Fetching OpenBSD “$(uname -r)”-stable source code…”
          #checkout OpenBSD stable source code
          cd /usr
          cvs -d$CVSROOT checkout -r$VERSION -P src ports xenocara
               #update OpenBSD stable source code
               cd /usr/src
               cvs -d$CVSROOT up -r$VERSION -Pd
               cd /usr/ports
               cvs -d$CVSROOT up -r$VERSION -Pd
               cd /usr/xenocara
               cvs -d$CVSROOT up -r$VERSION -Pd
     echo “Done.”
     echo “”
     echo “Please press ENTER to start building “$KERNEL” kernel, or CTRL C to quit.”
     read ENTER
          #build the correct kernel
          cd /usr/src/sys/arch/$ARCH/conf
          config $KERNEL
          cd ../compile/$KERNEL
          make clean && make
     echo “”
     echo “Please press ENTER to install new kernel, or CTRL C to quit.”
     read ENTER
          #install the new kernel
          make install
     echo “”
     echo “New kernel has been installed. The machine must be rebooted.”
     echo “Once rebooted log in as root and run the ‘makeworld’ script.”
     echo “”
     echo “Please press ENTER to reboot the system.”
     read ENTER
reboot

makeworld

#!/bin/sh
     echo “Rebuilding userland and Xenocara.”
     echo “Please be patient this will take a while…”
          #rebuild userland utilites
          rm -rf /usr/obj/*
          cd /usr/src
          make obj
          cd /usr/src/etc && env DESTDIR=/ make distrib-dirs
          cd /usr/src
          make build
               #rebuild Xenocara
               rm -rf /usr/xobj/*
               cd /usr/xenocara
               make bootstrap
               make obj
               make build
     echo “”
     echo “Rebuild complete.”
     echo “”
     echo “Please press ENTER to reboot the system.”
     read ENTER
reboot

 

Posted in OpenBSD | Tagged , , , , , , , , | Leave a comment

Installing OpenBSD 5.3 i386 / amd64 using softraid (also works on OpenBSD 5.1 and 5.2)

Please note currently only the i386 and amd64 kernels allow booting directly from a softraid array.  Other supported architectures require the kernel to be located on a small (100MB) non-softraid partition.

I recently purchased a HP Proliant MicroServer N40L, and a couple of Western Digital RE4 enterprise drives to use in a RAID 1 array.  The process of configuring the softraid RAID array was as simple as follows:

Boot off the 5.3 media as per usual, but choose (S)hell instead of (I)nstall.

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2
# fdisk -iy sd0
Writing MBR at offset 0.
# fdisk -iy sd1
Writing MBR at offset 0.
# disklabel -E sd0
Label editor (enter ‘?’ for help at any prompt)
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# bioctl -c 1 -l /dev/sd0a,/dev/sd1a softraid0
sd2 at scscibus2 targ 1 lun 0: <OPENBSD, SR RAID 1, 005> SCSI2 0/direct fixed
sd2: 476937MB, 512 bytes/sector, 976767473 sectors
softraid0: SR RAID 1 volume attached as sd2
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
1+0 records in
1+0 recours out
1048576 bytes transferred in 0.031 secs (32996916 bytes/sec)
# exit

That will place you back at the (I)nstall, (U)pgrade or (S)hell? prompt and you can install as per normal.  Just be sure to  install to the newly created sd2 array.  Partitions on the array can be configured as per usual, using 4.2 BSD/swap FS types.  Once you’re done reboot as per usual and you’ll be up and running with softraid.  To make sure you can check your array status with the bioctl command.

# bioctl softraid0
Volume        Status                             Size  Device

#

It’s also worth noting that softraid can handle RAID 0, 5 and more.  To configure a RAID 0 stripe you would follow the guide for RAID 1 but change the bioctl command:

# bioctl -c 0 -l /dev/sd0a,/dev/sd1a softraid0

A quick example for configuring 3 drives in RAID 5 would be as follows:

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2 sd3
# fdisk -iy sd0
# fdisk -iy sd1
# fdisk -iy sd2
# disklabel -E sd0
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# disklabel -R sd2 protofile
# bioctl -c 5 -l /dev/sd0a,/dev/sd1a,/dev/sd2a softraid0
# dd if=/dev/zero of=/dev/rsd3c bs=1m count=1
# exit

You would then install to the newly created sd3 array.

As always be sure to check the man pages if you’re not sure what a command does.

softraid (4)
bioctl (8)
fdisk (8)
disklabel (8)

Posted in OpenBSD | Tagged , , , , , | 3 Comments

Zork trilogy menu for Frotz

Here is a small script I chuck in /usr/local/bin/zork to make choosing a Zork game to play easy using Frotz.

WordPress seems to format text in a weird way, so I’ve uploaded this script to pastebin.com.

zork

#!/bin/sh
while true
do
        clear
        echo “Welcome to Zork.”
        echo “”
        echo “Please choose from the following games;”
        echo “”
        echo “1 – Zork I: The Great Underground Empire (1980, Infocom)”
        echo “2 – Zork II: The Wizard of Frobozz (1981, Infocom)”
        echo “3 – Zork III: The Dungeon Master (1982, Infocom)”
        echo “”
        echo “Your choice (1-3 or Q to quit)? \c”
read ZORK
        case $ZORK in
                +([1-3]) )
                        #1-3
                        WHICHGAME=”zork”$ZORK”.z5″
                        /usr/local/bin/frotz /usr/local/share/frotz/$WHICHGAME
                        clear
                        break
                        ;;
                q|Q )
                        #quit
                        clear
                        break
                        ;;
                * )
                        #incorrect selection
                        ;;
        esac
done

I’m using frotz-2.43p2 from the OpenBSD 5.0 packages, and the .z5 files for the Zork trilogy go in /usr/local/share/frotz/.

This script should be easy enough to edit to create a menu for other Frotz games.

Update: this also works with OpenBSD 5.1 and 5.2.

Posted in OpenBSD | Tagged , , , , | Leave a comment