You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
# -*- mode: shell-script -*-
|
|
|
|
NTFY_CONFIGFILE="$SERVICE_CONFIGSTORE/etc/ntfy/server.yml"
|
|
NTFY_FIREBASE_KEYFILE="$SERVICE_CONFIGSTORE/etc/ntfy/firebase-key.json"
|
|
|
|
ntfy:init() {
|
|
service_def=$(get_compose_service_def "$SERVICE_NAME")
|
|
options=$(e "$service_def" | yq e '.options' -)
|
|
|
|
mkdir -p "${NTFY_CONFIGFILE%/*}" || {
|
|
err "failed to create directory ${NTFY_CONFIGFILE%/*}"
|
|
exit 1
|
|
}
|
|
|
|
## Ensure 'firebase-key-file' was not set in '$options'
|
|
if yq e -e '.firebase-key-file' <<< "$options" >/dev/null; then
|
|
err "${WHITE}firebase-key-file${NORMAL} should not be" \
|
|
"specified in ${DARKYELLOW}$SERVICE_NAME${NORMAL}'s options"
|
|
exit 1
|
|
fi
|
|
|
|
## if 'firebase' is set
|
|
if firebase_key=$(yq e -e '.firebase' 2>/dev/null <<< "$options"); then
|
|
## set 'firebase-key-file' in '$options'
|
|
options=$(yq e '.firebase-key-file = "/etc/ntfy/firebase-key.json"' <<< "$options") || {
|
|
err "failed to set firebase-key-file in options"
|
|
exit 1
|
|
}
|
|
umask 077
|
|
## store content of $firebase_key in json format in '$NTFY_FIREBASE_KEYFILE'
|
|
e "$firebase_key" | yq -p yaml -o json . > "$NTFY_FIREBASE_KEYFILE" || {
|
|
err "failed to store firebase-key-file"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
e "$options" > "$NTFY_CONFIGFILE" || {
|
|
err "failed to store ntfy config"
|
|
exit 1
|
|
}
|
|
|
|
}
|
|
|
|
ntfy:config() {
|
|
local cmd="$1"
|
|
yq e "$1" -i "$NTFY_CONFIGFILE"
|
|
}
|