--- /dev/null
+def main [host: string, destination: string, ssh_key: path] {
+ let ssh_args = [-i $ssh_key $host]
+ let scp_args = [-r -i $ssh_key]
+ let target = "aarch64-unknown-linux-gnu" # For raspberry pi zero 1: "arm-unknown-linux-gnueabihf"
+
+ def invoke_ssh [command: list] {
+ let args = $ssh_args ++ $command
+ print $"Executing: ssh ($args)"
+ ssh $args
+ }
+
+ def copy_ssh [source: string, destination: string] {
+ let args = $scp_args ++ [$source $"($host):($destination)"]
+ print $"Executing: scp ($args)"
+ scp $args
+ }
+
+ cargo build --target $target --release
+ invoke_ssh [sudo systemctl stop recipes]
+ copy_ssh ./target/($target)/release/recipes $destination
+ invoke_ssh [rm -rf recipes/static]
+ copy_ssh ./backend/static/ $destination
+ copy_ssh ./backend/sql/ $destination
+ invoke_ssh [chmod u+x recipes/recipes]
+ invoke_ssh [sudo systemctl start recipes]
+ print "Deployment finished"
+}
+