summaryrefslogtreecommitdiff
path: root/bin/ship-vhost
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ship-vhost')
-rwxr-xr-xbin/ship-vhost46
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