Files
webp/update.sh

26 lines
517 B
Bash
Executable File

#!/bin/bash
host="root@main"
# 更新 go mod, 然後靜態編譯
go mod tidy
go build -o dist/main bin/main.go
# 重命名旧文件
ssh $host "mv ~/webp/main ~/webp/main_old"
# 上传到服务器, 然後刪除本地文件
scp dist/main $host:~/webp/main
rm -rf dist
# 重载服务
ssh $host "systemctl restart webp"
# 删除旧文件
ssh $host "rm ~/webp/main_old"
# 设为系统服务
# sudo cp webp.service /etc/systemd/system/webp.service
# 设置日志轮转
# sudo cp webp.logrotate /etc/logrotate.d/webp