X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=deploy.nu;fp=deploy.nu;h=2e463511462d54c5262d1c7ee00802bbe21d5b66;hp=0000000000000000000000000000000000000000;hb=b3751b28bfc8bf5fd0d5406acc1d3543e6481ed1;hpb=aedfae1d17d2fd39b3b1f4889723d627fcc79218 diff --git a/deploy.nu b/deploy.nu new file mode 100644 index 0000000..2e46351 --- /dev/null +++ b/deploy.nu @@ -0,0 +1,28 @@ +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" +} +