From 24e05b6c0882880491cf8f6ca9eb6fff9ef992f0 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Tue, 1 Oct 2019 08:50:17 +0200 Subject: [PATCH] Added base.sh and refactored --- scripts/base.sh | 5 +++++ scripts/import-data-from-system.sh | 3 ++- scripts/lock.sh | 2 +- scripts/system-setup.sh | 4 +++- scripts/unlock.sh | 3 +-- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 scripts/base.sh diff --git a/scripts/base.sh b/scripts/base.sh new file mode 100644 index 0000000..bb95459 --- /dev/null +++ b/scripts/base.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script contains the global program variables and functions +# @author Kevin Veen-Birkenbach [aka. Frantz] +ENCRYPTED=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../.encrypted"); +DECRYPTED=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../data"); diff --git a/scripts/import-data-from-system.sh b/scripts/import-data-from-system.sh index 4b4e808..215c4c1 100644 --- a/scripts/import-data-from-system.sh +++ b/scripts/import-data-from-system.sh @@ -2,7 +2,8 @@ # Imports data from the system # @author Kevin Veen-Birkenbach [aka. Frantz] # @param $1 If the first parameter is "reverse" the data will be exported to the system -DATA_FOLDER=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../data"); +source "$(dirname "$(readlink -f "${0}")")/base.sh" +DATA_FOLDER=$ENCRYPTED if [ -z "$(mount | grep $DATA_FOLDER)" ] then echo "The data folder $DATA_FOLDER is locked. You need to unlock it!" diff --git a/scripts/lock.sh b/scripts/lock.sh index a3f2001..fddd4ab 100644 --- a/scripts/lock.sh +++ b/scripts/lock.sh @@ -1,6 +1,6 @@ #!/bin/bash # Locks the data # @author Kevin Veen-Birkenbach [aka. Frantz] -DECRYPTED=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../data"); +source "$(dirname "$(readlink -f "${0}")")/base.sh" echo "Locking directory $DECRYPTED..." fusermount -u "$DECRYPTED" && echo "Data is now encrypted." && echo "Removing directory $DECRYPTED..." && rmdir "$DECRYPTED" diff --git a/scripts/system-setup.sh b/scripts/system-setup.sh index 8065227..d7adec1 100644 --- a/scripts/system-setup.sh +++ b/scripts/system-setup.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Installs the core system +# @author Kevin Veen-Birkenbach [aka. Frantz] echo "Start setup of customized core software..." echo "Synchronising packages..." echo "Synchronizing programing languages..." @@ -57,7 +59,7 @@ apm install -c \ highlight-selected\ autocomplete-paths\ todo-show\ - docblockr\ + docblockr npm i -g bash-language-server #Needed by atom-package ide-bash echo "Synchronizing containerization tools..." echo "Installing docker..." diff --git a/scripts/unlock.sh b/scripts/unlock.sh index 028468d..a2dc280 100644 --- a/scripts/unlock.sh +++ b/scripts/unlock.sh @@ -1,8 +1,7 @@ #!/bin/bash # Unlocks the data # @author Kevin Veen-Birkenbach [aka. Frantz] -ENCRYPTED=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../.encrypted"); -DECRYPTED=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../data"); +source "$(dirname "$(readlink -f "${0}")")/base.sh" echo "Unlocking directory $DECRYPTED..." echo "Creating directory $DECRYPTED..." mkdir "$DECRYPTED"