#!/bin/sh : ${INSTALL_ROOT="/mnt/magellan"} KNOWN_DISKS="ROOT BOOT SWAP HOME TMP USER VAR SVR OPT" format_disks() { local disk local disk_part local disk_fs local opts local progress declare -i progress=0 # disk format for disk in ${KNOWN_DISKS} do disk_part=$(eval echo \$PARTITION_DISK_${disk}) disk_fs=$(eval echo \$PARTITION_FS_${disk}) if [[ ! -z ${disk_part} ]] then if [[ ! -z ${disk_fs} ]] then case ${disk_fs} in swap) mkswap ${disk_part} >&2;; reiserfs) mkfs.${disk_fs} -f ${disk_part} >&2;; *) mkfs.${disk_fs} ${disk_part} >&2;; esac fi fi (( progress++ )) echo ${progress} 9 | awk '{print ($1 / $2 * 100) - 1}' done echo "100" } mount_disks() { local disk local disk_part local dest # activate swap swapon ${PARTITION_DISK_SWAP} # first mount rootfs mount ${PARTITION_DISK_ROOT} ${INSTALL_ROOT} # than all other for disk in ${KNOWN_DISKS} do case ${disk} in BOOT) dest=boot ;; HOME) dest=home ;; TMP) dest=tmp ;; USER) dest=usr ;; VAR) dest=var ;; SVR) dest=svr ;; OPT) dest=opt ;; *) continue ;; esac disk_part=$(eval echo \$PARTITION_DISK_${disk}) if [[ ! -z ${disk_part} ]] then install -d ${INSTALL_ROOT}/${dest} mount ${disk_part} ${INSTALL_ROOT}/${dest} fi done } umount_disks() { local disk local disk_part local dest # first umount all other for disk in ${KNOWN_DISKS} do # excludes case ${disk} in ROOT) continue ;; SWAP) continue ;; esac disk_part=$(eval echo \$PARTITION_DISK_${disk}) [[ ! -z ${disk_part} ]] && umount ${disk_part} done # then umount rootfs umount ${PARTITION_DISK_ROOT} # de-activate swap swapoff ${PARTITION_DISK_SWAP} } case $1 in --format | -f) format_disks ;; --mount | -m ) mount_disks ;; --umount | -u ) umount_disks ;; *) echo "unkown option '$1'." ;; esac