Permalink
Browse files

New style for web configs / separate conf per domain

  • Loading branch information...
Serghey Rodin
Serghey Rodin committed Dec 7, 2017
1 parent 1b1622e commit 4053f9ac5ded46c19ced24244f2c56e2cf8f4340
Showing with 77 additions and 32 deletions.
  1. +41 −17 bin/v-backup-user
  2. +36 −15 func/domain.sh
View
@@ -148,36 +148,60 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
grep "DOMAIN='$domain'" $conf > vesta/web.conf
# Backup vhost config
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf
conf=$HOMEDIR/$user/conf/web/$domain.$WEB_SYSTEM.conf
if [ -e "$conf" ]; then
cp $conf conf/$WEB_SYSTEM.conf
else
# old style configs
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf
fi
# Backup ssl vhost
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > conf/s$WEB_SYSTEM.conf
conf=$HOMEDIR/$user/conf/web/$domain.$WEB_SYSTEM.ssl.conf
if [ -e "$conf" ]; then
cp $conf conf/$WEB_SYSTEM.ssl.conf
else
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > \
conf/s$WEB_SYSTEM.conf
fi
fi
# Backup proxy config
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > conf/$PROXY_SYSTEM.conf
conf=$HOMEDIR/$user/conf/web/$domain.$PROXY_YSTEM.conf
if [ -e "$conf" ]; then
cp $conf conf/$PROXY_SYSTEM.conf
else
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > \
conf/$PROXY_SYSTEM.conf
fi
fi
# Backup ssl proxy config
if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf > conf/s$PROXY_SYSTEM.conf
conf=$HOMEDIR/$user/conf/web/$domain.$PROXY_SYSTEM.ssl.conf
if [ -e "$conf" ]; then
cp $conf conf/$PROXY_SYSTEM.ssl.conf
else
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
get_web_config_lines $tpl_file $conf
sed -n "$top_line,$bottom_line p" $conf >\
conf/s$PROXY_SYSTEM.conf
fi
fi
# Backup custom config
# Backup custom config / backup LE config
for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do
cp $HOMEDIR/$user/conf/web/$sconfig conf/
done
View
@@ -167,9 +167,9 @@ prepare_web_domain_values() {
# Add web config
add_web_config() {
conf="$HOMEDIR/$user/conf/web/$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/s$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.ssl.conf"
fi
domain_idn=$domain
@@ -218,7 +218,8 @@ add_web_config() {
trigger="${2/.*pl/.sh}"
if [ -x "$WEBTPL/$1/$WEB_BACKEND/$trigger" ]; then
$WEBTPL/$1/$WEB_BACKEND/$trigger \
$user $domain $local_ip $HOMEDIR $HOMEDIR/$user/web/$domain/public_html
$user $domain $local_ip $HOMEDIR \
$HOMEDIR/$user/web/$domain/public_html
fi
}
@@ -250,28 +251,48 @@ get_web_config_lines() {
# Replace web config
replace_web_config() {
conf="$HOMEDIR/$user/conf/web/$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/s$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.ssl.conf"
fi
if [ -e "$conf" ]; then
sed -i "s|$old|$new|g" $conf
else
# fallback to old style configs
conf="$HOMEDIR/$user/conf/web/$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/s$1.conf"
fi
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
sed -i "$top_line,$bottom_line s|$old|$new|g" $conf
fi
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
sed -i "$top_line,$bottom_line s|$old|$new|g" $conf
}
# Delete web configuartion
del_web_config() {
conf="$HOMEDIR/$user/conf/web/$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/s$1.conf"
conf="$HOMEDIR/$user/conf/web/$domain.$1.ssl.conf"
fi
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
sed -i "$top_line,$bottom_line d" $conf
web_domain=$(grep DOMAIN $USER_DATA/web.conf |wc -l)
if [ "$web_domain" -eq '0' ]; then
sed -i "/.*\/$user\/.*$1.conf/d" /etc/$1/conf.d/vesta.conf
if [ -e "$conf" ]; then
sed -i "|$conf|d" /etc/$1/conf.d/vesta.conf
rm -f $conf
else
# fallback to old style configs
conf="$HOMEDIR/$user/conf/web/$1.conf"
if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/web/s$1.conf"
fi
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
sed -i "$top_line,$bottom_line d" $conf
web_domain=$(grep DOMAIN $USER_DATA/web.conf |wc -l)
if [ "$web_domain" -eq '0' ]; then
sed -i "/.*\/$user\/.*$1.conf/d" /etc/$1/conf.d/vesta.conf
rm -f $conf
fi
fi
}

0 comments on commit 4053f9a

Please sign in to comment.