mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
deploy.sh: rename bin_dir to host_bin_dir and add more doc comment
This commit is contained in:
parent
e8041986a4
commit
d1455f66c7
25
deploy.sh
25
deploy.sh
|
@ -2,11 +2,20 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
target=$1
|
target=$1
|
||||||
bin_dir=bin
|
|
||||||
|
# bin_type is the binary type that you want to build bbgo
|
||||||
|
# use "bbgo" for full-features binary (including web application)
|
||||||
|
# use "bbgo-slim" for slim version binary (without web application)
|
||||||
bin_type=bbgo-slim
|
bin_type=bbgo-slim
|
||||||
|
|
||||||
|
# host_bin_dir is the directory that binary file will be uploaded to.
|
||||||
|
# default to $HOME/bin
|
||||||
|
host_bin_dir=bin
|
||||||
|
|
||||||
host=bbgo
|
host=bbgo
|
||||||
host_user=root
|
host_user=root
|
||||||
host_home=/root
|
host_home=/root
|
||||||
|
|
||||||
host_systemd_service_dir=/etc/systemd/system
|
host_systemd_service_dir=/etc/systemd/system
|
||||||
host_os=linux
|
host_os=linux
|
||||||
host_arch=amd64
|
host_arch=amd64
|
||||||
|
@ -34,6 +43,10 @@ function remote_run() {
|
||||||
ssh $host "$*"
|
ssh $host "$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remote_eval() {
|
||||||
|
ssh $host "echo $*"
|
||||||
|
}
|
||||||
|
|
||||||
function warn() {
|
function warn() {
|
||||||
echo "${YELLOW}$*${NC}"
|
echo "${YELLOW}$*${NC}"
|
||||||
}
|
}
|
||||||
|
@ -61,7 +74,7 @@ fi
|
||||||
|
|
||||||
# initialize the remote environment
|
# initialize the remote environment
|
||||||
# create the directory for placing binaries
|
# create the directory for placing binaries
|
||||||
ssh $host "mkdir -p \$HOME/$bin_dir && mkdir -p \$HOME/$target"
|
ssh $host "mkdir -p \$HOME/$host_bin_dir && mkdir -p \$HOME/$target"
|
||||||
|
|
||||||
if [[ $(remote_test "-e $host_systemd_service_dir/$target.service") != "yes" ]]; then
|
if [[ $(remote_test "-e $host_systemd_service_dir/$target.service") != "yes" ]]; then
|
||||||
if [[ "$setup_host_systemd_service" == "no" ]]; then
|
if [[ "$setup_host_systemd_service" == "no" ]]; then
|
||||||
|
@ -71,6 +84,10 @@ if [[ $(remote_test "-e $host_systemd_service_dir/$target.service") != "yes" ]];
|
||||||
|
|
||||||
warn "$host_systemd_service_dir/$target.service does not exist, setting up..."
|
warn "$host_systemd_service_dir/$target.service does not exist, setting up..."
|
||||||
|
|
||||||
|
if [[ -z $host_home ]]; then
|
||||||
|
host_home=$(remote_eval "\$HOME")
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<END >".systemd.$target.service"
|
cat <<END >".systemd.$target.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
|
@ -101,10 +118,10 @@ make $bin_type-$host_os-$host_arch
|
||||||
# copy the binary to the server
|
# copy the binary to the server
|
||||||
info "deploying..."
|
info "deploying..."
|
||||||
info "copying binary to host $host..."
|
info "copying binary to host $host..."
|
||||||
scp build/bbgo/$bin_type-$host_os-$host_arch $host:$bin_dir/bbgo-$tag
|
scp build/bbgo/$bin_type-$host_os-$host_arch $host:$host_bin_dir/bbgo-$tag
|
||||||
|
|
||||||
# link binary and restart the systemd service
|
# link binary and restart the systemd service
|
||||||
info "linking binary and restarting..."
|
info "linking binary and restarting..."
|
||||||
ssh $host "(cd $target && ln -sf \$HOME/$bin_dir/bbgo-$tag bbgo && systemctl restart $target.service)"
|
ssh $host "(cd $target && ln -sf \$HOME/$host_bin_dir/bbgo-$tag bbgo && systemctl restart $target.service)"
|
||||||
|
|
||||||
info "deployed successfully!"
|
info "deployed successfully!"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user