Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly check current directory and try changing to ~/IOTstack #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@
# sudo bash ./scripts/backup.sh 2 pi
# This will only produce a backup in the rollowing folder and change all the permissions to the 'pi' user.

if [ -d "./menu.sh" ]; then
echo "./menu.sh file was not found. Ensure that you are running this from IOTstack's directory."
exit 1
if [ ! -f "menu.sh" ]; then
script_path=$(readlink -f "${BASH_SOURCE[0]}")
cd "${script_path%/*}/.."
if [ ! -f "menu.sh" ]; then
echo "menu.sh file was not found from the current directory. Ensure that you are running this from IOTstack's directory."
exit 1
fi
fi

BACKUPTYPE=${1:-"3"}

if [[ "$BACKUPTYPE" -ne "1" && "$BACKUPTYPE" -ne "2" && "$BACKUPTYPE" -ne "3" ]]; then
echo "Unknown backup type '$BACKUPTYPE', can only be 1, 2 or 3"
echo "Unknown backup type '$BACKUPTYPE', can only be 1, 2 or 3"
exit 1
fi

Expand Down