Распространенные способы определения современного UNIX-подобная система включает следующее:
/etc/system-release
/etc/system-release-cpe
/etc/os-release
/etc/redhat-release
/etc/centos-release
...
Etc ad naseum.
Дополнительную информацию можно найти здесь: Словарь CPE
Это будет зависеть от дистрибутива, версии и т. Д.
Используя функцию и GNU Parallel, вы заменяете повторяющийся раздел:
cd ~
apt-get update
apt-get install varnish -y
sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf
myfunc() {
sed -i 's/\*\:80/\*\:8080/g' /etc/apache2/sites-available/$1 &&
a2ensite $1
}
export -f myfunc
parallel myfunc {/} ::: /etc/apache2/sites-available/*
mkdir -p /etc/systemd/system/varnish.service.d # Be aware! You might not need this in the future.
cat <<-'VARNISH' > /etc/systemd/system/varnish.service.d/customexec.conf
[Service]
ExecStart=
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
VARNISH
systemctl restart apache2.service && systemctl daemon-reload && systemctl restart varnish.service