2 # Filename: prepare_tmpfs.sh
3 # Purpose: set up a tmpfs of a selected directory
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Sam Okt 06 13:23:59 CEST 2007 [mika]
8 ################################################################################
10 if [ $UID != 0 ]; then
11 echo "Error: $0 requires root permissions. Exiting."
18 echo "Usage: $0 <directory> <start|stop>"
21 if ! [ -n "$1" -a -n "$2" ] ; then
29 if ! mount | grep -q "tmpfs on ${DIRECTORY}" ; then
30 if [ -d $DIRECTORY ] ; then
31 if ! [ -d $DIRECTORY.tmpfile ] ; then
32 echo -n "Setting up tmpfs ${DIRECTORY}: "
33 mv $DIRECTORY/ $DIRECTORY.tmpfile && \
35 if mount $TMPFS -t tmpfs tmpfs $DIRECTORY ; then
36 cp -a $DIRECTORY.tmpfile/* $DIRECTORY &>/dev/null
37 cp -a $DIRECTORY.tmpfile/.* $DIRECTORY &>/dev/null
43 echo "Erorr: tmpdir $DIRECTORY.tmpfile exists already. Exiting."
47 echo "Error: $DIRECTORY does not exist. Exiting."
51 echo "Error: $DIRECTORY already mounted. Exiting."
57 if mount | grep -q $DIRECTORY ; then
58 echo -n "Unmounting tmpfs ${DIRECTORY}: "
59 umount ${DIRECTORY} && \
61 mv $DIRECTORY.tmpfile $DIRECTORY && echo done || echo failed
63 echo "Error: ${DIRECTORY} not mounted."
70 prepare_start || exit 1
73 prepare_stop || exit 1
82 ## END OF FILE #################################################################