-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·43 lines (36 loc) · 1.37 KB
/
deploy.sh
File metadata and controls
executable file
·43 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/expect -f
set install_dir "/opt/netatmo-truetempsync"
set publish_dir "NetatmoTrueTempSync/bin/publish/linux-arm64"
send_user "Host: "
expect_user -re "(.*)\n" { set host $expect_out(1,string) }
send_user "Username: "
expect_user -re "(.*)\n" { set user $expect_out(1,string) }
stty -echo
send_user "Password: "
expect_user -re "(.*)\n" { set pass $expect_out(1,string) }
stty echo
send_user "\n"
send_user "Publishing for linux-arm64...\n"
if {[catch {exec dotnet publish NetatmoTrueTempSync -p:PublishProfile=linux-arm64 >@stdout 2>@stderr}]} {
send_user "Publish failed.\n"
exit 1
}
proc run_ssh {user host pass args} {
spawn ssh -o PubkeyAuthentication=no "$user@$host" {*}$args
expect "password:" { send "$pass\r" }
expect eof
lassign [wait] pid spawnid os_error exit_code
return $exit_code
}
proc run_scp {user host pass src dst} {
spawn scp -o PubkeyAuthentication=no $src "$user@$host:$dst"
expect "password:" { send "$pass\r" }
expect eof
lassign [wait] pid spawnid os_error exit_code
return $exit_code
}
send_user "Deploying to $user@$host:$install_dir...\n"
run_ssh $user $host $pass "sudo mkdir -p $install_dir && sudo chown $user:$user $install_dir"
run_scp $user $host $pass "$publish_dir/netatmo-truetempsync" "$install_dir/"
run_ssh $user $host $pass "$install_dir/netatmo-truetempsync service install"
send_user "Done!\n"