Skip to content

Commit

Permalink
Added root checks
Browse files Browse the repository at this point in the history
  • Loading branch information
framps committed Feb 29, 2024
1 parent b7b9ab4 commit e352f1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 7 additions & 5 deletions helper/raspiBackupAndClone.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
#
echo "Still under development"
exit 42
#
#######################################################################################################################
#
# Sample script which calls raspiBackup.sh to create a backup and restores the backup to a device (e.g. SD card or USB disk) afterwards
Expand Down Expand Up @@ -45,6 +42,11 @@ GIT_COMMIT_ONLY=$(cut -f 2 -d ' ' <<< $GIT_COMMIT | sed 's/\$//')

GIT_CODEVERSION="$MYSELF $VERSION, $GIT_DATE_ONLY/$GIT_TIME_ONLY - $GIT_COMMIT_ONLY"

if (( $UID != 0 )); then
echo "--- Call me as root or with sudo"
exit 1
fi

# add pathes if not already set (usually not set in crontab)

if [[ -e /bin/grep ]]; then
Expand All @@ -65,7 +67,7 @@ function readVars() {
# MSG_FILE refers to message file just created
# LOG_FILE referes to logfile just created
else
echo "/tmp/raspiBackup.vars not found"
echo "??? /tmp/raspiBackup.vars not found"
exit 42
fi
}
Expand All @@ -89,7 +91,7 @@ if [[ ! -b $CLONE_DEVICE ]]; then
exit 1
fi

echo "Creating backup and restore backup afterwards to $CLONE_DEVICE ..."
echo "--- Creating backup and restore backup afterwards to $CLONE_DEVICE ..."

# create backup
raspiBackup.sh
Expand Down
7 changes: 6 additions & 1 deletion helper/raspiBackupAndJSON.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ function readVars() {
# MSG_FILE refers to message file just created
# LOG_FILE referes to logfile just created
else
echo "/tmp/raspiBackup.vars not found"
echo "??? /tmp/raspiBackup.vars not found"
exit 42
fi
}

# main program

if (( $UID != 0 )); then
echo "--- Call me as root or with sudo"
exit 1
fi

if ! which raspiBackup &>/dev/null; then
echo "??? Missing raspiBackup.sh"
exit 1
Expand Down

0 comments on commit e352f1f

Please sign in to comment.