Files
Jose Diaz-Gonzalez deeaf6dc41 fix: ensure path exists
2018-10-21 12:50:39 -04:00

55 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
scheduler-docker-local-install() {
declare desc="scheduler-docker-local install plugin trigger"
declare trigger="scheduler-docker-local-install"
local DOKKU_PATH
mkdir -p "${DOKKU_LIB_ROOT}/data/scheduler-docker-local"
chown -R "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "${DOKKU_LIB_ROOT}/data/scheduler-docker-local"
fn-plugin-property-setup "scheduler-docker-local"
DOKKU_PATH="$(which dokku)"
if [[ $(systemctl 2> /dev/null) =~ -\.mount ]]; then
cat<<EOF > /etc/systemd/system/dokku-retire.service
[Unit]
Description=Dokku retire service
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
User=$DOKKU_SYSTEM_USER
ExecStart=$DOKKU_PATH ps:restore
[Install]
WantedBy=docker.service
EOF
cat<<EOF > /etc/systemd/system/dokku-retire.timer
[Unit]
Description=Run dokku-retire.service every 2 minutes
[Timer]
OnCalendar=*:0/2
EOF
if command -v systemctl &>/dev/null; then
systemctl reenable dokku-redeploy
fi
else
cat<<EOF > /etc/cron.d/dokku-retire
PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash
2 * * * * $DOKKU_SYSTEM_USER $DOKKU_PATH ps:retire
EOF
fi
}
scheduler-docker-local-install "$@"