Merge pull request #3636 from dokku/refactor-deb-install

Unify deb and rpm creation code
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2019-08-10 14:29:29 -04:00
commit c9bc4f8615
2 files changed
+61 -33

No files matched your search

+54 -29
View File
@@ -26,31 +26,28 @@ call-sshcommand() {
fi fi
} }
case "$1" in setup-user() {
abort-upgrade | abort-remove | abort-deconfigure) ;; echo "Setting up dokku user"
\
configure)
mandb
[ ! -x /usr/bin/docker.io ] || ln -sf /usr/bin/docker.io /usr/local/bin/docker
if [[ -f /sbin/modprobe ]]; then
modprobe aufs || echo "WARNING: Restart server to finish installing dokku!"
fi
call-sshcommand create dokku /usr/bin/dokku call-sshcommand create dokku /usr/bin/dokku
egrep -i "^docker" /etc/group || groupadd docker egrep -i "^docker" /etc/group || groupadd docker
usermod -aG docker dokku usermod -aG docker dokku
mkdir -p ${DOKKU_ROOT}/.dokkurc mkdir -p "$DOKKU_ROOT/.ssh" "$DOKKU_ROOT/.dokkurc"
touch "$DOKKU_ROOT/.ssh/authorized_keys"
chown -R dokku:dokku "$DOKKU_ROOT/.ssh" "${DOKKU_ROOT}/.dokkurc"
}
setup-storage() {
echo "Setting up storage directories" echo "Setting up storage directories"
mkdir -p ${DOKKU_LIB_ROOT}/data ${DOKKU_LIB_ROOT}/data/storage mkdir -p "${DOKKU_LIB_ROOT}/data" "${DOKKU_LIB_ROOT}/data/storage"
chown dokku:dokku ${DOKKU_LIB_ROOT}/data ${DOKKU_LIB_ROOT}/data/storage chown dokku:dokku "${DOKKU_LIB_ROOT}/data"
}
setup-plugins() {
echo "Setting up plugin directories" echo "Setting up plugin directories"
# should be replaced by `plugn init` # 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/available" "${DOKKU_LIB_ROOT}/plugins/available"
mkdir -p ${DOKKU_LIB_ROOT}/core-plugins/enabled ${DOKKU_LIB_ROOT}/plugins/enabled 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 touch "${DOKKU_LIB_ROOT}/core-plugins/config.toml" "${DOKKU_LIB_ROOT}/plugins/config.toml"
echo "Migrating old plugins" echo "Migrating old plugins"
find ${DOKKU_LIB_ROOT}/plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do find ${DOKKU_LIB_ROOT}/plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do
@@ -65,32 +62,38 @@ case "$1" in
db_get "dokku/nginx_enable" db_get "dokku/nginx_enable"
echo "Enabling all core plugins" echo "Enabling all core plugins"
find ${DOKKU_LIB_ROOT}/core-plugins/available -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do find "${DOKKU_LIB_ROOT}/core-plugins/available" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do
if [ "$plugin" = "nginx-vhosts" ] && [ "$RET" = "false" ]; then if [ "$plugin" = "nginx-vhosts" ] && [ "$RET" = "false" ]; then
echo "Skipping enable of nginx-vhosts plugin" echo "Skipping enable of nginx-vhosts plugin"
continue continue
elif [ ! -d ${DOKKU_LIB_ROOT}/plugins/available/$plugin ]; then elif [ ! -d "${DOKKU_LIB_ROOT}/plugins/available/$plugin" ]; then
ln -s ${DOKKU_LIB_ROOT}/core-plugins/available/$plugin ${DOKKU_LIB_ROOT}/plugins/available/$plugin 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}/core-plugins" plugn enable "$plugin"
PLUGIN_PATH=${DOKKU_LIB_ROOT}/plugins plugn enable $plugin PLUGIN_PATH="${DOKKU_LIB_ROOT}/plugins" plugn enable "$plugin"
fi fi
done done
find -L ${DOKKU_LIB_ROOT} -type l -delete find -L "${DOKKU_LIB_ROOT}" -type l -delete
chown dokku:dokku -R ${DOKKU_LIB_ROOT}/plugins ${DOKKU_LIB_ROOT}/core-plugins chown dokku:dokku -R "${DOKKU_LIB_ROOT}/plugins" "${DOKKU_LIB_ROOT}/core-plugins"
echo "Install all core plugins"
dokku plugin:install --core
}
setup-sshcommand() {
echo "Ensure proper sshcommand path" echo "Ensure proper sshcommand path"
echo '/usr/bin/dokku' >"${DOKKU_ROOT}/.sshcommand" echo '/usr/bin/dokku' >"${DOKKU_ROOT}/.sshcommand"
if [[ -f .ssh/authorized_keys ]]; then if [[ -f .ssh/authorized_keys ]]; then
sed -i.bak 's#/usr/local/bin/dokku#/usr/bin/dokku#' "${DOKKU_ROOT}/.ssh/authorized_keys" sed -i.bak 's#/usr/local/bin/dokku#/usr/bin/dokku#' "${DOKKU_ROOT}/.ssh/authorized_keys"
rm "${DOKKU_ROOT}/.ssh/authorized_keys" rm "${DOKKU_ROOT}/.ssh/authorized_keys"
fi fi
}
echo "Install all core plugins" setup-version() {
dokku plugin:install --core rm -f "${DOKKU_ROOT}/VERSION"
cp "${DOKKU_LIB_ROOT}/STABLE_VERSION" "${DOKKU_ROOT}/VERSION"
rm -f ${DOKKU_ROOT}/VERSION }
cp ${DOKKU_LIB_ROOT}/STABLE_VERSION ${DOKKU_ROOT}/VERSION
setup-dokku-installer() {
if [[ -f /etc/nginx/conf.d/dokku-installer.conf ]]; then if [[ -f /etc/nginx/conf.d/dokku-installer.conf ]]; then
echo "Setting up dokku-installer" echo "Setting up dokku-installer"
/usr/share/dokku/contrib/dokku-installer.py onboot /usr/share/dokku/contrib/dokku-installer.py onboot
@@ -106,7 +109,9 @@ case "$1" in
service dokku-installer start || echo "Unable to start dokku-installer" service dokku-installer start || echo "Unable to start dokku-installer"
fi fi
fi fi
}
dpkg-handling() {
db_get "dokku/web_config" db_get "dokku/web_config"
if [ "$RET" = "true" ]; then if [ "$RET" = "true" ]; then
db_stop db_stop
@@ -133,6 +138,26 @@ case "$1" in
call-sshcommand acl-add dokku default <"$RET" || true call-sshcommand acl-add dokku default <"$RET" || true
fi fi
fi fi
}
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
if [[ -f /sbin/modprobe ]]; then
modprobe aufs || echo "WARNING: Restart server to finish installing dokku!"
fi
setup-user
setup-storage
setup-plugins
setup-sshcommand
setup-version
setup-dokku-installer
dpkg-handling
;; ;;
*) *)
+7 -4
View File
@@ -5,11 +5,10 @@ set -eo pipefail; [[ $TRACE ]] && set -x
setup-user() { setup-user() {
echo "Setting up dokku user" echo "Setting up dokku user"
getent passwd dokku >/dev/null || useradd -m -s /bin/bash dokku getent passwd dokku >/dev/null || useradd -m -s /bin/bash dokku
mkdir -p "$DOKKU_ROOT/.ssh"
touch "$DOKKU_ROOT/.ssh/authorized_keys"
chown -R dokku:dokku "$DOKKU_ROOT/.ssh"
usermod -aG docker dokku usermod -aG docker dokku
mkdir -p "$DOKKU_ROOT/.dokkurc" mkdir -p "$DOKKU_ROOT/.ssh" "$DOKKU_ROOT/.dokkurc"
touch "$DOKKU_ROOT/.ssh/authorized_keys"
chown -R dokku:dokku "$DOKKU_ROOT/.ssh" "${DOKKU_ROOT}/.dokkurc"
} }
setup-storage() { setup-storage() {
@@ -43,6 +42,10 @@ setup-plugins() {
setup-sshcommand() { setup-sshcommand() {
echo "Ensure proper sshcommand path" echo "Ensure proper sshcommand path"
echo '/usr/bin/dokku' >"${DOKKU_ROOT}/.sshcommand" echo '/usr/bin/dokku' >"${DOKKU_ROOT}/.sshcommand"
if [[ -f .ssh/authorized_keys ]]; then
sed -i.bak 's#/usr/local/bin/dokku#/usr/bin/dokku#' "${DOKKU_ROOT}/.ssh/authorized_keys"
rm "${DOKKU_ROOT}/.ssh/authorized_keys"
fi
} }
setup-version() { setup-version() {