Skip to content

Commit

Permalink
deploy.sh: improve user/home var detection
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Aug 9, 2022
1 parent 1671e49 commit b368a66
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ bin_type=bbgo-slim
host_bin_dir=bin

host=bbgo
host_user=root
host_home=/root
# host_user=ubuntu
# host_home=/root

host_systemd_service_dir=/etc/systemd/system
host_os=linux
Expand Down Expand Up @@ -123,6 +123,11 @@ if [[ $(remote_test "-e $host_systemd_service_dir/$target.service") != "yes" ]];
host_home=$(remote_eval "\$HOME")
fi

if [[ -z $host_user ]]; then
host_user=$(remote_eval "\$USER")
fi


cat <<END >".systemd.$target.service"
[Unit]
After=network-online.target
Expand All @@ -141,10 +146,12 @@ RestartSec=30
END

info "uploading systemd service file..."
scp ".systemd.$target.service" "$host:$host_systemd_service_dir/$target.service"
scp ".systemd.$target.service" "$host:$target.service"
remote_run "sudo mv -v $target.service $host_systemd_service_dir/$target.service"
# scp ".systemd.$target.service" "$host:$host_systemd_service_dir/$target.service"

info "reloading systemd daemon..."
remote_run "sudo systemctl daemon-reload && systemctl enable $target"
remote_run "sudo systemctl daemon-reload && sudo systemctl enable $target"
fi


Expand Down

0 comments on commit b368a66

Please sign in to comment.