#!/bin/sh # Easymount installer, easily mount removable hardware by mortal users on NetBSD # CL 2005 Bastiaan Welmers, bastiaan at welmers.net installfiles () { FILESDIR=`echo $0 | sed -e /install.sh/s///`files if [ ! -e /sbin/mount_general ]; then mv /sbin/mount /sbin/mount_general cp $FILESDIR/mount /sbin/mount chmod 555 /sbin/mount else echo "Warning: /sbin/mount_general seems to already exists, not overwriting" fi if [ ! -e /sbin/umount_root ]; then mv /sbin/umount /sbin/umount_root cp $FILESDIR/umount /sbin/umount chmod 555 /sbin/umount else echo "Warning: /sbin/umount_root seems to already exists, not overwriting" fi if [ ! -e /usr/bin/reject_root ]; then mv /usr/bin/eject /usr/bin/eject_root cp $FILESDIR/eject /usr/bin/eject chmod 555 /usr/bin/eject else echo "Warning: /usr/bin/eject_root seems to already exists, not overwriting" fi cp $FILESDIR/mount_auto /sbin chmod 555 /sbin/mount_auto if [ ! -d /usr/local/bin ]; then mkdir -p /usr/local/bin fi ln -s /sbin/mount /usr/local/bin/mount ln -s /sbin/umount /usr/local/bin/umount cp $FILESDIR/sudoers.easymount /usr/pkg/etc cp $FILESDIR/fstab.easymount /etc cat << "EOF" Files are installed. Please complete /usr/pkg/etc/sudoers and /etc/fstab to enable mortal-user mounting. Examples are in /usr/pkg/etc/sudoers.easymount and /etc/fstab.easymount EOF exit } cat << "EOF" NOTE: this will install easymount, a few scripts that replace /sbin/mount, /sbin/umount, and /usr/bin/eject making it possible to easily mount, unmount and eject removable media by mortal users, authorized by sudo. Originaly binaries will be renamed to respectively /sbin/mount_general, /sbin/umount_root and /usr/bin/eject_root. It also adds /sbin/mount_auto, making it possible to use the \"auto\" fs type in /etc/fstab, so the file system type of the media will be auto-detected, and set the right file user id in case of msdos file systems. Additionaly files /etc/fstab.easymount and /usr/pkg/etc/sudoers.easymount will be created, containing examples for setting up fstab and sudoers files the right way. Also symlinks in /usr/local/bin will be created, pointing to /sbin/mount and /sbin/umount Do you want to continue? (Yes) EOF read yesno YESNO=`echo $yesno | tr a-z A-Z` if [ $YESNO = YES ]; then installfiles fi echo "Aborting..."