fix: allow enabling nginx-vhosts when skipped at install
Installing with the `dokku/nginx_enable` debconf option set to `false` left the nginx-vhosts plugin disabled with no way to turn it back on, as `dokku plugin:enable nginx-vhosts` reported that the plugin does not exist. The plugin can now be enabled after installation, and the debconf documentation explains the option's effect and how to reverse it.
This commit is contained in:
12
debian/postinst
vendored
12
debian/postinst
vendored
@@ -109,14 +109,18 @@ setup-plugins() {
|
||||
db_get "dokku/nginx_enable"
|
||||
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
|
||||
if [ -d "${DOKKU_LIB_ROOT}/plugins/available/$plugin" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
ln -s "${DOKKU_LIB_ROOT}/core-plugins/available/$plugin" "${DOKKU_LIB_ROOT}/plugins/available/$plugin"
|
||||
if [ "$plugin" = "nginx-vhosts" ] && [ "$RET" = "false" ]; then
|
||||
echo "Skipping enable of nginx-vhosts plugin"
|
||||
continue
|
||||
elif [ ! -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
|
||||
|
||||
PLUGIN_PATH="${DOKKU_LIB_ROOT}/core-plugins" plugn enable "$plugin"
|
||||
PLUGIN_PATH="${DOKKU_LIB_ROOT}/plugins" plugn enable "$plugin"
|
||||
done
|
||||
find -L "${DOKKU_LIB_ROOT}/core-plugins" -type l -delete
|
||||
find -L "${DOKKU_LIB_ROOT}/plugins" -type l -delete
|
||||
|
||||
@@ -249,6 +249,8 @@ dokku plugin:enable postgres
|
||||
-----> Plugin postgres enabled
|
||||
```
|
||||
|
||||
Core plugins that were not enabled at install time - such as the nginx-vhosts plugin when the `dokku/nginx_enable` debconf option is set to `false` - can also be enabled this way. Run `dokku plugin:install --core` afterwards so the plugin's install trigger is executed.
|
||||
|
||||
### Triggering a plugin trigger
|
||||
|
||||
The `plugin:trigger` can be used to call any internal plugin trigger. This may have unintended consequences, and thus should only be called for development or debugging purposes.
|
||||
|
||||
@@ -37,4 +37,14 @@ After setting the desired options, proceed with the installation as described ab
|
||||
| dokku/hostname | string | dokku.me | Hostname, used as vhost domain and for showing app URL after deploy |
|
||||
| dokku/skip_key_file| boolean | false | Don't check for the existence of the dokku/key_file. Warning: Setting this to true, will require you to manually add an SSH key later on. |
|
||||
| dokku/key_file | string | /root/.ssh/id_rsa.pub | Path on disk to an SSH key to add to the Dokku user (Will be ignored on `dpkg-reconfigure`) |
|
||||
| dokku/nginx_enable | boolean | true | Enable nginx-vhosts plugin |
|
||||
| dokku/nginx_enable | boolean | true | Enable nginx-vhosts plugin. When `false`, the plugin is installed but left disabled, and the `nginx:*` commands are unavailable. |
|
||||
| dokku/install_default_site | boolean | true | Install a catch-all nginx default site on fresh install |
|
||||
|
||||
### Enabling the nginx-vhosts plugin after installation
|
||||
|
||||
If Dokku was installed with `dokku/nginx_enable` set to `false`, the nginx-vhosts plugin can be enabled later. The `plugin:install --core` call runs the plugin's install trigger, which sets up the nginx configuration required by Dokku.
|
||||
|
||||
```shell
|
||||
sudo dokku plugin:enable nginx-vhosts
|
||||
sudo dokku plugin:install --core
|
||||
```
|
||||
|
||||
@@ -18,6 +18,9 @@ enable_plugin() {
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_ENABLED_PATH/$PLUGIN ]] && dokku_log_fail "Plugin already enabled"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin does not exist"
|
||||
if [[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && [[ ! -e $PLUGIN_CORE_ENABLED_PATH/$PLUGIN ]]; then
|
||||
PLUGIN_PATH="$PLUGIN_CORE_PATH" plugn enable "$PLUGIN"
|
||||
fi
|
||||
plugn enable "$PLUGIN"
|
||||
dokku_log_info1_quiet "Plugin $PLUGIN enabled"
|
||||
}
|
||||
|
||||
@@ -9,9 +9,16 @@ setup() {
|
||||
|
||||
teardown() {
|
||||
remove_test_plugin || true
|
||||
restore_enter_plugin
|
||||
global_teardown
|
||||
}
|
||||
|
||||
restore_enter_plugin() {
|
||||
declare desc="re-enables the enter core plugin if a test left it disabled"
|
||||
[[ -e "$PLUGIN_CORE_PATH/enabled/enter" ]] || PLUGIN_PATH="$PLUGIN_CORE_PATH" plugn enable enter || true
|
||||
[[ -e "$PLUGIN_ENABLED_PATH/enter" ]] || PLUGIN_PATH="$PLUGIN_PATH" plugn enable enter || true
|
||||
}
|
||||
|
||||
@test "(plugin) plugin:help" {
|
||||
run /bin/bash -c "dokku plugin"
|
||||
echo "output: $output"
|
||||
@@ -379,3 +386,33 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(plugin:enable) core plugin skipped at install" {
|
||||
run /bin/bash -c "rm $PLUGIN_ENABLED_PATH/enter $PLUGIN_CORE_PATH/enabled/enter"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku plugin:list --format json | jq -r '.[] | select(.name == \"enter\") | .enabled'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "false"
|
||||
|
||||
run /bin/bash -c "dokku plugin:enable enter"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Plugin enter enabled"
|
||||
|
||||
run /bin/bash -c "dokku plugin:list --format json | jq -r '.[] | select(.name == \"enter\") | .enabled'"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "true"
|
||||
|
||||
run /bin/bash -c "test -L $PLUGIN_CORE_PATH/enabled/enter"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user