2023.12.31

This commit is contained in:
spiritlhl 2023-12-31 09:20:23 +00:00
parent a4903e0655
commit 0e425eff6e
5 changed files with 81 additions and 5 deletions

View file

@ -1,5 +1,9 @@
# 更新日志
2023.12.27
- 修复部分宿主机安装过程中可能存在```firmware-ath9k-htc```需要移除的情况
2023.12.21
- 修复部分宿主机和LXC容器不含定时任务机制的问题

View file

@ -13,9 +13,10 @@
## 更新
2023.12.27
2023.12.31
- 修复部分宿主机安装过程中可能存在```firmware-ath9k-htc```需要移除的情况
- 增加一个删除对应容器/虚拟机的脚本,避免在删除过程中删除了非对应的映射规则
- 修复批量开设时最后一个循环后续没有要等待的内容还去等待的问题
[更新日志](CHANGELOG.md)

View file

@ -1,7 +1,7 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.07.31
# 2023.12.31
# cd /root
@ -204,6 +204,9 @@ build_new_cts() {
./buildct.sh $ct_num $password $cpu_nums $memory_nums $disk_nums $ssh_port $web1_port $web2_port $port_start $port_end $system $storage $independent_ipv6
cat "ct$ct_num" >>ctlog
rm -rf "ct$ct_num"
if [ "$i" = "$new_nums" ]; then
break
fi
sleep 30
done
}

View file

@ -1,7 +1,7 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.07.31
# 2023.12.31
# cd /root
@ -242,7 +242,10 @@ build_new_vms() {
./buildvm.sh $vm_num $user $password $cpu_nums $memory_nums $disk_nums $ssh_port $web1_port $web2_port $port_start $port_end $system $storage $independent_ipv6
cat "vm$vm_num" >>vmlog
rm -rf "vm$vm_num"
sleep 60
if [ "$i" = "$new_nums" ]; then
break
fi
sleep 30
done
}

65
scripts/pve_delete.sh Normal file
View file

@ -0,0 +1,65 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.12.31
# ./pve_delete.sh arg1 arg2
# arg 可填入虚拟机/容器的序号,可以有任意多个
# 输入解析
args=("$@")
num_args=${#args[@]}
# 虚拟机操作
vmids=$(qm list | awk '{if(NR>1)print $1}')
if [ -n "$vmids" ]; then
# 遍历每个VMID的config提取ip=到/24之间的内容
for vmid in $vmids; do
ip_address=$(qm config $vmid | grep -oP 'ip=\K[0-9.]+')
if [ ! -z "$ip_address" ]; then
vmip_array["$vmid"]=$ip_address
fi
done
for key_1 in "${!vmip_array[@]}"; do
for key_2 in "${args[@]}"; do
if [ "$key_1" = "$key_2" ]; then
ip_address="${vmip_array[$key_1]}"
echo "Delete VMID $key_1 IP Address $ip_address Mapping"
sed -i "/$ip_address:/d" /etc/iptables/rules.v4
qm stop $vmid
qm destroy $vmid
rm -rf /var/lib/vz/images/$vmid*
rm -rf vm"$key_1"
fi
done
done
fi
# 容器操作
ctids=$(pct list | awk '{if(NR>1)print $1}')
if [ -n "$ctids" ]; then
# 遍历每个CTID的config提取ip=到/24之间的内容
for ctid in $ctids; do
ip_address=$(pct config $ctid | grep -oP 'ip=\K[0-9.]+')
if [ ! -z "$ip_address" ]; then
ctip_array["$ctid"]=$ip_address
fi
done
for key_1 in "${!ctip_array[@]}"; do
for key_2 in "${args[@]}"; do
if [ "$key_1" = "$key_2" ]; then
ip_address="${ctip_array[$key_1]}"
echo "Delete CTID $key_1 IP Address $ip_address Mapping"
sed -i "/$ip_address:/d" /etc/iptables/rules.v4
pct stop "$key_1"
pct destroy "$key_1"
rm -rf ct"$key_1"
fi
done
done
fi
# 其他相关操作
cat /etc/iptables/rules.v4 | iptables-restore
service networking restart
systemctl restart networking.service
systemctl restart ndpresponder.service