forked from fatekey/gcp_free
-
Notifications
You must be signed in to change notification settings - Fork 1
Remote Scripts
Matrtex edited this page Jun 7, 2026
·
1 revision
远程执行逻辑集中在 gcp_remote.py。
支持两种模式:
gcloud compute ssh/scp- 原生
ssh/scp
默认优先使用 gcloud 模式。只有显式传 --remote-method ssh 或本机无法使用 gcloud 时,才使用原生 SSH。
本地脚本位于 scripts/:
| 脚本 | 用途 |
|---|---|
apt.sh |
Debian / Ubuntu 换源 |
dae.sh |
安装 dae
|
net_iptables.sh |
按月流量限额追加 iptables 限制 |
net_shutdown.sh |
超额自动关机 |
上传脚本前会统一转换为 LF 行尾,避免 Windows CRLF 导致远程 shell 执行异常。
远程脚本执行命令内置 trap cleanup EXIT,正常和失败路径都会删除远端临时脚本。
deploy_dae_config() 会:
- 解析本地
config.dae。 - 检测远程 OS。
- 上传到
/tmp/gcp_free_config_*.dae。 - 复制到
/usr/local/etc/dae/config.dae。 - 设置权限为
600。 - enable 并 restart
dae。 - 删除远端临时文件。
如果上传后应用命令构建失败或应用步骤失败,会额外发起 rm -f 清理远端临时配置文件。清理失败只告警,不覆盖原始失败结果。
dry-run 只打印命令,不实际执行远程操作:
.\start.ps1 run-script --project-id <项目ID> --account <账号邮箱> --instance <实例名> --zone <可用区> --dry-run apt本文档维护于 Matrtex/gcp_free。代码内文档见 README.md、contexts/context.md 和 docs/wiki.md。