2 # * copy the conf if it doesn't exist
3 # * create the destination directory if doesn't exist
5 if ($args.Count -lt 3) {
6 $scriptName = [Environment]::GetCommandLineArgs()[1]
7 Write-Output "Usage: $scriptName <address: string> <remote director: string> <key file: openssh format>"
15 $ssh_command = "ssh -i $ssh_key $address"
16 $scp_command = "scp -r -i $ssh_key"
18 function Invoke-SSH([string]$command)
20 $expression = "$ssh_command $command"
21 Write-Output "Executing: $expression"
22 Invoke-Expression $expression | Write-Output
25 function Copy-SSH([string]$source, [string]$destination)
27 $expression = "$scp_command $source ${address}:$destination"
28 Write-Output "Executing: $expression"
29 Invoke-Expression $expression
32 cargo build --target arm-unknown-linux-gnueabihf --release
34 Invoke-SSH "sudo systemctl stop recipes"
36 Copy-SSH -source "./target/arm-unknown-linux-gnueabihf/release/recipes" -destination "~/recipes/"
38 Invoke-SSH "rm -rf recipes/static"
39 Copy-SSH -source "./backend/static/" -destination "~/recipes/"
41 Invoke-SSH "chmod u+x recipes/recipes"
42 Invoke-SSH "strip recipes/recipes"
43 Invoke-SSH "sudo systemctl start recipes"
45 Write-Output "Deployment finished"