Replace powershell script by nushell script
This commit is contained in:
parent
aedfae1d17
commit
b3751b28bf
3 changed files with 29 additions and 47 deletions
28
deploy.nu
Normal file
28
deploy.nu
Normal file
|
|
@ -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"
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue