pleroma-docker/pleroma

85 lines
1.9 KiB
Plaintext
Raw Normal View History

2018-04-08 16:49:07 -04:00
#!/bin/bash
set -e
flags=""
2018-04-08 16:49:07 -04:00
print_help() {
2018-04-08 16:49:07 -04:00
echo "
Pleroma Maintenance Script
Usage:
$0 [action]
2018-04-08 16:49:07 -04:00
Actions:
build Rebuild the pleroma container
2018-04-08 16:49:07 -04:00
purge Remove the pleroma container and all build caches
2018-04-08 16:49:07 -04:00
start / up Start pleroma and sibling services
2018-04-08 16:49:07 -04:00
stop / down Stop pleroma and sibling services
restart Executes #stop and #start respectively.
status / ps Show the current container status
2018-04-08 16:49:07 -04:00
logs Show the current container logs
enter Enter the pleroma container for debugging/maintenance
"
2018-04-08 16:49:07 -04:00
}
render_template() {
m4 $flags docker-compose.m4 | awk 'NF'
2018-04-08 16:49:07 -04:00
}
docker_compose() {
render_template | docker-compose -f - "$@"
2018-04-08 16:49:07 -04:00
}
load_env() {
if [[ ! -f .env ]]; then
echo "Please create a .env file first"
echo "(Copy .env.dist to .env for a template)"
exit 1
fi
while read -r line; do
if [[ "$line" == \#* ]] || [[ -z "$line" ]]; then
continue;
fi
export "${line?}"
flags="-D__${line?} $flags"
done < .env
2018-04-08 16:49:07 -04:00
}
action__start() { docker_compose up --remove-orphans -d; }
action__up() { action__start; }
action__stop() { docker_compose down; }
action__down() { action__stop; }
action__restart() { action__stop; action__start; }
action__logs() { docker_compose logs -f; }
action__build() { docker_compose build --build-arg __BUST_CACHE="$(date +%s)" server; }
action__enter() { docker_compose exec server ash; }
action__status() { docker_compose ps; }
action__ps() { action__status; }
action__debug() { render_template; }
action__lint() { render_template | jq; }
2018-04-08 16:49:07 -04:00
if [[ -z "$1" ]]; then
print_help
exit 1
fi
load_env
actions=(build update purge start up stop down restart logs enter status ps debug lint)
if [[ ${actions[*]} =~ ${1} ]]; then
"action__${1}"
else
2018-04-08 16:49:07 -04:00
print_help
exit 1
fi