diff --git a/.scripts/package_manager_run.sh b/.scripts/package_manager_run.sh index fb3bdba010..f9ca4339a0 100644 --- a/.scripts/package_manager_run.sh +++ b/.scripts/package_manager_run.sh @@ -15,7 +15,22 @@ package_manager_run() { elif [[ -n "$(command -v yum)" ]]; then run_script "pm_yum_${ACTION}" else - fatal "Supported package manager not detected!" + if [[ ${ACTION} == "install" ]]; then + local COMMAND_DEPS=("curl" "git" "grep" "sed" "whiptail") + for COMMAND_DEP in "${COMMAND_DEPS[@]}"; do + 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 [[ -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 + 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 } diff --git a/.scripts/symlink_ds.sh b/.scripts/symlink_ds.sh index 9803d3d205..ed9ef28b04 100644 --- a/.scripts/symlink_ds.sh +++ b/.scripts/symlink_ds.sh @@ -5,25 +5,26 @@ 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" - fi + local SYMLINK_TARGETS=("/usr/bin/ds" "/usr/local/bin/ds") - # /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" + 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 + 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 ${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 } test_symlink_ds() {