Documentation/SupportedImages/BuildingBaselineImage: mkswap.sh

File mkswap.sh, 918 bytes (added by ssugrim, 8 years ago)

Start up script to make swap files

Line 
1#! /bin/sh
2#
3
4### BEGIN INIT INFO
5# Provides: mkswap
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: Makes a swap file on start and removes it on stop
9# Description: see short
10### END INIT INFO
11
12FILENAME=/swapfile
13
14start(){
15 echo -n "Makeing swap at: $FILENAME "
16 if [ -e $FILENAME ]; then
17 swapoff $FILENAME
18 rm $FILENAME
19 fi
20 dd if=/dev/zero of=$FILENAME bs=10M count=200
21 mkswap $FILENAME
22 chown root.root $FILENAME
23 chmod 0600 $FILENAME
24 swapon $FILENAME
25 echo "."
26}
27
28stop(){
29 echo -n "Removing swap at: $FILENAME "
30 if [ -e $FILENAME ]; then
31 swapoff $FILENAME
32 rm $FILENAME
33 fi
34 echo "."
35}
36
37case "$1" in
38 start)
39 start
40 ;;
41 stop)
42 stop
43 ;;
44 restart)
45 stop
46 start
47 ;;
48 force-reload)
49 stop
50 start
51 ;;
52 *)
53 echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}"
54 exit 1
55esac
56
57exit 0
58