Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Created October 10, 2017 05:34
Show Gist options
  • Save tzkmx/23a969a0eeb53dd987e9dca25746e025 to your computer and use it in GitHub Desktop.
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
#! /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
[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
[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