init/clean.sh
Martin 28188cf5c0
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 11s
[+] 增加 traefik 清理
2025-03-12 09:04:53 +08:00

45 lines
1.2 KiB
Bash

# 列出磁盘空间
df -h
# 清理 apt
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean -y
# 清理 docker
docker system prune -a -f --volumes
# 清理日志
sudo journalctl --vacuum-size=10M
# 列出清理后容器大小
docker ps -a --format "{{.ID}}\t{{.Image}}\t{{.Size}}"
docker images --format "{{.Repository}}:{{.Tag}}\t{{.Size}}"
# 查看占用磁盘
# du -ah -d 1 /
if [ -d "/root/act_runner" ] && docker images | grep -q "docker.martin98.com/library/gitea/act_runner"; then
echo "清理 act_runner"
docker volume rm act-toolcache
cd /root/act_runner
sh run.sh
fi
if [ -d "/root/git-proxy" ] && docker images | grep -q "docker.martin98.com/library/hunsh/gh-proxy-py:latest"; then
echo "清理 git-proxy"
cd /root/git-proxy
sh restart.sh
fi
if [ -d "/root/registry" ] && docker images | grep -q "registry"; then
echo "清理 registry"
cd /root/registry
sh restart.sh
fi
if [ -d "/root/registry" ] && docker ps --format '{{.ID}} {{.Image}}' | grep -q 'traefik'; then
echo "清理 Traefik"
container_id=$(docker ps --format '{{.ID}} {{.Image}}' | grep 'traefik' | awk '{print $1}')
docker exec -it $container_id sh -c "rm -rf /tmp/*"
fi
# 列出磁盘空间
df -h