#!/bin/sh PATH="/usr/bin:/usr/sbin:$PATH" SWAPFILE=/swapfile case $1 in 'start') echo "...creating loop device" for i in $(seq 2 6) do if [ ! -e /dev/loop$i ]; then mknod /dev/loop$i b 7 $i 2>/dev/null fi done if [ -f $SWAPFILE ]; then echo "...enabling swap" swapon $SWAPFILE fi if [ -d /data ]; then echo "...mounting filesystems" if [ -f /data/dictionaries.squashfs ]; then mount -o loop -t squashfs /data/dictionaries.squashfs /data/dictionaries fi if [ -f /data/openoffice.squashfs ]; then mount -o loop -t squashfs /data/openoffice.squashfs /mnt/openoffice fi fi sdcontrol insert ;; 'stop') if [ "`grep file /proc/swaps`" != "" ]; then echo "...disabling swap file(s)" for s in `cat /proc/swaps|grep file|cut -d" " -f1` do swapoff $s 2>/dev/null done fi if [ "`grep part /proc/swaps`" != "" ]; then echo "...disabling swap partition(s)" for p in `cat /proc/swaps|grep part|cut -d" " -f1` do swapoff $p 2>/dev/null done fi echo "...unmounting loop device(s)" for i in `mount|grep loop|cut -d" " -f3` do umount $i 2>/dev/null done for i in $(seq 0 6) do losetup -d /dev/loop$i 2>/dev/null done sdcontrol eject ;; *) echo "usage: $0 {start|stop}" ;; esac