From 96757895dcba6964f4e22ab403d4abe23ed0d623 Mon Sep 17 00:00:00 2001
From: Marty Oehme <contact@martyoeh.me>
Date: Fri, 28 Feb 2025 08:27:20 +0100
Subject: [PATCH] wlsunset: Fix pass through time variables to service

Passing them through as individual arguments on the commandline.
Previously quoting would pass them through as a single argument, making
it not work correctly.

Could switch to using bash arrays for this (to make it more robust
against word-splitting) but a) I prefer the portability of sh for such a
simple script and b) there _should_ never be a time when we pass through
anything that has weird word-splitting issues. Either the location is
passed through or the times.
---
 services/sv/wlsunset/run | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/services/sv/wlsunset/run b/services/sv/wlsunset/run
index a35f6b0..0863c8a 100755
--- a/services/sv/wlsunset/run
+++ b/services/sv/wlsunset/run
@@ -1,16 +1,16 @@
-#!/bin/sh
+#!/usr/bin/env sh
 
 [ -r ./conf ] && . ./conf
 
-TIME_OPTS='-S \"09:00\" -s \"21:00\" -d \"3600\"'
+TIME_OPTS="-S 08:00 -s 21:00 -d 3600"
 if command -v curl >/dev/null 2>&1; then
     loc=$(curl -s ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/')
     if [ -n "$loc" ]; then
         lat="$(echo "$loc" | cut -d, -f1)"
         long="$(echo "$loc" | cut -d, -f2)"
-        TIME_OPTS="-l \"$lat\" -L \"$long\""
+        TIME_OPTS="-l $lat -L $long"
     fi
 fi
 
 exec 2>&1
-exec chpst -e "$TURNSTILE_ENV_DIR" wlsunset $TIME_OPTS "$@"
+exec chpst -e "$TURNSTILE_ENV_DIR" wlsunset ${TIME_OPTS} "$@"