Files
directus/abra.sh
2026-01-08 16:10:12 +01:00

64 lines
2.1 KiB
Bash
Executable File

# Set any config versions here
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
export DIRECTUS_ENTRYPOINT_VERSION=v4
export PG_BACKUP_VERSION=v1
# essentially a wrapper for directus-template-cli apply:
# https://github.com/directus-labs/directus-template-cli
apply_community_template () {
echo "This will apply one of the community templates to your directus installation."
echo "Checkout existing templates here: https://github.com/directus-labs/directus-templates"
echo "\"CMS\" is proably what you want, there exist others, e.g. \"Simple CRM\", for others checkout github-repo and look in the package.json for \"templateName\""
echo -n "Enter template name (e.g. \"CMS\"): "
read template
if [ -z "$template" ]; then
echo "You need to define a template" >&2
return 1
fi
echo "\n will try to apply template \"$template\". "
read -p "Proceed? (y/n): " proceed
if [ "$proceed" != "y" ]; then
echo "Aborting."
return 1
fi
npx --yes directus-template-cli@latest apply -p \
--directusUrl=https://$DOMAIN \
--userEmail=$ADMIN_EMAIL \
--userPassword=$(cat /var/run/secrets/admin_password) \
--templateLocation="$template" \
--templateType="community"
return 0
}
# run locally!
# essentially a wrapper for directus-template-cli extract:
# https://github.com/directus-labs/directus-template-cli
extract_template (){
TEMPLATE_LOCATION="./directus-template"
TEMPLATE_NAME="directus-template"
echo "script extracts your current directus settings (includes data!) and saves it with the template name \"$TEMPLATE_NAME\" to the folder \"$TEMPLATE_LOCATION\""
ADMIN_PASSWORD=$(abra app run -t $DOMAIN app -- cat /var/run/secrets/admin_password)
npx --yes directus-template-cli@latest extract -p \
--directusUrl=https://$DOMAIN \
--userEmail=$ADMIN_EMAIL \
--userPassword=$ADMIN_PASSWORD \
--templateLocation="$TEMPLATE_LOCATION" \
--templateName="$TEMPLATE_NAME"
ADMIN_PASSWORD=""
TEMPLATE_LOCATION=""
TEMPLATE_NAME=""
return 0
}