Skip to content

Commit

Permalink
add arch support (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ns2Kracy authored Nov 29, 2022
1 parent a0f8518 commit db3b632
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

readonly APP_NAME="casaos-message-bus"
readonly APP_NAME_SHORT="message-bus"

# copy config files
readonly CONF_PATH=/etc/casaos
readonly CONF_FILE=${CONF_PATH}/${APP_NAME_SHORT}.conf
readonly CONF_FILE_SAMPLE=${CONF_PATH}/${APP_NAME_SHORT}.conf.sample

if [ ! -f "${CONF_FILE}" ]; then \
echo "Initializing config file..."
cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"; \
fi

systemctl daemon-reload

# enable service (without starting)
echo "Enabling service..."
systemctl enable --force --no-ask-password "${APP_NAME}.service"
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

set -e

readonly CASA_SERVICES=(
"casaos-message-bus.service"
)

readonly CASA_EXEC=casaos-message-bus
readonly CASA_CONF=/etc/casaos/message-bus.conf
readonly CASA_DB=/var/lib/casaos/db/message-bus.db

readonly aCOLOUR=(
'\e[38;5;154m' # green | Lines, bullets and separators
'\e[1m' # Bold white | Main descriptions
'\e[90m' # Grey | Credits
'\e[91m' # Red | Update notifications Alert
'\e[33m' # Yellow | Emphasis
)

Show() {
# OK
if (($1 == 0)); then
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
# FAILED
elif (($1 == 1)); then
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
# INFO
elif (($1 == 2)); then
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
# NOTICE
elif (($1 == 3)); then
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
fi
}

Warn() {
echo -e "${aCOLOUR[3]}$1$COLOUR_RESET"
}

trap 'onCtrlC' INT
onCtrlC() {
echo -e "${COLOUR_RESET}"
exit 1
}

if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then
Show 2 "${CASA_EXEC} is not detected, exit the script."
exit 1
fi

while true; do
echo -n -e " ${aCOLOUR[4]}Do you want delete message bus database? Y/n :${COLOUR_RESET}"
read -r input
case $input in
[yY][eE][sS] | [yY])
REMOVE_LOCAL_STORAGE_DATABASE=true
break
;;
[nN][oO] | [nN])
REMOVE_LOCAL_STORAGE_DATABASE=false
break
;;
*)
Warn " Invalid input..."
;;
esac
done

for SERVICE in "${CASA_SERVICES[@]}"; do
Show 2 "Stopping ${SERVICE}..."
systemctl disable --now "${SERVICE}" || Show 3 "Failed to disable ${SERVICE}"
done

rm -rvf "$(which ${CASA_EXEC})" || Show 3 "Failed to remove ${CASA_EXEC}"
rm -rvf "${CASA_CONF}" || Show 3 "Failed to remove ${CASA_CONF}"

if [[ ${REMOVE_LOCAL_STORAGE_DATABASE} == true ]]; then
rm -rvf "${CASA_DB}" || Show 3 "Failed to remove ${CASA_DB}"
fi

0 comments on commit db3b632

Please sign in to comment.