MODIFY base data

This commit is contained in:
root
2023-04-17 06:17:05 +00:00
parent 55f06298df
commit 7abe197967

View File

@@ -157,38 +157,8 @@ remove_location() {
fi; fi;
} }
file="/tmp/$DOMAIN_NAME.conf"
# check whether certificates exist or not
echo "created domain name: "$DOMAIN_NAME;
#cp -a /scripts/nginx_template.conf /tmp/$DOMAIN.conf
# if domain already exists as a config file append alternate location there
if [ -f $DOMAIN_NAME.conf ]; then
if [ "$OPERATION" = "DELETE" ]; then
remove_alternate_location;
elif [ "$OPERATION" = "MODIFY" ]; then
remove_alternate_location;
add_alternate_location;
else
# default CREATE, append location
add_alternate_location;
# reload alternate locations if allowed networks has changed
if [ -n "$RELOAD_LOCATIONS" ]; then
rm $file;
remove_alternate_location;
add_alternate_location;
fi;
fi;
else
# create new nginx config # create new nginx config
create_new_config() {
{ {
if [[ "$HTTP_PORT" != "80" ]]; then if [[ "$HTTP_PORT" != "80" ]]; then
@@ -372,16 +342,68 @@ echo " proxy_pass http://$LOCAL_NAME:$HTTPS_PORT;"
echo " proxy_buffering off;" echo " proxy_buffering off;"
echo "}" echo "}"
echo "# first location end";
add_location; add_location;
fi fi
echo "}" if [ "$OPERATION" != "MODIFY" ]; then
echo "}"
fi;
fi fi
} >> "$file" } >> "$file"
}
file="/tmp/$DOMAIN_NAME.conf"
# check whether certificates exist or not
echo "created domain name: "$DOMAIN_NAME;
#cp -a /scripts/nginx_template.conf /tmp/$DOMAIN.conf
# if domain already exists as a config file append alternate location there
if [ -f $DOMAIN_NAME.conf ]; then
if [ "$OPERATION" = "DELETE" ]; then
remove_alternate_location;
elif [ "$OPERATION" = "MODIFY" ]; then
# must be before create_new_config
remove_alternate_location;
add_alternate_location;
mv $file $DOMAIN_NAME.conf;
# regenerates nginx config into $file
create_new_config;
# append existing alternate locations to new config file
OFFSET=$(cat $DOMAIN_NAME.conf | grep -n '# first location end' -m 1 | cut -d ':' -f1);
OFFSET=$(($OFFSET + 1));
{
tail -n+$OFFSET $DOMAIN_NAME.conf
} >> $file
else
# default CREATE, append location
add_alternate_location;
# reload alternate locations if allowed networks has changed
if [ -n "$RELOAD_LOCATIONS" ]; then
rm $file;
remove_alternate_location;
add_alternate_location;
fi;
fi;
else
create_new_config;
fi; # end of create new nginx config fi; # end of create new nginx config
if [ "$OPERATION" != "DELETE" ]; then if [ "$OPERATION" != "DELETE" ]; then