Optimized path variables and code

This commit is contained in:
Kevin Veen-Birkenbach 2019-10-01 12:30:27 +02:00
parent 54a11fa8d4
commit 89902cd8eb
7 changed files with 30 additions and 23 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
data/
decrypted/
.encrypted/

View File

@ -2,6 +2,11 @@
#
# This script contains the global program variables and functions
# @author Kevin Veen-Birkenbach [aka. Frantz]
REPOSITORY_PATH="$(dirname "$(readlink -f "${0}")")"
ENCRYPTED=$(readlink -f "$REPOSITORY_PATH/../.encrypted");
DECRYPTED=$(readlink -f "$REPOSITORY_PATH/../data");
#
# shellcheck disable=SC2034 #Deactivate checking of unused variables
REPOSITORY_PATH=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../")
ENCRYPTED_PATH="$REPOSITORY_PATH/.encrypted";
DECRYPTED_PATH="$REPOSITORY_PATH/decrypted";
SCRIPT_PATH="$REPOSITORY_PATH/scripts";
DATA_PATH="$DECRYPTED_PATH/data";
BACKUP_PATH="$DECRYPTED_PATH/backup";

View File

@ -1,4 +1,6 @@
#!/bin/bash
# Executes the import script in reverse mode
# @author Kevin Veen-Birkenbach [aka. Frantz]
bash "$(dirname "$(readlink -f "${0}")")/import-data-from-system.sh" reverse
# shellcheck source=/dev/null # Deactivate SC1090
source "$(dirname "$(readlink -f "${0}")")/base.sh"
bash "$SCRIPT_PATH/import-data-from-system.sh" reverse

View File

@ -4,19 +4,18 @@
# @author Kevin Veen-Birkenbach [aka. Frantz]
# @param $1 If the first parameter is "reverse" the data will be exported to the system
#
# Deactivate SC1090
# shellcheck source=/dev/null
# shellcheck source=/dev/null # Deactivate SC1090
# shellcheck disable=SC2143 # Comparing with -z allowed
source "$(dirname "$(readlink -f "${0}")")/base.sh"
DATA_FOLDER=$ENCRYPTED
if [ -z "$(mount | grep $DATA_FOLDER)" ]
if [ -z "$(mount | grep "$DECRYPTED_PATH")" ]
then
echo "The data folder $DATA_FOLDER is locked. You need to unlock it!"
bash "$(dirname "$(readlink -f "${0}")")/unlock.sh" || exit 1;
echo "The decrypted folder $DECRYPTED_PATH is locked. You need to unlock it!"
bash "$SCRIPT_PATH/unlock.sh" || exit 1;
fi
declare -a BACKUP_LIST=("$HOME/.ssh/" "$HOME/.gitconfig" "$HOME/.mozilla/firefox/" "$HOME/.atom/config.cson");
for system_item_path in "${BACKUP_LIST[@]}";
do
data_item_path="$DATA_FOLDER$system_item_path"
data_item_path="$DATA_PATH$system_item_path"
if [ "$1" = "reverse" ]
then
destination="$system_item_path"

View File

@ -3,8 +3,7 @@
# Locks the data
# @author Kevin Veen-Birkenbach [aka. Frantz]
#
# Deactivate SC1090
# shellcheck source=/dev/null
# shellcheck source=/dev/null # Deactivate SC1090
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"
echo "Locking directory $DECRYPTED_PATH..."
fusermount -u "$DECRYPTED_PATH" && echo "Data is now encrypted." && echo "Removing directory $DECRYPTED_PATH..." && rmdir "$DECRYPTED_PATH"

View File

@ -2,6 +2,9 @@
#
# Installs the core system
# @author Kevin Veen-Birkenbach [aka. Frantz]
#
# shellcheck source=/dev/null # Deactivate SC1090
source "$(dirname "$(readlink -f "${0}")")/base.sh"
echo "Start setup of customized core software..."
echo "Synchronising packages..."
echo "Synchronizing programing languages..."

View File

@ -3,11 +3,10 @@
# Unlocks the data
# @author Kevin Veen-Birkenbach [aka. Frantz]
#
# Deactivate SC1090
# shellcheck source=/dev/null
# shellcheck source=/dev/null # Deactivate SC1090
source "$(dirname "$(readlink -f "${0}")")/base.sh"
echo "Unlocking directory $DECRYPTED..."
echo "Creating directory $DECRYPTED..."
mkdir "$DECRYPTED"
echo "Encrypting directory $DECRYPTED to $DECRYPTED..."
encfs "$ENCRYPTED" "$DECRYPTED" && echo "ATTENTION: DATA IS NOW DECRYPTED!"
echo "Unlocking directory $DECRYPTED_PATH..."
echo "Creating directory $DECRYPTED_PATH..."
mkdir "$DECRYPTED_PATH"
echo "Encrypting directory $DECRYPTED_PATH to $DECRYPTED_PATH..."
encfs "$ENCRYPTED_PATH" "$DECRYPTED_PATH" && echo "ATTENTION: DATA IS NOW DECRYPTED!"