Sunday, February 22, 2009

Good amd config and hotplug config for OpenBSD

This is a backup for me, and perhaps of use to anyone else?

amd, acting like /net in solaris and a hotplugd which mounts usb sticks:

/etc/amd/amd.net
---

/defaults type:=host;fs:=${autodir}/${rhost}/root;rhost:=${key}
* opts:=rw,nosuid,grpid


/etc/hotplug/attach
---

#!/bin/sh

devclass=$1
devname=$2

case ${devclass} in
2)
echo "hotplug:attach: Disk device detected (${devname})"

slices=`disklabel ${devname} 2>&1 | grep -e '^ *[abd-z]:' \
| grep -v swap | awk '{print $1}' | cut -b 1`

echo "hotplug:attach: Attempting mount of slices: ${slices}"

chmod 777 /mnt/hot/${devname}

for slice in ${slices}; do

if ! [ -d "/mnt/hot/${devname}${slice}" ]; then
echo "hotplug:attach: Creating /mnt/hot/${devname}${slice}"
mkdir /mnt/hot/${devname}${slice}
fi

chmod 777 /mnt/hot/${devname}${slice}

msdos=`disklabel $devname | grep -e "^ ${slice}:" | grep MSDOS`

echo "hotplug:attach: mounting ${devname}${slice}"
if [ "$msdos" != "" ]; then
echo "hotplug:attach: ${devname}${slice} - MSDOS long filenames enabled"
mount_msdos -l ${opts} /dev/${devname}${slice} \
/mnt/hot/${devname}${slice}
else
mount ${opts} /dev/${devname}${slice} \
/mnt/hot/${devname}${slice}
fi
su - edd -c "DISPLAY=:0 rox /mnt/hot/${devname}${slice}" &

done
;;
esac



/etc/hotplug/dettach
---


#!/bin/sh

devclass=$1
devname=$2

case ${devclass} in
2)
echo "hotplug:detach: Disk device removed"

slices=`mount | grep -e "on /mnt/hot/${devname}" | awk '{print $1}'`

for slice in ${slices}; do
echo "hotplug:detach: Unmounting ${slice}"
umount ${slice}
done
;;
esac

0 comments: