1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-19 23:38:06 +02:00

WIP: make script work regardless of PWD

This commit is contained in:
Shane Kilkelly 2020-07-15 15:29:28 +01:00
parent 32c5d51eab
commit 3119f42407

View file

@ -2,6 +2,10 @@
set -euo pipefail
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
PROJECT_ROOT="$(realpath "$SCRIPT_DIR/..")"
function usage() {
echo "Usage: bin/backup-config [OPTIONS] [DESTINATION]"
echo ""
@ -43,11 +47,11 @@ function __main__() {
destination="$1"
if [[ "$mode" == "copy" ]]; then
cp -r config "$destination"
cp -r "$PROJECT_ROOT/config" "$destination"
elif [[ "$mode" == "zip" ]]; then
zip -r "$destination" config
zip -j -r "$destination" "$PROJECT_ROOT/config"
elif [[ "$mode" == "tar" ]]; then
tar -cf "$destination" config/*
tar -cf "$destination" -C "$PROJECT_ROOT" config
else
echo "Error: unrecognized mode '$mode'"
exit 1