Add backupswap.sh to on/off the backup swap
This commit is contained in:
Executable
+33
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user