From a83c926697c656e3d94411a4f1736d9f3527f3d4 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 14:35:31 -0500 Subject: [PATCH 01/22] Attempt to make DockStarter work with an immutable filesystem --- .scripts/symlink_ds.sh | 48 +++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 9803d3d205..c726f3788b 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,25 +5,39 @@ IFS=$'\n\t' symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" - # /usr/bin/ds - if [[ -L "/usr/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/bin/ds)" ]]; then - info "Attempting to remove /usr/bin/ds symlink." - sudo rm -f "/usr/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/bin/ds\"" - fi - if [[ ! -L "/usr/bin/ds" ]]; then - info "Creating /usr/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/bin/ds" + if findmnt -n /usr | egrep "^ro,|,ro,|,ro$"; then + echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead." + # $HOME/bin/ds + if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f $HOME/bin/ds)" ]]; then + info "Attempting to remove $HOME/bin/ds symlink." + sudo rm -f "$HOME/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"$HOME/bin/ds\"" + fi + if [[ ! -L "$HOME/bin/ds" ]]; then + info "Creating $HOME/bin/ds symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" + fi + else + # /usr/bin/ds + if [[ -L "/usr/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/bin/ds)" ]]; then + info "Attempting to remove /usr/bin/ds symlink." + sudo rm -f "/usr/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/bin/ds\"" + fi + if [[ ! -L "/usr/bin/ds" ]]; then + info "Creating /usr/bin/ds symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/bin/ds" + fi + + # /usr/local/bin/ds + if [[ -L "/usr/local/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/local/bin/ds)" ]]; then + info "Attempting to remove /usr/local/bin/ds symlink." + sudo rm -f "/usr/local/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/local/bin/ds\"" + fi + if [[ ! -L "/usr/local/bin/ds" ]]; then + info "Creating /usr/local/bin/ds symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" /usr/local/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/local/bin/ds" + fi fi - # /usr/local/bin/ds - if [[ -L "/usr/local/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/local/bin/ds)" ]]; then - info "Attempting to remove /usr/local/bin/ds symlink." - sudo rm -f "/usr/local/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/local/bin/ds\"" - fi - if [[ ! -L "/usr/local/bin/ds" ]]; then - info "Creating /usr/local/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" /usr/local/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/local/bin/ds" - fi } test_symlink_ds() { From 970b8fd1747ad0da42cfd7eda27ebcf56f916bbd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 14:39:17 -0500 Subject: [PATCH 02/22] Update symlink_ds.sh --- .scripts/symlink_ds.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index c726f3788b..e823bbf73d 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,7 +5,7 @@ IFS=$'\n\t' symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" - if findmnt -n /usr | egrep "^ro,|,ro,|,ro$"; then + if findmnt -n /usr | grep "ro"; then echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead." # $HOME/bin/ds if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f $HOME/bin/ds)" ]]; then @@ -14,7 +14,7 @@ symlink_ds() { fi if [[ ! -L "$HOME/bin/ds" ]]; then info "Creating $HOME/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" + sudo ln -s -T "${SCRIPTNAME}" $HOME/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" fi else # /usr/bin/ds From 2f4c55eacc7ec973708e9b72ff95c6bbc4fa073f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 14:40:17 -0500 Subject: [PATCH 03/22] Update symlink_ds.sh --- .scripts/symlink_ds.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index e823bbf73d..081b35aa27 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -6,8 +6,9 @@ symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" if findmnt -n /usr | grep "ro"; then - echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead." - # $HOME/bin/ds + echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead. You will need to add this to your path." + mkdir -p $HOME/bin # Make sure the path exists. + # $HOME/bin/ds if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f $HOME/bin/ds)" ]]; then info "Attempting to remove $HOME/bin/ds symlink." sudo rm -f "$HOME/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"$HOME/bin/ds\"" From 9c4fbcb095e5721c453b5a86ac5a52963090ff73 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 14:46:18 -0500 Subject: [PATCH 04/22] We don't need to have a package manager install things if they are already there --- .scripts/package_manager_run.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index 63248e3fb6..b3dbe54ed3 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -13,7 +13,20 @@ package_manager_run() { elif [[ -n "$(command -v yum)" ]]; then run_script "pm_yum_${ACTION}" else - fatal "Supported package manager not detected!" + # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. + echo "Supported package manager not detected. Checking for dependencies ..." + # Define an array of commands + commands=("curl" "docker" "docker-compose" "git" "grep" "sed" "whiptail") + + # Iterate over each command in the array + for cmd in "${commands[@]}"; do + # Check if the command is available in the system + if ! command -v "$cmd" &> /dev/null; then + fatal "Error: '$cmd' is not available. Exiting..." + fi + done + + echo "All commands are available." fi } From 0c7fc0ef4eb60f59f4db73f06d058bc5a6c904c4 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 16:07:02 -0500 Subject: [PATCH 05/22] fix: trailing whitespace --- .scripts/package_manager_run.sh | 4 ++-- .scripts/symlink_ds.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index b3dbe54ed3..4da9215ca3 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -17,7 +17,7 @@ package_manager_run() { echo "Supported package manager not detected. Checking for dependencies ..." # Define an array of commands commands=("curl" "docker" "docker-compose" "git" "grep" "sed" "whiptail") - + # Iterate over each command in the array for cmd in "${commands[@]}"; do # Check if the command is available in the system @@ -25,7 +25,7 @@ package_manager_run() { fatal "Error: '$cmd' is not available. Exiting..." fi done - + echo "All commands are available." fi } diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 081b35aa27..6b9b02ee8f 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -27,7 +27,7 @@ symlink_ds() { info "Creating /usr/bin/ds symbolic link for DockSTARTer." sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/bin/ds" fi - + # /usr/local/bin/ds if [[ -L "/usr/local/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/local/bin/ds)" ]]; then info "Attempting to remove /usr/local/bin/ds symlink." From 269ea8177556fa9f45c5a4833a232e12bb20d66b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 16:11:04 -0500 Subject: [PATCH 06/22] fix: shellcheck issues --- .scripts/symlink_ds.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 6b9b02ee8f..b7802f4beb 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -7,15 +7,15 @@ symlink_ds() { if findmnt -n /usr | grep "ro"; then echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead. You will need to add this to your path." - mkdir -p $HOME/bin # Make sure the path exists. + mkdir -p "$HOME/bin" # Make sure the path exists. # $HOME/bin/ds - if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f $HOME/bin/ds)" ]]; then + if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f "$HOME"/bin/ds)" ]]; then info "Attempting to remove $HOME/bin/ds symlink." sudo rm -f "$HOME/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"$HOME/bin/ds\"" fi if [[ ! -L "$HOME/bin/ds" ]]; then info "Creating $HOME/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" $HOME/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" + sudo ln -s -T "${SCRIPTNAME}" "$HOME/bin/ds" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" fi else # /usr/bin/ds From 5c049918d78ff8b3e609ebbec3b04a82adf21582 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 18:53:20 -0500 Subject: [PATCH 07/22] Make this less verbose --- .scripts/package_manager_run.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index 4da9215ca3..020927ebd1 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -14,7 +14,7 @@ package_manager_run() { run_script "pm_yum_${ACTION}" else # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. - echo "Supported package manager not detected. Checking for dependencies ..." + # Define an array of commands commands=("curl" "docker" "docker-compose" "git" "grep" "sed" "whiptail") @@ -26,7 +26,6 @@ package_manager_run() { fi done - echo "All commands are available." fi } From 87be8297be0253e42bb2418536f44227d5108cb6 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:34:05 -0500 Subject: [PATCH 08/22] Ateempt to implement suggestions --- .scripts/package_manager_run.sh | 4 ++-- .scripts/symlink_ds.sh | 42 +++++++++++---------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index 020927ebd1..a4cef7a6e2 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -12,11 +12,11 @@ package_manager_run() { run_script "pm_pacman_${ACTION}" elif [[ -n "$(command -v yum)" ]]; then run_script "pm_yum_${ACTION}" - else + elif [[ "${ACTION}" == "install" ]]; then # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. # Define an array of commands - commands=("curl" "docker" "docker-compose" "git" "grep" "sed" "whiptail") + commands=("curl" "docker" "git" "grep" "sed" "whiptail") # Iterate over each command in the array for cmd in "${commands[@]}"; do diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index b7802f4beb..b01cdc966b 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -6,39 +6,25 @@ symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" if findmnt -n /usr | grep "ro"; then - echo "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin instead. You will need to add this to your path." - mkdir -p "$HOME/bin" # Make sure the path exists. - # $HOME/bin/ds - if [[ -L "$HOME/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f "$HOME"/bin/ds)" ]]; then - info "Attempting to remove $HOME/bin/ds symlink." - sudo rm -f "$HOME/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"$HOME/bin/ds\"" - fi - if [[ ! -L "$HOME/bin/ds" ]]; then - info "Creating $HOME/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" "$HOME/bin/ds" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" $HOME/bin/ds" + if [[ "$PATH" != *"$HOME/bin"* ]]; then + warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi + mkdir -p "$HOME/bin" # Make sure the path exists. + ds_symlink_targets=("HOME/bin") else - # /usr/bin/ds - if [[ -L "/usr/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/bin/ds)" ]]; then - info "Attempting to remove /usr/bin/ds symlink." - sudo rm -f "/usr/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/bin/ds\"" - fi - if [[ ! -L "/usr/bin/ds" ]]; then - info "Creating /usr/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" /usr/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/bin/ds" - fi + ds_symlink_targets=("/usr/bin/ds" "/usr/local/bin/ds") + fi - # /usr/local/bin/ds - if [[ -L "/usr/local/bin/ds" ]] && [[ ${SCRIPTNAME} != "$(readlink -f /usr/local/bin/ds)" ]]; then - info "Attempting to remove /usr/local/bin/ds symlink." - sudo rm -f "/usr/local/bin/ds" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"/usr/local/bin/ds\"" + for target in "${ds_symlink_targets[@]}"; do + if [[ -L "${target}" ]] && [[ "${SCRIPTNAME}" != "$(readlink -f "${target}")" ]]; then + info "Attempting to remove ${target} symlink." + sudo rm -f "${target}" || fatal "Failed to remove file. Failing command: sudo rm -f \"${target}\"" fi - if [[ ! -L "/usr/local/bin/ds" ]]; then - info "Creating /usr/local/bin/ds symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" /usr/local/bin/ds || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" /usr/local/bin/ds" + if [[ ! -L "${target}" ]]; then + info "Creating ${target} symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" "${target}" || fatal "Failed to create symlink. Failing command: sudo ln -s -T \"${SCRIPTNAME}\" \"${target}\"" fi - fi - + done } test_symlink_ds() { From aa8b4694f3adf2117cc1960da331042ba76e012a Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:36:31 -0500 Subject: [PATCH 09/22] fix: unnecessary data was getting output to the console --- .scripts/symlink_ds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index b01cdc966b..ee7de9eb42 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,7 +5,7 @@ IFS=$'\n\t' symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" - if findmnt -n /usr | grep "ro"; then + if findmnt -n /usr | grep "ro" > /dev/null; if [[ "$PATH" != *"$HOME/bin"* ]]; then warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi From a22c74a645a5da457b67987ae7b27c955cb52a81 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:38:19 -0500 Subject: [PATCH 10/22] fix: missing then --- .scripts/symlink_ds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index ee7de9eb42..4fb8419ec3 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,7 +5,7 @@ IFS=$'\n\t' symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" - if findmnt -n /usr | grep "ro" > /dev/null; + if findmnt -n /usr | grep "ro" > /dev/null; then if [[ "$PATH" != *"$HOME/bin"* ]]; then warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi From 341db821505fc91e330dbd47a87d3b87169e8a2d Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:41:00 -0500 Subject: [PATCH 11/22] Add a check for 'docker compose' --- .scripts/package_manager_run.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index a4cef7a6e2..a925afef1b 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -26,6 +26,11 @@ package_manager_run() { fi done + if [[ "$(docker compose 2>&1)" == *"docker: 'compose' is not a docker command."* ]]; then + fatal "The 'docker compose' command is not functional. Follow the directions at https://docs.docker.com/compose/install/linux/ to install compose." + fi + + fi } From 378c6968cd341961e9db52cdd335142c55df3ab3 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:41:18 -0500 Subject: [PATCH 12/22] chore: remove some whitespace --- .scripts/package_manager_run.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index a925afef1b..a8c8ff0e6b 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -29,8 +29,6 @@ package_manager_run() { if [[ "$(docker compose 2>&1)" == *"docker: 'compose' is not a docker command."* ]]; then fatal "The 'docker compose' command is not functional. Follow the directions at https://docs.docker.com/compose/install/linux/ to install compose." fi - - fi } From 97898f24e1db13807999a8e7ddfcf511e9465fa1 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 21:44:15 -0500 Subject: [PATCH 13/22] chore: try to make shfmt happy --- .scripts/package_manager_run.sh | 2 +- .scripts/symlink_ds.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index a8c8ff0e6b..9f94d231df 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -12,7 +12,7 @@ package_manager_run() { run_script "pm_pacman_${ACTION}" elif [[ -n "$(command -v yum)" ]]; then run_script "pm_yum_${ACTION}" - elif [[ "${ACTION}" == "install" ]]; then + elif [[ ${ACTION} == "install" ]]; then # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. # Define an array of commands diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 4fb8419ec3..34b1bd4934 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -6,7 +6,7 @@ symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" if findmnt -n /usr | grep "ro" > /dev/null; then - if [[ "$PATH" != *"$HOME/bin"* ]]; then + if [[ $PATH != *"$HOME/bin"* ]]; then warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi mkdir -p "$HOME/bin" # Make sure the path exists. @@ -16,11 +16,11 @@ symlink_ds() { fi for target in "${ds_symlink_targets[@]}"; do - if [[ -L "${target}" ]] && [[ "${SCRIPTNAME}" != "$(readlink -f "${target}")" ]]; then + if [[ -L ${target} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${target}")" ]]; then info "Attempting to remove ${target} symlink." sudo rm -f "${target}" || fatal "Failed to remove file. Failing command: sudo rm -f \"${target}\"" fi - if [[ ! -L "${target}" ]]; then + if [[ ! -L ${target} ]]; then info "Creating ${target} symbolic link for DockSTARTer." sudo ln -s -T "${SCRIPTNAME}" "${target}" || fatal "Failed to create symlink. Failing command: sudo ln -s -T \"${SCRIPTNAME}\" \"${target}\"" fi From 7ff9e15f4d576775d18800c34a3bb2aa98dcdbf8 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 22:24:00 -0500 Subject: [PATCH 14/22] Implement suggestions --- .scripts/package_manager_run.sh | 8 +++++++- .scripts/symlink_ds.sh | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index 9f94d231df..a6b5db1a50 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -16,7 +16,7 @@ package_manager_run() { # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. # Define an array of commands - commands=("curl" "docker" "git" "grep" "sed" "whiptail") + commands=("curl" "git" "grep" "sed" "whiptail") # Iterate over each command in the array for cmd in "${commands[@]}"; do @@ -25,7 +25,13 @@ package_manager_run() { fatal "Error: '$cmd' is not available. Exiting..." fi done + elif [[ ${ACTION} == "install_docker" ]]; then + # Check for the presence of the docker command + if ! command -v "docker" &> /dev/null; then + fatal "Error: 'docker' is not available. Exiting..." + fi + # If docker warns that compose is not a docker command when we call it, we alert the user they need to take action. if [[ "$(docker compose 2>&1)" == *"docker: 'compose' is not a docker command."* ]]; then fatal "The 'docker compose' command is not functional. Follow the directions at https://docs.docker.com/compose/install/linux/ to install compose." fi diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 34b1bd4934..3b06372b22 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -10,19 +10,19 @@ symlink_ds() { warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi mkdir -p "$HOME/bin" # Make sure the path exists. - ds_symlink_targets=("HOME/bin") + DS_SYMLINK_TARGETS=("HOME/bin") else - ds_symlink_targets=("/usr/bin/ds" "/usr/local/bin/ds") + DS_SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") fi - for target in "${ds_symlink_targets[@]}"; do - if [[ -L ${target} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${target}")" ]]; then - info "Attempting to remove ${target} symlink." - sudo rm -f "${target}" || fatal "Failed to remove file. Failing command: sudo rm -f \"${target}\"" + for DS_SYMLINK_TARGET in "${DS_SYMLINK_TARGETS[@]}"; do + if [[ -L ${DS_SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${target}")" ]]; then + info "Attempting to remove ${DS_SYMLINK_TARGET} symlink." + sudo rm -f "${target}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${target}\"" fi if [[ ! -L ${target} ]]; then info "Creating ${target} symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" "${target}" || fatal "Failed to create symlink. Failing command: sudo ln -s -T \"${SCRIPTNAME}\" \"${target}\"" + sudo ln -s -T "${SCRIPTNAME}" "${target}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${target}\"" fi done } From 20ca452082b95208c1461e07aaeeb5bfa4cdc783 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 22:24:31 -0500 Subject: [PATCH 15/22] fix: swap target to correct control variable --- .scripts/symlink_ds.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 3b06372b22..62f63de1f3 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -18,11 +18,11 @@ symlink_ds() { for DS_SYMLINK_TARGET in "${DS_SYMLINK_TARGETS[@]}"; do if [[ -L ${DS_SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${target}")" ]]; then info "Attempting to remove ${DS_SYMLINK_TARGET} symlink." - sudo rm -f "${target}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${target}\"" + sudo rm -f "${DS_SYMLINK_TARGET}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${DS_SYMLINK_TARGET}\"" fi - if [[ ! -L ${target} ]]; then - info "Creating ${target} symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" "${target}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${target}\"" + if [[ ! -L ${DS_SYMLINK_TARGET} ]]; then + info "Creating ${DS_SYMLINK_TARGET} symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" "${DS_SYMLINK_TARGET}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${DS_SYMLINK_TARGET}\"" fi done } From 61338d0c4894a64b042ed2af83a6daaba56dbcd4 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 22:25:33 -0500 Subject: [PATCH 16/22] fix: Missing $ --- .scripts/symlink_ds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 62f63de1f3..bb88c31b20 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -10,7 +10,7 @@ symlink_ds() { warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." fi mkdir -p "$HOME/bin" # Make sure the path exists. - DS_SYMLINK_TARGETS=("HOME/bin") + DS_SYMLINK_TARGETS=("$HOME/bin") else DS_SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") fi From 6429e808f8c28e226bcd4e51bc7c480484c698a0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 22:26:14 -0500 Subject: [PATCH 17/22] fix: missed one. --- .scripts/symlink_ds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index bb88c31b20..73471acaa2 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -16,7 +16,7 @@ symlink_ds() { fi for DS_SYMLINK_TARGET in "${DS_SYMLINK_TARGETS[@]}"; do - if [[ -L ${DS_SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${target}")" ]]; then + if [[ -L ${DS_SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${DS_SYMLINK_TARGET}")" ]]; then info "Attempting to remove ${DS_SYMLINK_TARGET} symlink." sudo rm -f "${DS_SYMLINK_TARGET}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${DS_SYMLINK_TARGET}\"" fi From a5af01e60ed894405e6c995ed3ea6d36c963dcf4 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 20 Feb 2024 23:29:41 -0500 Subject: [PATCH 18/22] change compose check logic --- .scripts/package_manager_run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index a6b5db1a50..a2161e1e0d 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -32,7 +32,7 @@ package_manager_run() { fi # If docker warns that compose is not a docker command when we call it, we alert the user they need to take action. - if [[ "$(docker compose 2>&1)" == *"docker: 'compose' is not a docker command."* ]]; then + if ! docker compose version > /dev/null 2>&1; then fatal "The 'docker compose' command is not functional. Follow the directions at https://docs.docker.com/compose/install/linux/ to install compose." fi fi From 8c5c21ded5686468e23b2f3ce827bc34309b97f6 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 22 Feb 2024 18:52:12 -0600 Subject: [PATCH 19/22] refactor: :recycle: symlink adjustments Signed-off-by: Eric Nemchik --- .scripts/symlink_ds.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 73471acaa2..e9203c7c7b 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,24 +5,24 @@ IFS=$'\n\t' symlink_ds() { run_script 'set_permissions' "${SCRIPTNAME}" + local SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") + if findmnt -n /usr | grep "ro" > /dev/null; then - if [[ $PATH != *"$HOME/bin"* ]]; then - warn "Read only /usr filesystem detected. Symlinks will be created in $HOME/bin. You will need to add this to your path." + if [[ $PATH != *"${HOME}/bin"* ]]; then + warn "Read only /usr filesystem detected. Symlinks will be created in ${HOME}/bin. You will need to add this to your path." fi - mkdir -p "$HOME/bin" # Make sure the path exists. - DS_SYMLINK_TARGETS=("$HOME/bin") - else - DS_SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") + mkdir -p "${HOME}/bin" # Make sure the path exists. + SYMLINK_TARGETS=("${HOME}/bin") fi - for DS_SYMLINK_TARGET in "${DS_SYMLINK_TARGETS[@]}"; do - if [[ -L ${DS_SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${DS_SYMLINK_TARGET}")" ]]; then - info "Attempting to remove ${DS_SYMLINK_TARGET} symlink." - sudo rm -f "${DS_SYMLINK_TARGET}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${DS_SYMLINK_TARGET}\"" + for SYMLINK_TARGET in "${SYMLINK_TARGETS[@]}"; do + if [[ -L ${SYMLINK_TARGET} ]] && [[ ${SCRIPTNAME} != "$(readlink -f "${SYMLINK_TARGET}")" ]]; then + info "Attempting to remove ${SYMLINK_TARGET} symlink." + sudo rm -f "${SYMLINK_TARGET}" || fatal "Failed to remove file.\nFailing command: ${F[C]}sudo rm -f \"${SYMLINK_TARGET}\"" fi - if [[ ! -L ${DS_SYMLINK_TARGET} ]]; then - info "Creating ${DS_SYMLINK_TARGET} symbolic link for DockSTARTer." - sudo ln -s -T "${SCRIPTNAME}" "${DS_SYMLINK_TARGET}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${DS_SYMLINK_TARGET}\"" + if [[ ! -L ${SYMLINK_TARGET} ]]; then + info "Creating ${SYMLINK_TARGET} symbolic link for DockSTARTer." + sudo ln -s -T "${SCRIPTNAME}" "${SYMLINK_TARGET}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${SYMLINK_TARGET}\"" fi done } From 6ae8a506a2a0e3072542a0e5b7f7ec4f7230eed6 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 22 Feb 2024 19:29:42 -0600 Subject: [PATCH 20/22] refactor: :recycle: pm adjustments Signed-off-by: Eric Nemchik --- .scripts/package_manager_run.sh | 35 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index a2161e1e0d..068f3b637e 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -12,28 +12,21 @@ package_manager_run() { run_script "pm_pacman_${ACTION}" elif [[ -n "$(command -v yum)" ]]; then run_script "pm_yum_${ACTION}" - elif [[ ${ACTION} == "install" ]]; then - # We might not need a supported package manager at all if the dependencies are there already. Let's validate that. - - # Define an array of commands - commands=("curl" "git" "grep" "sed" "whiptail") - - # Iterate over each command in the array - for cmd in "${commands[@]}"; do - # Check if the command is available in the system - if ! command -v "$cmd" &> /dev/null; then - fatal "Error: '$cmd' is not available. Exiting..." + else + if [[ ${ACTION} == "install" ]]; then + local COMMAND_DEPS=("curl" "git" "grep" "sed" "whiptail") + for COMMAND_DEP in "${COMMAND_DEPS[@]}"; do + if ! command -v "${COMMAND_DEP}" &> /dev/null; then + fatal "Error: '${COMMAND_DEP}' is not available. Please install '${COMMAND_DEP}' and try again." + fi + done + elif [[ ${ACTION} == "install_docker" ]]; then + if ! command -v "docker" &> /dev/null; then + fatal "Error: 'docker' is not available. Please install 'docker' and try again." + fi + if ! docker compose version > /dev/null 2>&1; then + fatal "Error: 'docker compose' is not available. Please install 'docker compose' and try again." fi - done - elif [[ ${ACTION} == "install_docker" ]]; then - # Check for the presence of the docker command - if ! command -v "docker" &> /dev/null; then - fatal "Error: 'docker' is not available. Exiting..." - fi - - # If docker warns that compose is not a docker command when we call it, we alert the user they need to take action. - if ! docker compose version > /dev/null 2>&1; then - fatal "The 'docker compose' command is not functional. Follow the directions at https://docs.docker.com/compose/install/linux/ to install compose." fi fi } From 2a8d29c968d9448f42d3ce6cdd04a81b3eea5faf Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 22 Feb 2024 20:04:22 -0600 Subject: [PATCH 21/22] refactor: :recycle: symlink adjustments Signed-off-by: Eric Nemchik --- .scripts/symlink_ds.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index e9203c7c7b..ed9ef28b04 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -7,12 +7,8 @@ symlink_ds() { local SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") - if findmnt -n /usr | grep "ro" > /dev/null; then - if [[ $PATH != *"${HOME}/bin"* ]]; then - warn "Read only /usr filesystem detected. Symlinks will be created in ${HOME}/bin. You will need to add this to your path." - fi - mkdir -p "${HOME}/bin" # Make sure the path exists. - SYMLINK_TARGETS=("${HOME}/bin") + if findmnt -n /usr | grep -P "\bro\b" > /dev/null; then + SYMLINK_TARGETS=("${HOME}/bin/ds" "${HOME}/.local/bin/ds") fi for SYMLINK_TARGET in "${SYMLINK_TARGETS[@]}"; do @@ -22,8 +18,12 @@ symlink_ds() { fi if [[ ! -L ${SYMLINK_TARGET} ]]; then info "Creating ${SYMLINK_TARGET} symbolic link for DockSTARTer." + mkdir -p "$(dirname "${SYMLINK_TARGET}")" || fatal "Failed to create directory.\nFailing command: ${F[C]}mkdir -p \"$(dirname "${SYMLINK_TARGET}")\"" sudo ln -s -T "${SCRIPTNAME}" "${SYMLINK_TARGET}" || fatal "Failed to create symlink.\nFailing command: ${F[C]}sudo ln -s -T \"${SCRIPTNAME}\" \"${SYMLINK_TARGET}\"" fi + if [[ ${PATH} != *"$(dirname "${SYMLINK_TARGET}")"* ]]; then + warn "${F[C]}$(dirname "${SYMLINK_TARGET}")${NC} not found in PATH. Please add it to your PATH in order to use the ${F[C]}ds${NC} command alias." + fi done } From b1dae06371afd43757c30ab8e52bb728bae9f311 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 22 Feb 2024 20:28:04 -0600 Subject: [PATCH 22/22] refactor: :recycle: pm adjustments Signed-off-by: Eric Nemchik --- .scripts/package_manager_run.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index cb0c81067c..f9ca4339a0 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -18,16 +18,17 @@ package_manager_run() { if [[ ${ACTION} == "install" ]]; then local COMMAND_DEPS=("curl" "git" "grep" "sed" "whiptail") for COMMAND_DEP in "${COMMAND_DEPS[@]}"; do - if ! command -v "${COMMAND_DEP}" &> /dev/null; then - fatal "Error: '${COMMAND_DEP}' is not available. Please install '${COMMAND_DEP}' and try again." + if [[ -z "$(command -v "${COMMAND_DEP}")" ]]; then + fatal "${F[C]}${COMMAND_DEP}${NC} is not available. Please install ${F[C]}${COMMAND_DEP}${NC} and try again." fi done elif [[ ${ACTION} == "install_docker" ]]; then - if ! command -v "docker" &> /dev/null; then - fatal "Error: 'docker' is not available. Please install 'docker' and try again." + if [[ -z "$(command -v docker)" ]]; then + fatal "${F[C]}docker${NC} is not available. Please install ${F[C]}docker${NC} and try again." fi if ! docker compose version > /dev/null 2>&1; then - fatal "Error: 'docker compose' is not available. Please install 'docker compose' and try again." + warn "Please see https://docs.docker.com/compose/install/linux/ to install ${F[C]}docker compose${NC}" + fatal "${F[C]}docker compose${NC} is not available. Please install ${F[C]}docker compose${NC} and try again." fi fi fi