#!/bin/sh set -e . /usr/share/debconf/confmodule readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" case "$1" in abort-upgrade|abort-remove|abort-deconfigure) ;; configure) mandb [ ! -x /usr/bin/docker.io ] || ln -sf /usr/bin/docker.io /usr/local/bin/docker modprobe aufs || echo "WARNING: Restart server to finish installing dokku!" sshcommand create dokku /usr/local/bin/dokku egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku # setup plugin directories # should be replaced by `plugn init` mkdir -p ${DOKKU_LIB_ROOT}/core-plugins/available ${DOKKU_LIB_ROOT}/plugins/available mkdir -p ${DOKKU_LIB_ROOT}/core-plugins/enabled ${DOKKU_LIB_ROOT}/plugins/enabled touch ${DOKKU_LIB_ROOT}/core-plugins/config.toml ${DOKKU_LIB_ROOT}/plugins/config.toml # migrate old plugins find ${DOKKU_LIB_ROOT}/plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do if [ "$plugin" = "available" ] || [ "$plugin" = "enabled" ]; then continue elif [ -f ${DOKKU_LIB_ROOT}/plugins/$plugin/.core ]; then rm -rf ${DOKKU_LIB_ROOT}/plugins/$plugin elif [ ! -d ${DOKKU_LIB_ROOT}/plugins/available/$plugin ]; then mv ${DOKKU_LIB_ROOT}/plugins/$plugin ${DOKKU_LIB_ROOT}/plugins/available; fi done # enable all core plugins find ${DOKKU_LIB_ROOT}/core-plugins/available -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do if [ ! -d ${DOKKU_LIB_ROOT}/plugins/available/$plugin ]; then ln -s ${DOKKU_LIB_ROOT}/core-plugins/available/$plugin ${DOKKU_LIB_ROOT}/plugins/available/$plugin; PLUGIN_PATH=${DOKKU_LIB_ROOT}/core-plugins plugn enable $plugin PLUGIN_PATH=${DOKKU_LIB_ROOT}/plugins plugn enable $plugin fi done chown dokku:dokku -R ${DOKKU_LIB_ROOT}/plugins ${DOKKU_LIB_ROOT}/core-plugins dokku plugin:install --core rm -f ${DOKKU_ROOT}/VERSION cp ${DOKKU_LIB_ROOT}/STABLE_VERSION ${DOKKU_ROOT}/VERSION if [ -f /etc/init/dokku-installer.conf ] && service dokku-installer status 2> /dev/null | grep waiting; then sudo service dokku-installer start fi db_get "dokku/web_config" if [ "$RET" = "true" ]; then exit 0 fi db_get "dokku/vhost_enable" if [ "$RET" = "true" ]; then db_get "dokku/hostname" echo "$RET" > "${DOKKU_ROOT}/VHOST" else rm -f "${DOKKU_ROOT}/VHOST" fi db_get "dokku/hostname" echo "$RET" > "${DOKKU_ROOT}/HOSTNAME" if [ -z "${DEBCONF_RECONFIGURE}" ]; then db_get "dokku/key_file" if [ -f "$RET" ]; then sshcommand acl-add dokku default < "$RET" fi fi ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac exit 0