#!/bin/bash# 域名列表domains=("www.qq.com" "www.qq.com.cn" "www.ww.cn")#查询/etc/nginx/conf.d/*.conf配置文件中的域名,并去重,sh不支持数组,如果用这种方式 需要bash环境运行#domains=($(grep -hroP 'server_name\s+\K\S+' /etc/nginx/conf.d/*.conf | tr -d ';' | sort -u))# 企业微信群聊机器人的 Webhook 地址webhook_url="https://123/123"# 循环遍历域名列表for domain in "${domains[@]}"; doecho "$domain"# 查询域名的证书有效期expiration_date=$(openssl s_client -connect "$domain":443 -servername "$domain" 2>/dev/null | openssl x509 -noout -dates | grep notAfter | cut -d "=" -f 2)echo "Certificate expiration for $domain: $expiration_date"# 将日期转换为时间戳expiration_timestamp=$(date -d "$expiration_date" +%s)# 当前时间戳current_timestamp=$(date +%s)# 计算剩余天数remaining_days=$(( (expiration_timestamp - current_timestamp) / 86400 ))# 如果剩余天数小于等于10天,则发送警告消息到企业微信群聊机器人if [ $remaining_days -le 10 ]; thensubject="SSL Certificate Expiration Warning - $domai
#命令备忘#当前目录下,文件和文件夹按大小排序并显示大小du -sh * | sort -hr#显示当前目录下所有文件夹的大小du --max-depth=1 -h#查看一个进程的父进程lsof -p <PID>pstree -p <PID>pstree -p | grep "<PID>"#系统日志指定大小和保留时间journalctl --vacuum-time=2djournalctl --vacuum-size=500M#npm源npm install --registry=https://registry.npm.taobao.orgnpm install --registry=https://registry.npmmirror.comnpm install --registry=https://mirrors.cloud.tencent.com/npm/#phpinfo<?phpphpinfo();?>#docker打tag并推送至远程仓库 harbor.net替换为仓库地址docker build --tag imagename:v$BUILD_ID .docker tag imagename:v$BUILD_ID harbor.net/imagename:v$BUILD_IDdocker push harbor.net/imagename:v$BUILD_ID
#!/bin/sh#关闭SeLinuxsed -i 's/enforcing/disabled/g' /etc/sysconfig/selinuxsetenforce 0#关闭防火墙systemctl stop firewalldsystemctl disable firewalld#安装gcc gcc-c++等基础组件tar zxvf package.tar.gzcd packagerpm -Uvh *.rpm --nodeps --forcecd ../#安装apache#安装aprtar zxvf apr-1.7.0.tar.gzcd apr-1.7.0./configure --prefix=/usr/local/aprmake && make installcd ../#安装apr-utiltar zxvf apr-util-1.6.1.tar.gzcd apr-util-1.6.1./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make installcd ../#安装pcretar zxvf pcre-8.00.tar.gzcd pcre-8.00./configure --prefix=/usr/local/pcremake && make installcd ../#安装httpdtar zxvf httpd-2.4.48.tar.gzcd httpd-2.4.48./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr -with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcremake && make installcd ../#设置开机自启动cp -r /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpdsed -i '1 i\#description:Start and stop the Apache HTTP Server' /etc
#!/bin/bash# 创建日志文件目录log_dir="/data/update_logs"#mkdir -p "$log_dir"# 日志文件路径,按日切割log_file="$log_dir/update_$(date +%Y%m%d).log"# 获取当前时间current_time=$(date +"%Y-%m-%d %H:%M:%S")# 获取后端镜像仓库中最新的版本号(去掉前缀"v")v1=$(curl -u user:passwd -X GET "https://harbor.test.com.cn/api/v2.0/projects/children/repositories/tx-svc-wxchat-online/artifacts" | jq -r 'sort_by(.push_time) | .[-1].tags[0].name' | sed 's/v//')# 获取当前正在运行的后端容器的版本号v2=$(docker inspect --format='{{ index .Config.Image }}' tx-svc-wxchat-online | awk -F':' '{print $NF}' | cut -c2-)# 检查后端是否需要更新if [ "$v1" -gt "$v2" ]; thenecho "$current_time 需要更新,后端最新版本号:$v1" >> "$log_file"# 执行后端更新操作ansible-playbook /data/update_server.yaml --extra-vars "tag=$v1" >> "$log_file" 2>&1# 发送企业微信消息webhook_url="https://123/123"message="后端镜像更新成功,新版本:$v1"curl -s -H "Content-Type: application/json" -d "{\"msgtype\":\"text\",\"text\":{\"content\":\"$message\"}}"