2 # Filename: prepare_tmpfs.sh
3 # Purpose: setup a tmpfs
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 Mai 27 15:13:03 CEST 2006 [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
26 [ -d /UNIONFS ] && UNIONFS="/UNIONFS" # running from live-CD?
31 if ! mount | grep -q "tmpfs on ${UNIONFS}${DIRECTORY}" ; then
32 if [ -d $DIRECTORY ] ; then
33 if ! [ -d $DIRECTORY.tmpfile ] ; then
34 echo -n "Setting up tmpfs ${DIRECTORY}: "
35 mv $DIRECTORY/ $DIRECTORY.tmpfile && \
37 if mount $TMPFS -t tmpfs tmpfs $DIRECTORY ; then
38 cp -a $DIRECTORY.tmpfile/* $DIRECTORY &>/dev/null
39 cp -a $DIRECTORY.tmpfile/.* $DIRECTORY &>/dev/null
45 echo "Erorr: tmpdir $DIRECTORY.tmpfile exists already. Exiting."
49 echo "Error: $DIRECTORY does not exist. Exiting."
53 echo "Error: $DIRECTORY already mounted. Exiting."
59 if mount | grep -q $DIRECTORY ; then
60 echo -n "Unmounting tmpfs ${DIRECTORY}: "
61 umount ${UNIONFS}${DIRECTORY} && \
63 mv $DIRECTORY.tmpfile $DIRECTORY && echo done || echo failed
65 echo "Error: ${DIRECTORY} not mounted."
72 prepare_start || exit 1
75 prepare_stop || exit 1
84 ## END OF FILE #################################################################