This commit is contained in:
spiritlhl 2023-06-23 14:02:51 +00:00
parent 4666ea0014
commit 4332baec6f

View file

@ -25,14 +25,14 @@ temp_file_apt_fix="/tmp/apt_fix.txt"
remove_duplicate_lines() {
chattr -i "$1"
# 去除重复行并跳过空行和注释行
if [ -f "$1" ]; then
awk '!/^( *#|$)/ { if (!x[$0]++) print }' "$1" > "$1.tmp" && mv -f "$1.tmp" "$1"
awk 'NF && !/^( *#|$)/ { if (!x[$0]++) print; next } { print }' "$1" > "$1.tmp" && mv -f "$1.tmp" "$1"
fi
rm -rf "$1.tmp"
chattr +i "$1"
}
install_package() {
package_name=$1
if command -v $package_name > /dev/null 2>&1 ; then