mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-13 16:32:23 +00:00
Update common-functions.sh
This commit is contained in:
parent
75c12e2d4b
commit
3598906cbd
@ -156,6 +156,26 @@ cleanup_duplicate_repos_pve9_() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -f "/etc/apt/sources.list.d/debian.sources" ]; then
|
||||||
|
for uri in $(grep -E '^UR[IL]:' /etc/apt/sources.list.d/debian.sources | awk '{print $2}'); do
|
||||||
|
if [[ "$uri" == *security.debian.org* ]]; then
|
||||||
|
if grep -q "^deb.*${uri//\//\\/}" "$sources_file"; then
|
||||||
|
sed -i "/^deb.*${uri//\//\\/}/s/^/# /" "$sources_file"
|
||||||
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
msg_info "$(translate "Commented security.debian.org lines in sources.list (using .sources format)")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for list_file in /etc/apt/sources.list.d/*.list; do
|
||||||
|
[[ -f "$list_file" ]] || continue
|
||||||
|
if grep -q "^deb.*${uri//\//\\/}" "$list_file"; then
|
||||||
|
sed -i "/^deb.*${uri//\//\\/}/s/^/# /" "$list_file"
|
||||||
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
msg_info "$(translate "Commented security.debian.org lines in $(basename "$list_file") (using .sources format)")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$cleaned_count" -gt 0 ]; then
|
if [ "$cleaned_count" -gt 0 ]; then
|
||||||
msg_ok "$(translate "Cleaned up $cleaned_count duplicate/old repositories")"
|
msg_ok "$(translate "Cleaned up $cleaned_count duplicate/old repositories")"
|
||||||
@ -169,20 +189,22 @@ cleanup_duplicate_repos_pve9_() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cleanup_duplicate_repos_pve9() {
|
cleanup_duplicate_repos_pve9() {
|
||||||
msg_info "$(translate "Cleaning up duplicate repositories...")"
|
msg_info "$(translate "Cleaning up duplicate repositories...")"
|
||||||
|
|
||||||
local sources_file="/etc/apt/sources.list"
|
local sources_file="/etc/apt/sources.list"
|
||||||
local temp_file=$(mktemp)
|
local temp_file
|
||||||
local cleaned_count=0
|
local cleaned_count=0
|
||||||
declare -A seen_repos
|
declare -A seen_repos
|
||||||
|
|
||||||
|
|
||||||
|
temp_file=$(mktemp)
|
||||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||||
if [[ "$line" =~ ^[[:space:]]*# ]] || [[ -z "$line" ]]; then
|
if [[ "$line" =~ ^[[:space:]]*# ]] || [[ -z "$line" ]]; then
|
||||||
echo "$line" >> "$temp_file"
|
echo "$line" >> "$temp_file"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$line" =~ ^deb ]]; then
|
if [[ "$line" =~ ^deb ]]; then
|
||||||
read -r _ url dist components <<< "$line"
|
read -r _ url dist components <<< "$line"
|
||||||
local key="${url}_${dist}"
|
local key="${url}_${dist}"
|
||||||
@ -197,43 +219,33 @@ cleanup_duplicate_repos_pve9() {
|
|||||||
echo "$line" >> "$temp_file"
|
echo "$line" >> "$temp_file"
|
||||||
fi
|
fi
|
||||||
done < "$sources_file"
|
done < "$sources_file"
|
||||||
|
|
||||||
mv "$temp_file" "$sources_file"
|
mv "$temp_file" "$sources_file"
|
||||||
chmod 644 "$sources_file"
|
chmod 644 "$sources_file"
|
||||||
|
|
||||||
for src in proxmox debian ceph; do
|
|
||||||
local sources_path="/etc/apt/sources.list.d/${src}.sources"
|
|
||||||
if [ -f "$sources_path" ]; then
|
|
||||||
case "$src" in
|
|
||||||
proxmox)
|
|
||||||
url_match="download.proxmox.com"
|
|
||||||
;;
|
|
||||||
debian)
|
|
||||||
url_match="deb.debian.org"
|
|
||||||
;;
|
|
||||||
ceph)
|
|
||||||
url_match="download.proxmox.com/ceph"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
url_match=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ -n "$url_match" ]]; then
|
for sources_path in /etc/apt/sources.list.d/*.sources; do
|
||||||
if grep -q "^deb.*$url_match" "$sources_file"; then
|
[[ -f "$sources_path" ]] || continue
|
||||||
sed -i "/^deb.*$url_match/s/^/# /" "$sources_file"
|
|
||||||
cleaned_count=$((cleaned_count + 1))
|
if ! grep -qi '^Enabled: *true' "$sources_path"; then
|
||||||
fi
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r uri; do
|
||||||
|
|
||||||
|
if grep -q "^deb.*${uri//\//\\/}" "$sources_file"; then
|
||||||
|
sed -i "/^deb.*${uri//\//\\/}/s/^/# /" "$sources_file"
|
||||||
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
msg_info "$(translate "Commented duplicated repo ($uri) in sources.list")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for list_file in /etc/apt/sources.list.d/*.list; do
|
for list_file in /etc/apt/sources.list.d/*.list; do
|
||||||
[[ -f "$list_file" ]] || continue
|
[[ -f "$list_file" ]] || continue
|
||||||
if grep -q "^deb.*$url_match" "$list_file"; then
|
if grep -q "^deb.*${uri//\//\\/}" "$list_file"; then
|
||||||
sed -i "/^deb.*$url_match/s/^/# /" "$list_file"
|
sed -i "/^deb.*${uri//\//\\/}/s/^/# /" "$list_file"
|
||||||
cleaned_count=$((cleaned_count + 1))
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
msg_info "$(translate "Commented duplicated repo ($uri) in $(basename "$list_file")")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
done < <(grep -E '^UR[IL]:' "$sources_path" | awk '{print $2}')
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $cleaned_count -gt 0 ]; then
|
if [ $cleaned_count -gt 0 ]; then
|
||||||
@ -248,6 +260,7 @@ cleanup_duplicate_repos_pve9() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cleanup_duplicate_repos_pve8() {
|
cleanup_duplicate_repos_pve8() {
|
||||||
msg_info "$(translate "Cleaning up duplicate repositories...")"
|
msg_info "$(translate "Cleaning up duplicate repositories...")"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user