From ad0303930bc1efceaaaa03b9ace6fb2b176e28da Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 9 Mar 2025 23:03:57 +0100 Subject: add ship-vhost --- bin/ship-vhost | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 bin/ship-vhost (limited to 'bin') diff --git a/bin/ship-vhost b/bin/ship-vhost new file mode 100755 index 0000000..0c51900 --- /dev/null +++ b/bin/ship-vhost @@ -0,0 +1,46 @@ +#!/bin/sh -ex + +# A ship template script + +die() { [ "$1" ] && echo "$0: $*" >&2; exit 1; } + +[ "$1" ] || die 'host argument missing' +[ -f /etc/alpine-release ] || die 'not on alpinelinux system' +[ "$USER" = root ] || exec doas "$0" "$@" + +: Step 1: install dependencies +apk add nginx + +: Step 2: Configure +mkdir -p "/var/www/$1/html" + +cat <<- EOF > "/var/www/$1/html/index.html" + + + + Server block + + +

Success! The Nginx server block is running!

+ + +EOF + +chown -R nginx: "/var/www/$1" + +cat <<- EOF > "/etc/nginx/http.d/$1.conf" +server { + listen 80; + listen [::]:80; + server_name $1; + root /var/www/$1/html; + access_log /var/log/nginx/$1.access.log; + error_log /var/log/nginx/$1.error.log; +} +EOF + +: Step 3: Enable and start +service nginx restart + +: Step 4: Test +netstat -tulpn | grep :80 -- cgit v1.2.3