diff host/update2.sh @ 2133:c3b4c19f2d8a

attempt to autodetect and use nginx confs dir
author Violet7
date Fri, 16 Jan 2026 17:29:05 -0800
parents 6a2383baecb6
children de3107eb911f
line wrap: on
line diff
--- a/host/update2.sh	Fri Jan 16 16:56:38 2026 -0800
+++ b/host/update2.sh	Fri Jan 16 17:29:05 2026 -0800
@@ -13,13 +13,30 @@
 	openssl genrsa 4096 >local/tiny_account.key
 fi
 
+nginx_conf_dir=$(
+	for d in \
+		/usr/local/etc/nginx/servers \
+		/etc/nginx/conf.d; do
+		if [ -d "$d" ]; then
+			echo "$d"
+			break
+		fi
+	done
+)
+
+if [ -n "$nginx_conf_dir" ]; then
+	echo "using nginx conf dir: $nginx_conf_dir"
+else
+	echo "ERROR: No nginx conf dir found.\nFind it and add it to update2.sh."
+	exit 1
+fi
+
 # id -gn gets the name of the primary group of the current user (staff)
-luan startup/nginx/nginx.conf.luan $(pwd) $(whoami) $(id -gn) >local/nginx.conf
-luan startup/nginx/nginx.default.conf.luan $(pwd) >local/nginx.default.conf
+luan startup/nginx/nginx.conf.luan $(pwd) $nginx_conf_dir $(whoami) $(id -gn) | sudo tee $nginx_conf_dir/luanhost.conf >/dev/null
+luan startup/nginx/nginx.default.conf.luan $(pwd) | sudo tee $nginx_conf_dir/luanhost.default.conf >/dev/null
 
 # this is done because the nginx conf uses absolute paths
 # and this breaks sites when the luan/host directory is moved
-# NOTE: if the luanhost root dir changes, the nginx include needs to be manually updated to reflect the new path.
 luan classpath:luan/host/update.luan
 
 echo Starting...