Add backupswap.sh to on/off the backup swap

This commit is contained in:
Johannes Zellner
2015-06-17 09:22:41 +02:00
parent 22fb979e42
commit 862aed7044
2 changed files with 34 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
set -eu -o pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "This script should be run as root." > /dev/stderr
exit 1
fi
if [[ $# -eq 0 ]]; then
echo "No arguments supplied"
exit 1
fi
if [[ "$1" == "--check" ]]; then
echo "OK"
exit 0
fi
BACKUP_SWAP_FILE="/backup.swap"
if [[ "$1" == "--on" ]]; then
if ! swapon -s | grep -q "${BACKUP_SWAP_FILE}"; then
swapon "${BACKUP_SWAP_FILE}"
fi
fi
if [[ "$1" == "--off" ]]; then
if swapon -s | grep -q "${BACKUP_SWAP_FILE}"; then
swapoff "${BACKUP_SWAP_FILE}"
fi
fi
+1
View File
@@ -15,6 +15,7 @@ scripts=("${SOURCE_DIR}/scripts/rmappdir.sh" \
"${SOURCE_DIR}/scripts/backupapp.sh" \
"${SOURCE_DIR}/scripts/restoreapp.sh" \
"${SOURCE_DIR}/scripts/reboot.sh" \
"${SOURCE_DIR}/scripts/backupswap.sh" \
"${SOURCE_DIR}/scripts/reloadcollectd.sh")
for script in "${scripts[@]}"; do