From 0d26eef610cb1c93590c1915a98d29d0a044e7a7 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 25 Jan 2021 13:39:05 -0800 Subject: [PATCH] added require root --- bashup-backup-files.sh | 6 ++++++ bashup-backup-mysql.sh | 6 ++++++ bashup-backup-pdns.sh | 6 ++++++ bashup-list-backups.sh | 6 ++++++ bashup-restore-files.sh | 6 ++++++ bashup-restore-mysql.sh | 6 ++++++ bashup-restore-pdns.sh | 6 ++++++ 7 files changed, 42 insertions(+) diff --git a/bashup-backup-files.sh b/bashup-backup-files.sh index 09427ea..e08d6d1 100755 --- a/bashup-backup-files.sh +++ b/bashup-backup-files.sh @@ -19,6 +19,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + if [ ! -d $backup_storage_dir ]; then echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." exit 1 diff --git a/bashup-backup-mysql.sh b/bashup-backup-mysql.sh index 92ec937..065e8c6 100755 --- a/bashup-backup-mysql.sh +++ b/bashup-backup-mysql.sh @@ -21,6 +21,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + if [ ! -d $backup_storage_dir ]; then echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." exit 1 diff --git a/bashup-backup-pdns.sh b/bashup-backup-pdns.sh index e7642e1..2fe5842 100755 --- a/bashup-backup-pdns.sh +++ b/bashup-backup-pdns.sh @@ -17,6 +17,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + if [ ! -d $backup_storage_dir ]; then echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." exit 1 diff --git a/bashup-list-backups.sh b/bashup-list-backups.sh index 6a018f0..e8cea65 100755 --- a/bashup-list-backups.sh +++ b/bashup-list-backups.sh @@ -14,6 +14,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + help() { thisfilename=$(basename -- "$0") diff --git a/bashup-restore-files.sh b/bashup-restore-files.sh index 3c6f899..c16f672 100755 --- a/bashup-restore-files.sh +++ b/bashup-restore-files.sh @@ -14,6 +14,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + help() { thisfilename=$(basename -- "$0") diff --git a/bashup-restore-mysql.sh b/bashup-restore-mysql.sh index 56641ec..671f342 100755 --- a/bashup-restore-mysql.sh +++ b/bashup-restore-mysql.sh @@ -14,6 +14,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + help() { thisfilename=$(basename -- "$0") diff --git a/bashup-restore-pdns.sh b/bashup-restore-pdns.sh index ebf32ac..c775b2a 100755 --- a/bashup-restore-pdns.sh +++ b/bashup-restore-pdns.sh @@ -12,6 +12,12 @@ if [[ -f /usr/local/etc/bashup.cnf ]]; then source /usr/local/etc/bashup.cnf fi +# require root +if [ "${EUID}" -ne 0 ]; then + echo "This script must be run as root" + exit 1 +fi + help() { thisfilename=$(basename -- "$0")