## spug

### test
1.本地动作：拉取代码build
```shell
ssh root@114.132.85.7 'bash -s' << 'EOF'
cd /home/lqh/apps/job-admin
git fetch --all
git reset --hard origin/master
docker-compose -f docker-compose-test.yml build
EOF
```

2.目标主机动作：docker-compose部署
```shell
docker-compose -f /home/lqh/apps-yml/dc-rcsc-admin.yaml up -d --force-recreate
docker system prune -f --filter "label!=17"
```


----
### prod
1.本地动作：拉取代码build
```shell
ssh root@114.132.85.7 'bash -s' << 'EOF'
cd /home/lqh/apps/job-admin
git fetch --all
git reset --hard origin/master
docker-compose -f docker-compose.yml build
docker-compose -f docker-compose.yml push
docker rmi $(docker images -f "dangling=true" -q)
EOF
```
2.目标主机动作：docker-compose部署
```shell
docker pull registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:rcsc_admin_prod_latest
docker-compose -f /home/lqh/apps-yml/dc-rcsc-admin.yaml up -d --force-recreate
docker rmi $(docker images -f "dangling=true" -q)
```

### https证书检测
```shell
#!/bin/bash

# 要检查的域名
DOMAIN="admin1.jcjob.cn"

# 检查证书是否过期
DAYS_LEFT=$(openssl s_client -connect "$DOMAIN":443 -servername "$DOMAIN" -showcerts </dev/null 2>/dev/null | openssl x509 -noout -enddate | awk -F= '{print $2}' | xargs -I {} date -d {} +%s)
CURRENT_TIME=$(date +%s)
THRESHOLD_DAYS=7

# 计算剩余天数
REMAINING_DAYS=$(( (DAYS_LEFT - CURRENT_TIME) / 86400 ))

# 判断是否即将过期
if [ "$REMAINING_DAYS" -lt "$THRESHOLD_DAYS" ]; then
    echo "($DOMAIN)SSL证书即将过期，剩余$REMAINING_DAYS天！"
    # 在此处添加其他操作，例如发送警报邮件或自动续期
else
    echo "($DOMAIN)SSL证书仍然有效，剩余$REMAINING_DAYS天。"
fi
```