diff --git a/.gitignore b/.gitignore index 0fa5e62a..7b1a6d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ old/ -manual.odt \ No newline at end of file +manual.odt +mwe \ No newline at end of file diff --git a/script-drives-add b/script-drives-add index 6607d5e1..30007f12 100644 --- a/script-drives-add +++ b/script-drives-add @@ -3,7 +3,10 @@ # TODO generalize # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-drives-fix-btrfs-full b/script-drives-fix-btrfs-full index 446f5dcd..0163b30b 100755 --- a/script-drives-fix-btrfs-full +++ b/script-drives-fix-btrfs-full @@ -2,7 +2,10 @@ # Fix the btrfs out of space error # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-files-permissions-reset b/script-files-permissions-reset index 07041aec..27012487 100755 --- a/script-files-permissions-reset +++ b/script-files-permissions-reset @@ -2,7 +2,10 @@ # Smartly change permissions on selected directories # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-files-permissions-set b/script-files-permissions-set index 5f3791b9..b13105ad 100755 --- a/script-files-permissions-set +++ b/script-files-permissions-set @@ -2,7 +2,10 @@ # Smartly change permissions on selected directories # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-install-manual-scripts b/script-install-manual-scripts index f7dae850..fc62d7cb 100644 --- a/script-install-manual-scripts +++ b/script-install-manual-scripts @@ -2,7 +2,10 @@ # This script will add scripts-* to the PATH and the manual to each user's Desktop # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-install-motd b/script-install-motd index bbc900bc..3863e77e 100755 --- a/script-install-motd +++ b/script-install-motd @@ -1,8 +1,11 @@ #!/usr/bin/env bash # Install motd scripts +# Bryan C. Roessler -# shellcheck source=./functions -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-install-reverse-proxy b/script-install-reverse-proxy index 1f0dd84e..52ffdc8a 100644 --- a/script-install-reverse-proxy +++ b/script-install-reverse-proxy @@ -2,7 +2,10 @@ # Adds a reverse proxy for local system services # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-system-scheduled-restart b/script-system-scheduled-restart index 76b791ec..7d67f1a1 100755 --- a/script-system-scheduled-restart +++ b/script-system-scheduled-restart @@ -2,7 +2,10 @@ # Update and restart the system # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-system-update b/script-system-update index 20dab357..dc7f93cb 100755 --- a/script-system-update +++ b/script-system-update @@ -2,7 +2,10 @@ # Update the system # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-user-add b/script-user-add index 27407e3d..e0083f61 100755 --- a/script-user-add +++ b/script-user-add @@ -2,7 +2,10 @@ # Add a user to the Hartman Lab server # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-user-remove b/script-user-remove index 1dbf60ca..c8336fbf 100755 --- a/script-user-remove +++ b/script-user-remove @@ -2,7 +2,10 @@ # Remove a user from the server # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-user-reset-password b/script-user-reset-password index 654121ce..68006f4d 100755 --- a/script-user-reset-password +++ b/script-user-reset-password @@ -2,7 +2,10 @@ # This script will reset a user password on the server # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-user-reset-x2go b/script-user-reset-x2go index 26bd564d..97a43653 100755 --- a/script-user-reset-x2go +++ b/script-user-reset-x2go @@ -2,7 +2,10 @@ # This script will reset x2go sessions to a working state # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root diff --git a/script-user-unban b/script-user-unban index ad25cdec..c6abca3d 100755 --- a/script-user-unban +++ b/script-user-unban @@ -2,7 +2,10 @@ # Unbans a fail2ban IP # Copyright 2021 Bryan C. Roessler -[[ -f functions ]] && . functions || exit 1 +parent="${BASH_SOURCE[0]}" +parent=${parent%/*} + +[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1 is_root