aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts/contrib/lsb-v3/init.d/swap
blob: 87c5f61c2d3cda6292d4c8c7b433e89cb78bcaf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# Begin /etc/init.d/swap

### BEGIN INIT INFO
# Provides:            swap
# Required-Start:      mountkernfs udev
# Should-Start:        lvm
# Required-Stop:       $local_fs
# Should-Stop:
# Default-Start:       sysinit 0 6
# Default-Stop:
# Short-Description:   Mounts and unmounts swap partitions.
# Description:         Mounts and unmounts swap partitions defined in 
#                      /etc/fstab.
# X-LFS-Default-Start: S20
# X-LFS-Default-Stop:  S80
# X-LFS-Provided-By:   LFS
### END INIT INFO

. /lib/lsb/init-functions

case "${1}" in
    start)
        message="Activating all swap files/partitions..."
        swapon -a
        evaluate_retval standard
        ;;

    stop)
        message="Deactivating all swap files/partitions..."
        swapoff -a
        evaluate_retval standard
        ;;

    restart)
        swapoff -a
        error_level="${?}"
        sleep 1
        swapon -a
        error_level="$(( ${error_level} + ${?} ))"
        (exit "${error_level}")
        evaluate_retval restart
        ;;

    status)
        log_success_msg "Retrieving swap status..."
        echo
        swapon -s
        ;;

    *)
        echo "Usage: ${0} {start|stop|restart|status}"
        exit 1
        ;;
esac

# End /etc/init.d/swap