增加远程脚本

This commit is contained in:
Olia Lisa 2026-01-17 17:24:22 +08:00
parent 771abcf074
commit f2be5c8720
2 changed files with 31 additions and 0 deletions

3
bin/remote/README.md Normal file
View File

@ -0,0 +1,3 @@
## 说明
这个文件夹的文件用于被其他主机(本地电脑)远程调用. 不要导入使用.

View File

@ -0,0 +1,28 @@
#!/bin/bash
update_docker_images(){
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../" # 脚本文件绝对路径
local docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径
# 检查是否存在 docker-compose.yml 文件
if [ ! -f $docker_compose_file ]; then
echo "Error: docker-compose.yml 文件不存在."
exit 1
fi
echo "正在关闭容器.."
docker-compose -f $docker_compose_file down
echo "正在更新镜像.."
docker-compose -f $docker_compose_file pull
echo "正在删除未使用的镜像..."
docker image prune -f
echo "正在启动容器.."
docker-compose -f $docker_compose_file up -d
}
update_docker_images