Added passeneg manager. Part 6

devel
Alexey Berezhok 4 months ago
parent c572522f43
commit 5067d35524

@ -271,6 +271,7 @@ convert_proxy_ngix_internal_redirect(){
# Add web config
add_web_config() {
# Check if folder already exists
TPLNM="$2"
if [ "$1" = "httpd" ]; then
confd="conf.h.d"
else
@ -281,14 +282,6 @@ add_web_config() {
mkdir -p "$HOMEDIR/$user/conf/web/$domain/"
fi
conf="$HOMEDIR/$user/conf/web/$domain/$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/$domain/$1.ssl.conf"
fi
domain_idn=$domain
format_domain_idn
PASS_TPL=""
#Passenger generator
if [ -e /usr/local/hestia/bin/v-ext-modules ]; then
@ -296,28 +289,50 @@ add_web_config() {
if [ -n "$res" ]; then
enabled=$(echo "$res" | grep enabled)
if [ -n "$enabled" ]; then
ruby_res=$(/usr/local/hestia/bin/v-ext-modules-run passenger_manager get_user_ruby "$domain" | tail -n1)
if [ -n "$ruby_res" ]; then
:
#TODO
RUBY_RES=$(/usr/local/hestia/bin/v-ext-modules-run passenger_manager get_user_ruby "$domain" | tail -n1)
if [ -n "$RUBY_RES" ]; then
pass_tpl_dir=$(v-ext-modules-run passenger_manager get_tpl_path | tail -n1)
if [ -n "$pass_tpl_dir" ]; then
PASS_TPL="$pass_tpl_dir"
if [[ "$TPLNM" =~ stpl$ ]]; then
TPLNM="passenger.stpl"
else
TPLNM="passenger.tpl"
fi
fi
fi
fi
fi
fi
if [ "$1" == "httpd" -a -n "$PASS_TPL" ]; then
return
fi
conf="$HOMEDIR/$user/conf/web/$domain/$1.conf"
if [[ "$TPLNM" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/$domain/$1.ssl.conf"
fi
domain_idn=$domain
format_domain_idn
WEBTPL_LOCATION="$WEBTPL/$1"
if [ "$1" != "$PROXY_SYSTEM" ] && [ -n "$WEB_BACKEND" ] && [ -d "$WEBTPL_LOCATION/$WEB_BACKEND" ]; then
if [ -f "$WEBTPL_LOCATION/$WEB_BACKEND/$2" ]; then
if [ -f "$WEBTPL_LOCATION/$WEB_BACKEND/$TPLNM" ]; then
# check for backend specific template
WEBTPL_LOCATION="$WEBTPL/$1/$WEB_BACKEND"
fi
fi
if [ -n "$PASS_TPL" ]; then
WEBTPL_LOCATION="$PASS_TPL"
fi
# Note: Removing or renaming template variables will lead to broken custom templates.
# -If possible custom templates should be automatically upgraded to use the new format
# -Alternatively a depreciation period with proper notifications should be considered
cat "${WEBTPL_LOCATION}/$2" \
cat "${WEBTPL_LOCATION}/$TPLNM" \
| sed -e "s|%ip%|$local_ip|g" \
-e "s|%domain%|$domain|g" \
-e "s|%domain_idn%|$domain_idn|g" \
@ -347,7 +362,7 @@ add_web_config() {
-e "s|%ssl_ca%|$ssl_ca|g" \
> $conf
if [ "$2" == "srvproxy.tpl" -o "$2" == "srvproxy.stpl" ];then
if [ "$TPLNM" == "srvproxy.tpl" -o "$TPLNM" == "srvproxy.stpl" ];then
proxy_backend_port_internal=$(convert_proxy_ngix_internal_redirect "$3")
cat "$conf" \
| sed -e "s|%proxy_backend_srv_port%|$proxy_backend_port_internal|g" \
@ -360,7 +375,7 @@ add_web_config() {
chown root:$user $conf
chmod 640 $conf
if [[ "$2" =~ stpl$ ]]; then
if [[ "$TPLNM" =~ stpl$ ]]; then
rm -f /etc/$1/$confd/domains/$domain.ssl.conf
ln -s $conf /etc/$1/$confd/domains/$domain.ssl.conf
@ -398,7 +413,7 @@ add_web_config() {
done
fi
trigger="${2/.*pl/.sh}"
trigger="${TPLNM/.*pl/.sh}"
if [ -x "${WEBTPL_LOCATION}/$trigger" ]; then
$WEBTPL_LOCATION/$trigger \
$user $domain $local_ip $HOMEDIR \

@ -27,6 +27,7 @@ server {
passenger_enabled on;
passenger_user %user%;
passenger_group %user%;
passenger_ruby %rubypath%;
location / {
passenger_base_uri /;

@ -18,6 +18,7 @@ server {
passenger_enabled on;
passenger_user %user%;
passenger_group %user%;
passenger_ruby %rubypath%;
location / {
passenger_base_uri /;

Loading…
Cancel
Save