diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-03-09 23:03:57 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-03-09 23:03:57 +0100 |
| commit | ad0303930bc1efceaaaa03b9ace6fb2b176e28da (patch) | |
| tree | 265fadf0b29ae00132a934a89e71879e804a2ec1 /bin | |
| parent | 98b2babfe8defd60728abe7fc5611b55f2014158 (diff) | |
add ship-vhost
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/ship-vhost | 46 |
1 files changed, 46 insertions, 0 deletions
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" +<!DOCTYPE html> +<html lang="en"> + <head> + <title>Server block</title> + </head> + <body> + <h1>Success! The Nginx server block is running!</h1> + </body> +</html> +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 |
