X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fprepare_tmpfs.sh;fp=usr_sbin%2Fprepare_tmpfs.sh;h=0000000000000000000000000000000000000000;hb=c08b156abb0b2b1b1335cb1ada0c08758553238b;hp=229fa797a1f8d8767cc536050890cc377a93a45c;hpb=b0c3e5ff760f99d6ff7721852bc1a0d73c5ea201;p=grml-scripts.git diff --git a/usr_sbin/prepare_tmpfs.sh b/usr_sbin/prepare_tmpfs.sh deleted file mode 100755 index 229fa79..0000000 --- a/usr_sbin/prepare_tmpfs.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/zsh -# Filename: prepare_tmpfs.sh -# Purpose: set up a tmpfs of a selected directory -# Authors: grml-team (grml.org), (c) Michael Prokop -# Bug-Reports: see http://grml.org/bugs/ -# License: This file is licensed under the GPL v2. -################################################################################ - -if [ $(id -u) != 0 ] ; then - echo "Error: $0 requires root permissions. Exiting." - exit 1 -fi - -setopt nonomatch - -usage(){ - echo "Usage: $0 " -} - -if ! [ -n "$1" -a -n "$2" ] ; then - usage - exit 1 -fi - -DIRECTORY="$1" - -prepare_start () { - if ! mount | grep -q "tmpfs on ${DIRECTORY}" ; then - if [ -d $DIRECTORY ] ; then - if ! [ -d $DIRECTORY.tmpfile ] ; then - echo -n "Setting up tmpfs ${DIRECTORY}: " - mv $DIRECTORY/ $DIRECTORY.tmpfile && \ - mkdir $DIRECTORY && \ - if mount $TMPFS -t tmpfs tmpfs $DIRECTORY ; then - cp -a $DIRECTORY.tmpfile/* $DIRECTORY &>/dev/null - cp -a $DIRECTORY.tmpfile/.* $DIRECTORY &>/dev/null - echo done - else - echo failed - fi - else - echo "Erorr: tmpdir $DIRECTORY.tmpfile exists already. Exiting." - exit 1 - fi - else - echo "Error: $DIRECTORY does not exist. Exiting." - exit 1 - fi - else - echo "Error: $DIRECTORY already mounted. Exiting." - exit 1 - fi -} - -prepare_stop () { - if mount | grep -q $DIRECTORY ; then - echo -n "Unmounting tmpfs ${DIRECTORY}: " - umount ${DIRECTORY} && \ - rmdir $DIRECTORY && \ - mv $DIRECTORY.tmpfile $DIRECTORY && echo done || echo failed - else - echo "Error: ${DIRECTORY} not mounted." - exit 1 - fi -} - -case "$2" in - start) - prepare_start || exit 1 - ;; - stop) - prepare_stop || exit 1 - ;; - *) - usage - exit 1 -esac - -exit 0 - -## END OF FILE #################################################################