Change the default font + other little things
[recipes.git] / deploy.ps1
1 # TODO:
2 # * copy the conf if it doesn't exist
3 # * create the destination directory if doesn't exist
4
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>"
8    exit 1
9 }
10
11 $address=$args[0]
12 $destination=$args[1]
13 $ssh_key=$args[2]
14
15 $ssh_command = "ssh -i $ssh_key $address"
16 $scp_command = "scp -r -i $ssh_key"
17
18 function Invoke-SSH([string]$command)
19 {
20    $expression = "$ssh_command $command"
21    Write-Output "Executing: $expression"
22    Invoke-Expression $expression | Write-Output
23 }
24
25 function Copy-SSH([string]$source, [string]$destination)
26 {
27    $expression = "$scp_command $source ${address}:$destination"
28    Write-Output "Executing: $expression"
29    Invoke-Expression $expression
30 }
31
32 cargo build --target arm-unknown-linux-gnueabihf --release
33
34 Invoke-SSH "sudo systemctl stop recipes"
35
36 Copy-SSH -source "./target/arm-unknown-linux-gnueabihf/release/recipes" -destination "~/recipes/"
37
38 Invoke-SSH "rm -rf recipes/static"
39 Copy-SSH -source "./backend/static/" -destination "~/recipes/"
40
41 Invoke-SSH "chmod u+x recipes/recipes"
42 Invoke-SSH "strip recipes/recipes"
43 Invoke-SSH "sudo systemctl start recipes"
44
45 Write-Output "Deployment finished"