mirror of
https://github.com/dokku/dokku.git
synced 2025-12-16 12:07:45 +01:00
Plugins management
We had an issue with third party plugins installing things via apt while already installing dokku itself via apt. To resolve this, `plugins-install` and `plugins-install-dependencies` now can take a `--core` flag allowing to execute the install hook only on core plugins and not on third party plugins. Another feature with this modification is the ability to disable/enable plugins. Two new commands now exist: * `plugins:enable <name>` to enable a previously disabled plugin * `plugins:disable <name>` to disable an installed plugin. This won’t work on core plugins.
This commit is contained in:
committed by
Jose Diaz-Gonzalez
parent
48c6460b45
commit
ac75c726ad
21
Makefile
21
Makefile
@@ -4,7 +4,10 @@ SSHCOMMAND_URL ?= https://raw.github.com/progrium/sshcommand/master/sshcommand
|
|||||||
PLUGINHOOK_URL ?= https://s3.amazonaws.com/progrium-pluginhook/pluginhook_0.1.0_amd64.deb
|
PLUGINHOOK_URL ?= https://s3.amazonaws.com/progrium-pluginhook/pluginhook_0.1.0_amd64.deb
|
||||||
STACK_URL ?= https://github.com/gliderlabs/herokuish.git
|
STACK_URL ?= https://github.com/gliderlabs/herokuish.git
|
||||||
PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest
|
PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest
|
||||||
PLUGINS_PATH ?= /var/lib/dokku/plugins
|
DOKKU_LIB_ROOT ?= /var/lib/dokku
|
||||||
|
PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/plugins
|
||||||
|
CORE_PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/core-plugins
|
||||||
|
DISABLED_PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/disabled-plugins
|
||||||
|
|
||||||
# If the first argument is "vagrant-dokku"...
|
# If the first argument is "vagrant-dokku"...
|
||||||
ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS)))
|
ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS)))
|
||||||
@@ -44,13 +47,15 @@ packer:
|
|||||||
|
|
||||||
copyfiles:
|
copyfiles:
|
||||||
cp dokku /usr/local/bin/dokku
|
cp dokku /usr/local/bin/dokku
|
||||||
mkdir -p ${PLUGINS_PATH}
|
mkdir -p ${CORE_PLUGINS_PATH} ${PLUGINS_PATH} ${DISABLED_PLUGINS_PATH}
|
||||||
find ${PLUGINS_PATH} -mindepth 2 -maxdepth 2 -name '.core' -printf '%h\0' | xargs -0 rm -Rf
|
rm -rf ${CORE_PLUGINS_PATH}/*
|
||||||
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \
|
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \
|
||||||
rm -Rf ${PLUGINS_PATH}/$$plugin && \
|
rm -Rf ${CORE_PLUGINS_PATH}/$$plugin && \
|
||||||
cp -R plugins/$$plugin ${PLUGINS_PATH} && \
|
rm -rf ${PLUGINS_PATH}/$$plugin && \
|
||||||
touch ${PLUGINS_PATH}/$$plugin/.core; \
|
cp -R plugins/$$plugin ${CORE_PLUGINS_PATH} && \
|
||||||
|
ln -s ${CORE_PLUGINS_PATH}/$$plugin ${PLUGINS_PATH}; \
|
||||||
done
|
done
|
||||||
|
chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} ${DISABLED_PLUGINS_PATH}
|
||||||
$(MAKE) addman
|
$(MAKE) addman
|
||||||
|
|
||||||
addman:
|
addman:
|
||||||
@@ -62,10 +67,10 @@ version:
|
|||||||
git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION
|
git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION
|
||||||
|
|
||||||
plugin-dependencies: pluginhook
|
plugin-dependencies: pluginhook
|
||||||
dokku plugins-install-dependencies
|
dokku plugins-install-dependencies --core
|
||||||
|
|
||||||
plugins: pluginhook docker
|
plugins: pluginhook docker
|
||||||
dokku plugins-install
|
dokku plugins-install --core
|
||||||
|
|
||||||
dependencies: apt-update sshcommand pluginhook docker help2man man-db
|
dependencies: apt-update sshcommand pluginhook docker help2man man-db
|
||||||
$(MAKE) -e stack
|
$(MAKE) -e stack
|
||||||
|
|||||||
2
debian/postinst
vendored
2
debian/postinst
vendored
@@ -16,7 +16,7 @@ case "$1" in
|
|||||||
sshcommand create dokku /usr/local/bin/dokku
|
sshcommand create dokku /usr/local/bin/dokku
|
||||||
egrep -i "^docker" /etc/group || groupadd docker
|
egrep -i "^docker" /etc/group || groupadd docker
|
||||||
usermod -aG docker dokku
|
usermod -aG docker dokku
|
||||||
dokku plugins-install
|
dokku plugins-install --core
|
||||||
rm -f /home/dokku/VERSION
|
rm -f /home/dokku/VERSION
|
||||||
cp /var/lib/dokku/STABLE_VERSION /home/dokku/VERSION
|
cp /var/lib/dokku/STABLE_VERSION /home/dokku/VERSION
|
||||||
|
|
||||||
|
|||||||
37
dokku
37
dokku
@@ -5,8 +5,11 @@ shopt -s nullglob
|
|||||||
export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"}
|
export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"}
|
||||||
export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish"}
|
export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish"}
|
||||||
export DOKKU_ROOT=${DOKKU_ROOT:=~dokku}
|
export DOKKU_ROOT=${DOKKU_ROOT:=~dokku}
|
||||||
|
export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"}
|
||||||
|
|
||||||
export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
|
export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"}
|
||||||
|
export PLUGIN_CORE_PATH=${PLUGIN_CORE_PATH:="$DOKKU_LIB_ROOT/core-plugins"}
|
||||||
|
export PLUGIN_DISABLED_PATH=${PLUGIN_DISABLED_PATH:="$DOKKU_LIB_ROOT/disabled-plugins"}
|
||||||
export DOKKU_NOT_IMPLEMENTED_EXIT=10
|
export DOKKU_NOT_IMPLEMENTED_EXIT=10
|
||||||
export DOKKU_VALID_EXIT=0
|
export DOKKU_VALID_EXIT=0
|
||||||
|
|
||||||
@@ -199,14 +202,22 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
plugins)
|
plugins)
|
||||||
ls -1 -d $PLUGIN_PATH/*/
|
for plugin in "$PLUGIN_PATH"/*/; do
|
||||||
|
basename "$plugin"
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
plugins-install)
|
plugins-install)
|
||||||
|
if [[ $2 == "--core" ]]; then
|
||||||
|
export PLUGIN_PATH="$PLUGIN_CORE_PATH"
|
||||||
|
fi
|
||||||
pluginhook install
|
pluginhook install
|
||||||
;;
|
;;
|
||||||
|
|
||||||
plugins-install-dependencies)
|
plugins-install-dependencies)
|
||||||
|
if [[ $2 == "--core" ]]; then
|
||||||
|
export PLUGIN_PATH="$PLUGIN_CORE_PATH"
|
||||||
|
fi
|
||||||
pluginhook dependencies
|
pluginhook dependencies
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -214,6 +225,23 @@ case "$1" in
|
|||||||
pluginhook update
|
pluginhook update
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
plugins:disable)
|
||||||
|
PLUGIN="$2"
|
||||||
|
[[ -e $PLUGIN_CORE_PATH/$PLUGIN ]] && echo "Cannot disable a core plugin" && exit 1
|
||||||
|
[[ -e $PLUGIN_DISABLED_PATH/$PLUGIN ]] && echo "Plugin already disabled" && exit 1
|
||||||
|
[[ ! -e $PLUGIN_PATH/$PLUGIN ]] && echo "Plugin does not exist" && exit 1
|
||||||
|
mv "$PLUGIN_PATH/$PLUGIN" "$PLUGIN_DISABLED_PATH"
|
||||||
|
echo "Plugin $PLUGIN disabled"
|
||||||
|
;;
|
||||||
|
|
||||||
|
plugins:enable)
|
||||||
|
PLUGIN="$2"
|
||||||
|
[[ -e $PLUGIN_PATH/$PLUGIN ]] && echo "Plugin already enabled" && exit 1
|
||||||
|
[[ ! -e $PLUGIN_DISABLED_PATH/$PLUGIN ]] && echo "Plugin does not exist" && exit 1
|
||||||
|
mv "$PLUGIN_DISABLED_PATH/$PLUGIN" "$PLUGIN_PATH"
|
||||||
|
echo "Plugin $PLUGIN enabled"
|
||||||
|
;;
|
||||||
|
|
||||||
# DEPRECATED as of v0.3.14
|
# DEPRECATED as of v0.3.14
|
||||||
deploy:all)
|
deploy:all)
|
||||||
echo "*DEPRECATED* in v0.3.14: deploy:all will be removed in future versions"
|
echo "*DEPRECATED* in v0.3.14: deploy:all will be removed in future versions"
|
||||||
@@ -228,8 +256,11 @@ case "$1" in
|
|||||||
cat<<EOF | pluginhook commands help | sort | column -c2 -t -s,
|
cat<<EOF | pluginhook commands help | sort | column -c2 -t -s,
|
||||||
help, Print the list of commands
|
help, Print the list of commands
|
||||||
plugins, Print active plugins
|
plugins, Print active plugins
|
||||||
plugins-install, Install active plugins
|
plugins-install [--core], Install active plugins (or only core ones)
|
||||||
|
plugins-install-dependencies [--core], Install active plugins dependencies (or only core ones)
|
||||||
plugins-update, Update active plugins
|
plugins-update, Update active plugins
|
||||||
|
plugins:enable <name>, Enable a previously disabled plugin
|
||||||
|
plugins:disable <name>, Disable an installed plugin (third-party only)
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user