mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-03-04 01:38:12 +08:00
Update install_pve.sh
This commit is contained in:
parent
def53e835a
commit
976fd23b65
1 changed files with 24 additions and 25 deletions
|
@ -17,7 +17,7 @@ else
|
||||||
export LANGUAGE="$utf8_locale"
|
export LANGUAGE="$utf8_locale"
|
||||||
echo "Locale set to $utf8_locale"
|
echo "Locale set to $utf8_locale"
|
||||||
fi
|
fi
|
||||||
|
temp_file_apt_fix="/tmp/apt_fix.txt"
|
||||||
|
|
||||||
# 前置环境安装
|
# 前置环境安装
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
@ -32,10 +32,9 @@ fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
apt-get install gnupg -y
|
apt-get install gnupg -y
|
||||||
fi
|
fi
|
||||||
if command -v apt-get > /dev/null 2>&1; then
|
apt_update_output=$(apt-get update 2>&1)
|
||||||
apt_update_output=$(apt-get update 2>&1)
|
echo "$apt_update_output" > "$temp_file_apt_fix"
|
||||||
echo "$apt_update_output" > "$temp_file_apt_fix"
|
if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then
|
||||||
if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then
|
|
||||||
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
||||||
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
||||||
_yellow "No Public Keys: ${joined_keys}"
|
_yellow "No Public Keys: ${joined_keys}"
|
||||||
|
@ -44,9 +43,8 @@ if command -v apt-get > /dev/null 2>&1; then
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
_green "Fixed"
|
_green "Fixed"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
rm "$temp_file_apt_fix"
|
|
||||||
fi
|
fi
|
||||||
|
rm "$temp_file_apt_fix"
|
||||||
if ! command -v wget > /dev/null 2>&1; then
|
if ! command -v wget > /dev/null 2>&1; then
|
||||||
apt-get install -y wget
|
apt-get install -y wget
|
||||||
fi
|
fi
|
||||||
|
@ -243,16 +241,17 @@ if [ $? -ne 0 ]; then
|
||||||
apt-get install debian-keyring debian-archive-keyring -y
|
apt-get install debian-keyring debian-archive-keyring -y
|
||||||
apt-get update -y && apt-get full-upgrade -y
|
apt-get update -y && apt-get full-upgrade -y
|
||||||
fi
|
fi
|
||||||
output=$(apt-get update 2>&1)
|
apt_update_output=$(apt-get update 2>&1)
|
||||||
if echo $output | grep -q "NO_PUBKEY"; then
|
echo "$apt_update_output" > "$temp_file_apt_fix"
|
||||||
echo "Some keys are missing, attempting to retrieve them now..."
|
if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then
|
||||||
missing_keys=$(echo $output | grep "NO_PUBKEY" | awk -F' ' '{print $NF}')
|
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
||||||
for key in $missing_keys; do
|
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
||||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
|
_yellow "No Public Keys: ${joined_keys}"
|
||||||
done
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${joined_keys}
|
||||||
apt-get update
|
apt-get update
|
||||||
else
|
if [ $? -eq 0 ]; then
|
||||||
echo "All keys are present."
|
_green "Fixed"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
output=$(apt-get update 2>&1)
|
output=$(apt-get update 2>&1)
|
||||||
if echo $output | grep -q "NO_PUBKEY"; then
|
if echo $output | grep -q "NO_PUBKEY"; then
|
||||||
|
|
Loading…
Reference in a new issue