Skip to content

Commit 32f3cd2

Browse files
committed
适配 PVE 9 并优化 PVE 换源
1 parent 5b925e4 commit 32f3cd2

1 file changed

Lines changed: 67 additions & 17 deletions

File tree

ChangeMirrors.sh

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
## Author: SuperManito
3-
## Modified: 2026-01-04
3+
## Modified: 2026-01-16
44
## License: MIT
55
## GitHub: https://github.com/SuperManito/LinuxMirrors
66
## Website: https://linuxmirrors.cn
@@ -252,7 +252,12 @@ File_ArmbianSourceList=$Dir_AptAdditionalSources/armbian.list
252252
File_ArmbianSourceListBackup=$File_ArmbianSourceList.bak
253253
File_ProxmoxSourceList=$Dir_AptAdditionalSources/pve-no-subscription.list
254254
File_ProxmoxSourceListBackup=$File_ProxmoxSourceList.bak
255-
File_ProxmoxAPLInfo=/usr/share/perl5/PVE/APLInfo.pm
255+
File_ProxmoxSources=$Dir_AptAdditionalSources/pve-no-subscription.sources
256+
File_ProxmoxSourcesBackup=$File_ProxmoxSources.bak
257+
File_ProxmoxCephSourceList=$Dir_AptAdditionalSources/ceph.list
258+
File_ProxmoxCephSourceListBackup=$File_ProxmoxCephSourceList.bak
259+
File_ProxmoxCephSources=$Dir_AptAdditionalSources/ceph.sources
260+
File_ProxmoxCephSourcesBackup=$File_ProxmoxCephSources.bak
256261
File_LinuxMintSourceList=$Dir_AptAdditionalSources/official-package-repositories.list
257262
File_LinuxMintSourceListBackup=$File_LinuxMintSourceList.bak
258263
File_RaspberryPiSourceList=$Dir_AptAdditionalSources/raspi.list
@@ -1540,7 +1545,13 @@ function backup_original_mirrors() {
15401545
fi
15411546
# Proxmox VE
15421547
if [ -f "${File_ProxmoxVersion}" ]; then
1543-
backup_file $File_ProxmoxSourceList $File_ProxmoxSourceListBackup "pve-no-subscription.list"
1548+
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
1549+
backup_file $File_ProxmoxSources $File_ProxmoxSourcesBackup "pve-no-subscription.sources"
1550+
[ -f "${File_ProxmoxCephSources}" ] && backup_file $File_ProxmoxCephSources $File_ProxmoxCephSourcesBackup "ceph.sources"
1551+
else
1552+
backup_file $File_ProxmoxSourceList $File_ProxmoxSourceListBackup "pve-no-subscription.list"
1553+
[ -f "${File_ProxmoxCephSourceList}" ] && backup_file $File_ProxmoxCephSourceList $File_ProxmoxCephSourceListBackup "ceph.list"
1554+
fi
15441555
fi
15451556
# Linux Mint
15461557
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_LINUX_MINT}" ]]; then
@@ -1625,7 +1636,15 @@ function remove_original_mirrors() {
16251636
# Armbian
16261637
[ -f "${File_ArmbianRelease}" ] && clear_file $File_ArmbianSourceList
16271638
# Proxmox VE
1628-
[ -f "${File_ProxmoxVersion}" ] && clear_file $File_ProxmoxSourceList
1639+
if [ -f "${File_ProxmoxVersion}" ]; then
1640+
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
1641+
clear_file $File_ProxmoxSources
1642+
[ -f "${File_ProxmoxCephSources}" ] && clear_file $File_ProxmoxCephSources
1643+
else
1644+
clear_file $File_ProxmoxSourceList
1645+
[ -f "${File_ProxmoxCephSourceList}" ] && clear_file $File_ProxmoxCephSourceList
1646+
fi
1647+
fi
16291648
# Linux Mint
16301649
[[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_LINUX_MINT}" ]] && clear_file $File_LinuxMintSourceList
16311650
# Raspberry Pi OS
@@ -1803,7 +1822,13 @@ function change_mirrors_main() {
18031822
fi
18041823
# Proxmox VE
18051824
if [ -f "${File_ProxmoxVersion}" ]; then
1806-
diff_file $File_ProxmoxSourceListBackup $File_ProxmoxSourceList
1825+
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
1826+
diff_file $File_ProxmoxSourcesBackup $File_ProxmoxSources
1827+
[ -f "${File_ProxmoxCephSources}" ] && diff_file $File_ProxmoxCephSourcesBackup $File_ProxmoxCephSources
1828+
else
1829+
diff_file $File_ProxmoxSourceListBackup $File_ProxmoxSourceList
1830+
[ -f "${File_ProxmoxCephSourceList}" ] && diff_file $File_ProxmoxCephSourceListBackup $File_ProxmoxCephSourceList
1831+
fi
18071832
fi
18081833
# Linux Mint
18091834
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_LINUX_MINT}" ]]; then
@@ -2132,6 +2157,9 @@ Signed-By: /usr/share/keyrings/${SYSTEM_JUDGMENT,,}-archive-keyring.gpg"
21322157
21332158
$(_template_deb822 "deb-src" "${1}" "${2}" "${3}" | sed -e "s|^|# |g")"
21342159
}
2160+
function gen_deb822_unsrc() {
2161+
echo "$(_template_deb822 "deb" "${1}" "${2}" "${3}")"
2162+
}
21352163
function gen_deb822_disabled() {
21362164
echo "$(_template_deb822 "deb" "${1}" "${2}" "${3}" | sed -e "s|^|# |g")
21372165
@@ -2549,17 +2577,39 @@ $(gen_deb "${source_address}" "${base_system_codename}" "${repo_components}")"
25492577
fi
25502578
# Proxmox VE
25512579
if [ -f "${File_ProxmoxVersion}" ]; then
2552-
source_address="${SOURCE}/proxmox/debian"
2553-
apt_source_file="${File_ProxmoxSourceList}"
2554-
apt_source_content="$(gen_deb_unsrc "${source_address}/pve" "${SYSTEM_VERSION_CODENAME}" "pve-no-subscription")
2555-
$(gen_deb_unsrc_disabled "${source_address}/pbs" "${SYSTEM_VERSION_CODENAME}" "pbs-no-subscription")
2556-
$(gen_deb_unsrc_disabled "${source_address}/pbs-client" "${SYSTEM_VERSION_CODENAME}" "pbs-client-no-subscription")
2557-
$(gen_deb_unsrc_disabled "${source_address}/pmg" "${SYSTEM_VERSION_CODENAME}" "pmg-no-subscription")"
2558-
write_apt_source
2559-
if [ -s "${File_ProxmoxAPLInfo}" ]; then
2560-
sed -e "s|url => [\"']https\?://[^/]*/images[\"']|url => \"${WEB_PROTOCOL}://${SOURCE}/images\"|g" \
2580+
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
2581+
source_address="download.proxmox.com"
2582+
else
2583+
source_address="${SOURCE}/proxmox"
2584+
fi
2585+
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
2586+
apt_source_file="${File_ProxmoxSources}"
2587+
apt_source_content="$(gen_deb822_unsrc "${source_address}/debian/pve" "${SYSTEM_VERSION_CODENAME}" "pve-no-subscription")"
2588+
write_apt_source
2589+
# Ceph 仓库
2590+
if [ -f "${File_ProxmoxCephSources}" ]; then
2591+
local ceph_codename="$(ceph -v | grep ceph | awk '{print $(NF-1)}')"
2592+
apt_source_file="${File_ProxmoxCephSources}"
2593+
apt_source_content="$(gen_deb822_unsrc "${source_address}/debian/ceph-${ceph_codename}" "${SYSTEM_VERSION_CODENAME}" "no-subscription")"
2594+
write_apt_source
2595+
fi
2596+
else
2597+
apt_source_file="${File_ProxmoxSourceList}"
2598+
apt_source_content="$(gen_deb_unsrc "${source_address}/debian/pve" "${SYSTEM_VERSION_CODENAME}" "pve-no-subscription")"
2599+
write_apt_source
2600+
# Ceph 仓库
2601+
if [ -f "${File_ProxmoxCephSourceList}" ]; then
2602+
local ceph_codename="$(ceph -v | grep ceph | awk '{print $(NF-1)}')"
2603+
apt_source_file="${File_ProxmoxCephSourceList}"
2604+
apt_source_content="$(gen_deb_unsrc "${source_address}/debian/ceph-${ceph_codename}" "${SYSTEM_VERSION_CODENAME}" "no-subscription")"
2605+
write_apt_source
2606+
fi
2607+
fi
2608+
# CT Templates
2609+
if [ -s /usr/share/perl5/PVE/APLInfo.pm ]; then
2610+
sed -e "s|url => [\"']https\?://[^/]*/images[\"']|url => \"${WEB_PROTOCOL}://${source_address}/images\"|g" \
25612611
-i \
2562-
$File_ProxmoxAPLInfo
2612+
/usr/share/perl5/PVE/APLInfo.pm
25632613
fi
25642614
fi
25652615
}
@@ -7012,7 +7062,7 @@ baseurl=https://mirrors.openanolis.cn/anolis/$releasever/Plus/$basearch/debug
70127062
enabled=0
70137063
gpgkey=https://mirrors.openanolis.cn/anolis/RPM-GPG-KEY-ANOLIS
70147064
gpgcheck=1
7015-
7065+
70167066
[PowerTools-debuginfo]
70177067
name=AnolisOS-$releasever - PowerTools Debuginfo
70187068
baseurl=https://mirrors.openanolis.cn/anolis/$releasever/PowerTools/$basearch/debug
@@ -7080,7 +7130,7 @@ baseurl=https://mirrors.openanolis.cn/anolis/$releasever/Plus/source/
70807130
enabled=0
70817131
gpgkey=https://mirrors.openanolis.cn/anolis/RPM-GPG-KEY-ANOLIS
70827132
gpgcheck=1
7083-
7133+
70847134
[PowerTools-source]
70857135
name=AnolisOS-$releasever - PowerTools Source
70867136
baseurl=https://mirrors.openanolis.cn/anolis/$releasever/PowerTools/source/

0 commit comments

Comments
 (0)