summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Sanders <hello@bensanders.net>2026-09-18 10:05:21 -0400
committerBenjamin Sanders <hello@bensanders.net>2026-09-18 10:05:21 -0400
commit55057f02eeed339f38286bd92010755704eb3717 (patch)
tree31ce480aecc7836e5b4c18ab0ba8f3b8c9e7cf08
parent3ecb8b59e1d08a6dbb81d867ea4376d9bdb25ac2 (diff)
added three filesHEADmain
-rw-r--r--bsimg-process.sh12
-rw-r--r--configure-server.sh26
-rw-r--r--pbs-bsimg-net.conf35
3 files changed, 73 insertions, 0 deletions
diff --git a/bsimg-process.sh b/bsimg-process.sh
new file mode 100644
index 0000000..48346d7
--- /dev/null
+++ b/bsimg-process.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+DIR="$1"
+HASH="$2"
+EXT="$3"
+
+cd "$DIR"
+for size in thumb:200 medium:800 large:1600; do
+ name="${size%%:*}"; px="${size##*:}"
+ magick "${HASH}-original.${EXT}" -resize "${px}x${px}>" "${HASH}-${name}.jpg"
+done \ No newline at end of file
diff --git a/configure-server.sh b/configure-server.sh
new file mode 100644
index 0000000..31bea65
--- /dev/null
+++ b/configure-server.sh
@@ -0,0 +1,26 @@
+# This is a rudimentary script to configure an image node
+
+# Start by updating cache and installing needed packages
+sudo apt update && sudo apt install imagemagick nginx vim git sudo python3-certbot-nginx -y
+
+# Created needed configuration files
+# First the NGINX config file
+# Second the file to process images
+touch /etc/nginx/conf.d/pbs-bsimg-net.conf
+touch /usr/local/bin/bsimg-process.sh
+
+# Make the image processor file executable
+chmod +x /usr/local/bin/bsimg-process.sh
+
+# Add my username to the www-data and ensure the group owns the directory
+# so I can upload files
+usermod -aG www-data ben
+usermod -aG sudo ben
+chown -R www-data:www-data /var/www/html/
+
+# Attempt to get TLS certs
+# Replace {region} with state/country code of region the vm is located
+certbot -d bsimg.net -d pbs.atl.bsimg.net -d pbs.bsimg.net -d pbs.{region}.bsimg.net
+
+# Restart NGINX
+systemctl restart nginx.service \ No newline at end of file
diff --git a/pbs-bsimg-net.conf b/pbs-bsimg-net.conf
new file mode 100644
index 0000000..69cf4bb
--- /dev/null
+++ b/pbs-bsimg-net.conf
@@ -0,0 +1,35 @@
+# Default server configuration
+map $arg_name $img_name {
+ default $arg_name;
+ "" "missing";
+}
+
+map $arg_format $img_format {
+ default $arg_format;
+ "" "missing";
+}
+
+server {
+ listen 80;
+ listen [::]:80;
+
+ root /var/www/html;
+
+ index index.html;
+
+ server_name pbs.bsimg.net pbs.atl.bsimg.net bsimg.net;
+
+ error_page 404 /404.html;
+ error_page 500 /500.html;
+
+ location / {
+ try_files $uri $uri/ =404;
+ }
+
+ location /media/ {
+ root /var/www/html;
+ expires 1y;
+ add_header Cache-Control "public, immutable";
+ try_files $uri-${img_name}.${img_format} =404;
+ }
+} \ No newline at end of file