nginx-vhosts rewrite
This commit is contained in:
40
plugins/proxy/commands
Executable file
40
plugins/proxy/commands
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " proxy proxy:set proxy:enable proxy:disable help proxy:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||
|
||||
case "$1" in
|
||||
proxy)
|
||||
proxy_main $2
|
||||
;;
|
||||
|
||||
proxy:set)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_set $2
|
||||
;;
|
||||
|
||||
proxy:enable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_enable $2 --no-restart
|
||||
;;
|
||||
|
||||
proxy:disable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
proxy_disable $2 --no-restart
|
||||
;;
|
||||
|
||||
help | proxy:help)
|
||||
cat<<EOF
|
||||
proxy <app>, Show proxy for app
|
||||
proxy:enable <app>, Enable proxy for app
|
||||
proxy:disable <app>, Disable proxy for app
|
||||
proxy:set <app> <proxy_type>, NOT IMPLEMENTED YET!!
|
||||
EOF
|
||||
;;
|
||||
|
||||
*)
|
||||
exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
||||
;;
|
||||
|
||||
esac
|
||||
74
plugins/proxy/functions
Executable file
74
plugins/proxy/functions
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
is_app_proxy_enabled() {
|
||||
local desc="return true if proxy is enabled; otherwise return false"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local APP_PROXY_ENABLED=true
|
||||
|
||||
local DOKKU_DISABLE_PROXY=$(config_get $APP DOKKU_DISABLE_PROXY)
|
||||
if [[ -n "$DOKKU_DISABLE_PROXY" ]]; then
|
||||
local APP_PROXY_ENABLED=false
|
||||
fi
|
||||
echo $APP_PROXY_ENABLED
|
||||
}
|
||||
|
||||
get_app_proxy_type() {
|
||||
local desc="return app proxy type"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local APP_PROXY_TYPE="nginx"
|
||||
|
||||
echo $APP_PROXY_TYPE
|
||||
}
|
||||
|
||||
proxy_main() {
|
||||
local desc="displays app proxy implementation"
|
||||
local ALL_APPS=$(dokku_apps)
|
||||
if [[ -n "$1" ]]; then
|
||||
local APP="$1"
|
||||
fi
|
||||
local APPS=${APP:="$ALL_APPS"}
|
||||
|
||||
dokku_col_log_info1_quiet "App Name" "Proxy Type"
|
||||
for app in $APPS; do
|
||||
verify_app_name "$app"
|
||||
dokku_col_log_msg "$app" "$(get_app_proxy_type $app)"
|
||||
done
|
||||
}
|
||||
|
||||
proxy_set() {
|
||||
local desc="enable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
dokku_log_info1 "proxy:set not implemented"
|
||||
}
|
||||
|
||||
proxy_enable() {
|
||||
local desc="enable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled $APP)" == "false" ]]; then
|
||||
dokku_log_info1 "Enabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
config_unset $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY
|
||||
plugn trigger proxy-enable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already enabled for app ($APP)"
|
||||
fi
|
||||
}
|
||||
|
||||
proxy_disable() {
|
||||
local desc="disable proxy for app"
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
if [[ "$(is_app_proxy_enabled $APP)" == "true" ]]; then
|
||||
dokku_log_info1 "Disabling proxy for app ($APP)"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
config_set $CONFIG_SET_ARGS $APP DOKKU_DISABLE_PROXY=1
|
||||
plugn trigger proxy-disable "$APP"
|
||||
else
|
||||
dokku_log_info1 "proxy is already disable for app ($APP)"
|
||||
fi
|
||||
}
|
||||
4
plugins/proxy/plugin.toml
Normal file
4
plugins/proxy/plugin.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core proxy plugin"
|
||||
version = "0.5.0"
|
||||
[plugin.config]
|
||||
Reference in New Issue
Block a user