From 3b1e0cb3f09907aa48c8d9a976dca5efc4117a7e Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Fri, 11 Sep 2026 14:40:23 +0100 Subject: [PATCH] better bash script --- wu.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 wu.sh diff --git a/wu.sh b/wu.sh new file mode 100755 index 0000000..8d7b834 --- /dev/null +++ b/wu.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +RESET='\033[0m' + +DEBUG=false +UPLOAD=false +CLEAN=false + +usage() { + echo "Usage: $(basename "$0") [-d] [-u] [-c] [-h]" + echo "" + echo "Options:" + echo " -d Debug build (adds -debug flag to odin)" + echo " -u Upload HTML to webserver after build" + echo " -c Clean old HTML files before generating" + echo " -h Show this help message" + exit 0 +} + +while getopts "duch" opt; do + case $opt in + d) DEBUG=true ;; + u) UPLOAD=true ;; + c) CLEAN=true ;; + h) usage ;; + *) usage ;; + esac +done + +if $CLEAN; then + echo -e "${YELLOW}[INFO]${RESET} Removing old HTML files..." + find /Users/simon/website_backup/NEW/HTML -type f -name "*.html" -delete + echo -e "${GREEN}[ OK ]${RESET} Old HTML removed" +fi + +if $DEBUG; then + echo -e "${CYAN}[INFO]${RESET} Debug build" + odin build . -debug +else + echo -e "${CYAN}[INFO]${RESET} Release build" + odin build . -o:speed +fi +echo -e "${GREEN}[ OK ]${RESET} Build complete" + +./cm -dir="/Users/simon/website_backup/NEW/" -out="/Users/simon/website_backup/NEW/HTML" +echo -e "${GREEN}[ OK ]${RESET} HTML generated" + +if $UPLOAD; then + echo -e "${YELLOW}[INFO]${RESET} Uploading to server..." + rsync -aP /Users/simon/website_backup/NEW/HTML/* root@www.simonkellet.xyz:/var/www/cabin/ + echo -e "${GREEN}[ OK ]${RESET} Upload complete" +fi