diff options
| author | Samuel Wilhelmsson <samuel.wilhelmsson@gmail.com> | 2025-01-12 21:39:08 +0100 |
|---|---|---|
| committer | Samuel Wilhelmsson <samuel.wilhelmsson@gmail.com> | 2025-01-12 21:39:08 +0100 |
| commit | 0052b53894f2b21df076b6bf00e4f73d0b6ae9a9 (patch) | |
| tree | 8d1789b3ad42385a11266c058541fbe2559c7fd3 | |
| parent | 1645b6133ce3e02a6ac6b5f015e15b4ab0230d4e (diff) | |
| download | tinygram-0052b53894f2b21df076b6bf00e4f73d0b6ae9a9.tar.gz tinygram-0052b53894f2b21df076b6bf00e4f73d0b6ae9a9.zip | |
update deploy script
| -rwxr-xr-x | deploy | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -1,11 +1,35 @@ #!/usr/bin/env janet (use sh) +## Check we've got the tools we need, an excuse to test macros +(def missing-tools @[]) + +(defmacro checktool [tool-name] + ~(try + ($< ,tool-name | @"") + ([err] (if + (string/has-prefix? "spawn failed" err) + (array/push missing-tools ,tool-name))))) + +(checktool 'templ) +(checktool 'go) +(checktool 'rsync) + +(if (any? missing-tools) + (do + (print (string "missing these tools: " + (string/join missing-tools " "))) + (os/exit 1))) + +## Set up our variables (def user "fnurk") (def host "samuelw.dev") -(def bin-dir "/opt/tinygram/") -(def asset-dir "/srv/tinygram/") +(def appname "tinygram") # also user +(def binaryname "tinygram") + +(def bin-dir (string "/opt/" appname "/")) +(def asset-dir (string "/srv/" appname "/")) (def service-dir "/etc/systemd/system/") (def ssh-target (string user "@" host)) @@ -14,15 +38,15 @@ (def asset-target (string ssh-target ":" asset-dir)) (def service-target (string ssh-target ":" service-dir)) -(def rsync-path ["--rsync-path" "sudo -u tinygram rsync"]) + +(def rsync-path ["--rsync-path" (string "sudo -u " appname " rsync")]) (def rsync-path-sudo ["--rsync-path" "sudo rsync"]) -(def rsync-bin-args [;rsync-path "tinygram" bin-target]) +(def rsync-bin-args [;rsync-path binaryname bin-target]) (def rsync-asset-args [;rsync-path "-r" "assets" asset-target]) (def rsync-service-args [;rsync-path-sudo "service/tinygram.service" service-target]) -(def rsync-service [;rsync-path "-r" "assets" asset-target]) - +##Build and rsync the files!! (print "-- building templ --") ($ templ generate) |
