46 lines
1.3 KiB
PowerShell
46 lines
1.3 KiB
PowerShell
# TODO:
|
|
# * copy the conf if it doesn't exist
|
|
# * create the destination directory if doesn't exist
|
|
|
|
if ($args.Count -lt 3) {
|
|
$scriptName = [Environment]::GetCommandLineArgs()[1]
|
|
Write-Output "Usage: $scriptName <address: string> <remote director: string> <key file: openssh format>"
|
|
exit 1
|
|
}
|
|
|
|
$address=$args[0]
|
|
$destination=$args[1]
|
|
$ssh_key=$args[2]
|
|
|
|
$ssh_command = "ssh -i $ssh_key $address"
|
|
$scp_command = "scp -r -i $ssh_key"
|
|
|
|
function Invoke-SSH([string]$command)
|
|
{
|
|
$expression = "$ssh_command $command"
|
|
Write-Output "Executing: $expression"
|
|
Invoke-Expression $expression | Write-Output
|
|
}
|
|
|
|
function Copy-SSH([string]$source, [string]$destination)
|
|
{
|
|
$expression = "$scp_command $source ${address}:$destination"
|
|
Write-Output "Executing: $expression"
|
|
Invoke-Expression $expression
|
|
}
|
|
|
|
cargo build --target arm-unknown-linux-gnueabihf --release
|
|
|
|
Invoke-SSH "sudo systemctl stop recipes"
|
|
|
|
Copy-SSH -source "./target/arm-unknown-linux-gnueabihf/release/recipes" -destination "~/recipes/"
|
|
|
|
Invoke-SSH "rm -rf recipes/static"
|
|
Copy-SSH -source "./backend/static/" -destination "~/recipes/"
|
|
|
|
Copy-SSH -source "./backend/sql/" -destination "~/recipes/"
|
|
|
|
Invoke-SSH "chmod u+x recipes/recipes"
|
|
Invoke-SSH "sudo systemctl start recipes"
|
|
|
|
Write-Output "Deployment finished"
|