summaryrefslogtreecommitdiff
path: root/addons/x11infoscreen/etc/init.d/flashybrid
diff options
context:
space:
mode:
authorjonas <jonas@8f53b18a-e215-0410-8885-9f593d34873e>2006-06-10 18:18:37 +0000
committerjonas <jonas@8f53b18a-e215-0410-8885-9f593d34873e>2006-06-10 18:18:37 +0000
commitb6d85b04286d30498a11aaac36e75032b1e72801 (patch)
tree2fc597a2ae2cf69a5cc6b3e7162f02f89613b08d /addons/x11infoscreen/etc/init.d/flashybrid
parent369cb1e5a343ec9e7c6f05de64f0eb102488d77f (diff)
Added all work so far...
git-svn-id: svn+ssh://xayide/home/jonas/private_svn/fleshybrid/trunk@2 8f53b18a-e215-0410-8885-9f593d34873e
Diffstat (limited to 'addons/x11infoscreen/etc/init.d/flashybrid')
-rwxr-xr-xaddons/x11infoscreen/etc/init.d/flashybrid128
1 files changed, 128 insertions, 0 deletions
diff --git a/addons/x11infoscreen/etc/init.d/flashybrid b/addons/x11infoscreen/etc/init.d/flashybrid
new file mode 100755
index 0000000..5ab4037
--- /dev/null
+++ b/addons/x11infoscreen/etc/init.d/flashybrid
@@ -0,0 +1,128 @@
+#!/bin/sh
+# Set up/shutdown the flashybrid system, including the ramdisk and partial
+# directory bind mounts. This needs to run at the part of system bootup that
+# mounts all the disks. It should also run at shutdown right before
+# filesystems are unmounted.
+
+CONFDIR=/etc/flashybrid
+if [ -e $CONFDIR/config ]; then
+ . $CONFDIR/config
+fi
+
+ENABLED=no
+if [ -e /etc/default/flashybrid ]; then
+ . /etc/default/flashybrid
+fi
+
+if [ -z "$RAMMOUNT" ]; then
+ exit 0
+fi
+
+is_mounted () {
+ grep -q " $1 " /proc/mounts
+}
+
+case "$1" in
+start)
+ if [ "$ENABLED" != yes ]; then
+ echo "Not setting up flashybrid system: disabled."
+ exit
+ fi
+
+ printf "Setting up flashybrid system..."
+
+ # Set up partial directories and so on, make sure disk is
+ # unmounted.
+ fh-embed >/dev/null
+
+ # Set up ram disk to hold variable data.
+ if ! is_mounted $RAMMOUNT; then
+ mount tmpfs -t tmpfs $RAMMOUNT
+ fi
+
+ # Temporary directories on ram disk.
+ for dir in $(grep -v '^#' $CONFDIR/ramtmp); do
+ mkdir -p -m 1777 $RAMMOUNT/$dir
+ if is_mounted $dir; then
+ umount $dir
+ fi
+ mount --bind $RAMMOUNT/$dir $dir
+ done
+
+ # Copy data from flash to ram disk for these directories.
+ for dir in $(grep -v '^#' $CONFDIR/ramstore); do
+ # Skip dirs that are not present.
+ if [ -d $dir ]; then
+ ramdir=$RAMMOUNT$dir
+ if is_mounted $dir; then
+ umount $dir
+ fi
+ if is_mounted $ramdir.flash; then
+ umount $ramdir.flash
+ fi
+ if [ ! -d $ramdir ]; then
+ mkdir -p ${ramdir%/*} # dirname
+ cp -a $dir $ramdir
+ fi
+ mkdir -p $ramdir.flash
+ mount --bind $dir $ramdir.flash
+ mount --bind $ramdir $dir
+ fi
+ done
+
+ # Make sure virtual filesystems are properly mounted
+ invoke-rc.d mountvirtfs start || /bin/true
+
+ echo "done."
+;;
+stop)
+ if [ "$ENABLED" != yes ]; then
+ echo "Not shutting down flashybrid system: disabled."
+ exit
+ fi
+
+ printf "Shutting down flashybrid system..."
+
+ # Copy data to flash.
+ # Remount the flash read-write so the copies to it will work.
+ mount -o remount,rw /
+ for dir in $(grep -v '^#' $CONFDIR/ramstore); do
+ if [ -d $RAMMOUNT/$dir ] && [ -d $RAMMOUNT/$dir.flash ]; then
+ # rsync is used to avoid churning the flash
+ # unnecessarily. The trailing slashes are very
+ # important..
+ rsync --delete -a $RAMMOUNT/$dir/ $RAMMOUNT/$dir.flash/
+ fi
+ done
+
+ for dir in $(grep -v '^#' $CONFDIR/ramtmp); do
+ if is_mounted $dir; then
+ umount $dir
+ fi
+ done
+
+ for dir in $(grep -v '^#' $CONFDIR/ramstore); do
+ ramdir=$RAMMOUNT$dir
+ if is_mounted $ramdir.flash; then
+ umount $ramdir.flash
+ fi
+ if is_mounted $dir; then
+ umount $dir
+ fi
+ done
+
+ if is_mounted $RAMMOUNT; then
+ umount $RAMMOUNT
+ fi
+
+ echo "done."
+;;
+restart|force-reload)
+ $0 stop
+ $0 start
+;;
+*)
+ echo "Usage: $0 {start|stop|restart|force-reload}"
+ exit 1
+;;
+esac