diff options
Diffstat (limited to 'dokku.install')
-rw-r--r-- | dokku.install | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/dokku.install b/dokku.install index 4fd781f7e392..86b8aa5263fa 100644 --- a/dokku.install +++ b/dokku.install @@ -1,12 +1,24 @@ #!/bin/bash +set -eo pipefail +[[ $TRACE ]] && set -x + readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" readonly DOKKU_LOGS_DIR="${DOKKU_LOGS_DIR:-/var/log/dokku}" +call-sshcommand() { + if [[ -x /usr/bin/sshcommand ]]; then + /usr/bin/sshcommand "$@" + else + echo "Unable to find sshcommand binary" 1>&2 + exit 1 + fi +} + setup-user() { echo "Setting up dokku user" - /usr/bin/sshcommand create dokku /usr/bin/dokku - (grep -i -E "^docker" /etc/group || groupadd docker) &>/dev/null + call-sshcommand create dokku /usr/bin/dokku + grep -i -E "^docker" /etc/group || groupadd docker usermod -aG docker dokku mkdir -p "${DOKKU_ROOT}/.ssh" "${DOKKU_ROOT}/.dokkurc" touch "${DOKKU_ROOT}/.ssh/authorized_keys" @@ -20,7 +32,22 @@ setup-storage() { } setup-plugins() { + echo "Deleting invalid plugins" + if [ -f "${DOKKU_LIB_ROOT}/core-plugins/available/" ]; then + find "${DOKKU_LIB_ROOT}/core-plugins/available/" -type d -empty -delete + fi + if [ -f "${DOKKU_LIB_ROOT}/core-plugins/enabled/" ]; then + find "${DOKKU_LIB_ROOT}/core-plugins/enabled/" -type d -empty -delete + fi + if [ -f "${DOKKU_LIB_ROOT}/plugins/available/" ]; then + find "${DOKKU_LIB_ROOT}/plugins/available/" -type d -empty -delete + fi + if [ -f "${DOKKU_LIB_ROOT}/plugins/enabled/" ]; then + find "${DOKKU_LIB_ROOT}/plugins/enabled/" -type d -empty -delete + fi + echo "Setting up 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" @@ -44,14 +71,17 @@ setup-plugins() { PLUGIN_PATH="${DOKKU_LIB_ROOT}/plugins" plugn enable "${plugin}" fi done - find -L "${DOKKU_LIB_ROOT}" -type l -delete + find -L "${DOKKU_LIB_ROOT}/core-plugins" -type l -delete + find -L "${DOKKU_LIB_ROOT}/plugins" -type l -delete chown dokku:dokku -R "${DOKKU_LIB_ROOT}/plugins" "${DOKKU_LIB_ROOT}/core-plugins" echo "Install all core plugins" - # dokku plugin:install-dependencies --core # Disabled since not usefull and pacman lock error - dokku plugin:install --core - rm -f /etc/update-motd.d/99-dokku + echo -e "#!/bin/sh\\n\\n~/.basher/bash -l \$@" > /tmp/login-basher + chmod +x /tmp/login-basher + BASH_BIN=/tmp/login-basher dokku plugin:install --core + rm /tmp/login-basher + rm -f /etc/update-motd.d/99-dokku sed -i 's/ syslog dokku$/ root dokku/g' /etc/logrotate.d/dokku } @@ -70,16 +100,12 @@ post_install() { setup-plugins setup-sshcommand - echo "Update version file" - rm -f "${DOKKU_ROOT}/VERSION" - cp "${DOKKU_LIB_ROOT}/VERSION" "${DOKKU_ROOT}/VERSION" - - echo "Update hostname" - hostname -f > "${DOKKU_ROOT}/HOSTNAME" - echo " - Please add your ssh pubkey like: - $ cat ~/.ssh/id_rsa.pub | sudo sshcommand acl-add dokku default + If using virtualhost routing is desired (eg. my-app => my-app.dokku.me), set a global domain for your server: + $ dokku domains:set-global dokku.me + + Setup a user's ssh key for deployment by passing in the public ssh key as shown: + $ echo 'CONTENTS_OF_ID_RSA_PUB_FILE' | dokku ssh-keys:add admin To enable nginx autoconfiguration, add to your /etc/nginx/nginx.conf in http section: include /etc/nginx/conf.d/*.conf; @@ -94,10 +120,20 @@ post_upgrade() { pre_remove() { echo "Destroying deployed applications" - for app in $(DOKKU_QUIET_OUTPUT=1 dokku apps); do + for app in $(DOKKU_QUIET_OUTPUT=1 dokku apps:list); do dokku --force apps:destroy "${app}" done + # HACK: Only disable core plugins, as we don't know what data users store in non-core plugin directories + echo "Disabling 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 + rm "${DOKKU_LIB_ROOT}/plugins/available/${plugin}" + PLUGIN_PATH=${DOKKU_LIB_ROOT}/core-plugins plugn disable "${plugin}" + PLUGIN_PATH=${DOKKU_LIB_ROOT}/plugins plugn disable "${plugin}" + fi + done + dokku cleanup } @@ -116,7 +152,7 @@ post_remove() { rm -rf "${DOKKU_LOGS_DIR}" # Remove dokku user and group - userdel -r dokku &>/dev/null + userdel -r dokku || true groupdel dokku &>/dev/null echo " |