#! /bin/sh
#

### BEGIN INIT INFO
# Provides:          mkswap
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Makes a swap file on start and removes it on stop
# Description:      see short
### END INIT INFO

FILENAME=/swapfile

start(){
    echo -n "Makeing swap at: $FILENAME "
	if [ -e $FILENAME ]; then
	    swapoff $FILENAME
            rm $FILENAME
	fi
	dd if=/dev/zero of=$FILENAME bs=10M count=200
	mkswap $FILENAME
	chown root.root $FILENAME
	chmod 0600 $FILENAME
	swapon $FILENAME
    echo "."
}

stop(){
    echo -n "Removing swap at: $FILENAME "
	if [ -e $FILENAME ]; then
	    swapoff $FILENAME
            rm $FILENAME
	fi
    echo "."
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  force-reload)
    stop
    start
    ;;
  *)
	echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}"
	exit 1
esac

exit 0

