-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
build/scripts/setup/service.d/message-bus/arch/setup-message-bus.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
80 changes: 80 additions & 0 deletions
80
build/sysroot/usr/share/casaos/cleanup/service.d/message-bus/arch/cleanup-message-bus.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |