Skip to content

Commit

Permalink
Merge pull request #1732 from GhostWriters/os-support
Browse files Browse the repository at this point in the history
OS support
  • Loading branch information
nemchik authored Feb 23, 2024
2 parents 074fe3c + b1dae06 commit eb0a2e0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
17 changes: 16 additions & 1 deletion .scripts/package_manager_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
35 changes: 18 additions & 17 deletions .scripts/symlink_ds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit eb0a2e0

Please sign in to comment.