Created
October 10, 2017 05:34
-
-
Save tzkmx/23a969a0eeb53dd987e9dca25746e025 to your computer and use it in GitHub Desktop.
SystemD Units to watch and force aliases to server_name in NginX, disallowing Plesk bloat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
filename=/var/www/vhosts/system/$1/conf/nginx.conf | |
sed -i -e "/media[0-9]\.$1/d" $filename | |
for index in 4 3 2 1 ; do \ | |
sed -i -e "s@server_name $1;@\0\n\tserver_name media$index.$1;@" $filename ; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description= Watches changes to Media enabled VirtualHost: %i. | |
Documentation= man:systemd.path | |
[Path] | |
PathChanged=/var/www/vhosts/system/%i/conf/nginx.conf | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description= Insert media server names in VirtualHost %i | |
Documentation= man:systemd.service | |
[Service] | |
Type=oneshot | |
ExecStart=/root/fix_media_vhosts.sh %i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment