#!/bin/bash

# sourcing our current rc.conf requires this to be a bash script
. /usr/lib/rc/functions

ck_verbose && SWAP_VERBOSE="-v"

case "$1" in
    start)
        stat_busy "Activating swap"
        swapon -a "${SWAP_VERBOSE}" || stat_die swap
        add_daemon swap
        stat_done swap
        ;;
    stop)
        stat_busy "Deactivating swap"
        swapoff -a "${SWAP_VERBOSE}" || stat_die swap
        rm_daemon swap
        stat_done swap
        ;;
    *)
        echo "usage: $0 {start|stop}"
        exit 1
        ;;
esac
