Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Aug 22, 2023
1 parent e2a0a82 commit eea44a5
Show file tree
Hide file tree
Showing 20 changed files with 1,063 additions and 1,081 deletions.
28 changes: 13 additions & 15 deletions dockerfiles/Dockerfile_aarch64_7
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
FROM debian:11

# Set official Debian sources
RUN rm /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://security.debian.org/debian-security bullseye-security main contrib" >> /etc/apt/sources.list
RUN rm /etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye-backports main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://security.debian.org/debian-security bullseye-security main contrib" >>/etc/apt/sources.list

# Install base packages
RUN apt-get update && \
RUN apt-get update &&
apt-get install wget systemd nano vim curl gnupg ca-certificates -y

#add proxmox repo
#use jiangcuo_proxmox_arm64 https://github.com/jiangcuo/Proxmox-Arm64
RUN echo "deb https://global.mirrors.apqa.cn/proxmox/ pvearm main">/etc/apt/sources.list.d/foxi.list && \
wget --no-check-certificate https://global.mirrors.apqa.cn/proxmox/gpg.key -O /etc/apt/trusted.gpg.d/gpg.key && \
RUN echo "deb https://global.mirrors.apqa.cn/proxmox/ pvearm main" >/etc/apt/sources.list.d/foxi.list &&
wget --no-check-certificate https://global.mirrors.apqa.cn/proxmox/gpg.key -O /etc/apt/trusted.gpg.d/gpg.key &&
chmod +r /etc/apt/trusted.gpg.d/gpg.key


#intall proxmox-ve without recommends.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractiv apt-get -y --no-install-recommends install proxmox-ve || echo ok

#intall proxmox-ve without recommends.
RUN apt-get update &&
DEBIAN_FRONTEND=noninteractiv apt-get -y --no-install-recommends install proxmox-ve || echo ok

#set passwd for root
RUN echo "root:root"|chpasswd
RUN echo "root:root" | chpasswd

#clean
RUN rm -rf /var/lib/apt/lists/* /*.deb
RUN rm -rf /var/lib/apt/lists/* /*.deb

#use setup.sh to start proxmox service
STOPSIGNAL SIGINT
Expand Down
52 changes: 26 additions & 26 deletions dockerfiles/Dockerfile_x86_64_7
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
FROM debian:11

# Set official Debian sources
RUN rm /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://security.debian.org/debian-security bullseye-security main contrib" >> /etc/apt/sources.list
RUN rm /etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://deb.debian.org/debian/ bullseye-backports main contrib non-free" >>/etc/apt/sources.list &&
echo "deb http://security.debian.org/debian-security bullseye-security main contrib" >>/etc/apt/sources.list

# Install base packages
RUN apt-get update && \
RUN apt-get update &&
apt-get install wget systemd nano vim curl gnupg ca-certificates -y

#add proxmox repo
RUN echo "deb http://mirrors.ustc.edu.cn/proxmox/debian/ bullseye pve-no-subscription" >>/etc/apt/sources.list && \
wget --no-check-certificate https://mirrors.ustc.edu.cn/proxmox/debian/proxmox-release-bullseye.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg && \
RUN echo "deb http://mirrors.ustc.edu.cn/proxmox/debian/ bullseye pve-no-subscription" >>/etc/apt/sources.list &&
wget --no-check-certificate https://mirrors.ustc.edu.cn/proxmox/debian/proxmox-release-bullseye.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg &&
chmod +r /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg

#repacked proxmox-ve
RUN wget https://mirrors.ustc.edu.cn/proxmox/debian/dists/bullseye/pve-no-subscription/binary-amd64/proxmox-ve_7.2-1_all.deb && \
mkdir /tmp/pve && \
dpkg -X proxmox-ve_7.2-1_all.deb /tmp/pve/ && \
dpkg -e proxmox-ve_7.2-1_all.deb /tmp/pve/DEBIAN && \
sed -i "s/pve-kernel-helper,//g" /tmp/pve/DEBIAN/control && \
sed -i "s/pve-kernel-5.15,//g" /tmp/pve/DEBIAN/control && \
dpkg-deb -Zxz -b /tmp/pve/ /tmp/
RUN wget https://mirrors.ustc.edu.cn/proxmox/debian/dists/bullseye/pve-no-subscription/binary-amd64/proxmox-ve_7.2-1_all.deb &&
mkdir /tmp/pve &&
dpkg -X proxmox-ve_7.2-1_all.deb /tmp/pve/ &&
dpkg -e proxmox-ve_7.2-1_all.deb /tmp/pve/DEBIAN &&
sed -i "s/pve-kernel-helper,//g" /tmp/pve/DEBIAN/control &&
sed -i "s/pve-kernel-5.15,//g" /tmp/pve/DEBIAN/control &&
dpkg-deb -Zxz -b /tmp/pve/ /tmp/

#repacked pve-manager
RUN wget https://mirrors.ustc.edu.cn/proxmox/debian/dists/bullseye/pve-no-subscription/binary-amd64/pve-manager_7.2-7_amd64.deb && \
mkdir /tmp/pve-manager && \
dpkg -X pve-manager_7.2-7_amd64.deb /tmp/pve-manager/ && \
dpkg -e pve-manager_7.2-7_amd64.deb /tmp/pve-manager/DEBIAN && \
sed -i "s/ifupdown2 (>= 2.0.1-1+pve8) | ifenslave (>= 2.6),//g" /tmp/pve-manager/DEBIAN/control && \
dpkg-deb -Zxz -b /tmp/pve-manager/ /tmp
RUN wget https://mirrors.ustc.edu.cn/proxmox/debian/dists/bullseye/pve-no-subscription/binary-amd64/pve-manager_7.2-7_amd64.deb &&
mkdir /tmp/pve-manager &&
dpkg -X pve-manager_7.2-7_amd64.deb /tmp/pve-manager/ &&
dpkg -e pve-manager_7.2-7_amd64.deb /tmp/pve-manager/DEBIAN &&
sed -i "s/ifupdown2 (>= 2.0.1-1+pve8) | ifenslave (>= 2.6),//g" /tmp/pve-manager/DEBIAN/control &&
dpkg-deb -Zxz -b /tmp/pve-manager/ /tmp

#intall proxmox-ve without recommends. ifupdown2 will install failed but ok
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractiv apt-get -y --no-install-recommends install proxmox-ve || echo ok
RUN apt-get update &&
DEBIAN_FRONTEND=noninteractiv apt-get -y --no-install-recommends install proxmox-ve || echo ok

##install again
RUN dpkg -i /tmp/*.deb || echo ok

#set passwd for root
RUN echo "root:root"|chpasswd
RUN echo "root:root" | chpasswd

#clean
RUN rm -rf /var/lib/apt/lists/* /*.deb
RUN rm -rf /var/lib/apt/lists/* /*.deb

#use setup.sh to start proxmox service
STOPSIGNAL SIGINT
CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target"]
CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target"]
142 changes: 70 additions & 72 deletions dockerfiles/build.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
#!/bin/bash
# from
# from
# https://github.com/spiritLHLS/pve
# 2023.08.15


########## 预设部分输出和部分中间变量

cd /root >/dev/null 2>&1
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
_green() { echo -e "\033[32m\033[01m$@\033[0m"; }
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
reading(){ read -rp "$(_green "$1")" "$2"; }
reading() { read -rp "$(_green "$1")" "$2"; }
export DEBIAN_FRONTEND=noninteractive
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
if [[ -z "$utf8_locale" ]]; then
echo "No UTF-8 locale found"
echo "No UTF-8 locale found"
else
export LC_ALL="$utf8_locale"
export LANG="$utf8_locale"
export LANGUAGE="$utf8_locale"
echo "Locale set to $utf8_locale"
export LC_ALL="$utf8_locale"
export LANG="$utf8_locale"
export LANGUAGE="$utf8_locale"
echo "Locale set to $utf8_locale"
fi
temp_file_apt_fix="/tmp/apt_fix.txt"

########## 定义部分需要使用的函数

install_package() {
package_name=$1
if command -v $package_name > /dev/null 2>&1 ; then
if command -v $package_name >/dev/null 2>&1; then
_green "$package_name already installed"
_green "$package_name 已经安装"
else
Expand All @@ -37,10 +36,9 @@ install_package() {
apt_output=$(apt-get install -y $package_name --fix-missing 2>&1)
fi
if [ $? -ne 0 ]; then
if echo "$apt_output" | grep -qE 'DEBIAN_FRONTEND=dialog dpkg --configure grub-pc' &&
if echo "$apt_output" | grep -qE 'DEBIAN_FRONTEND=dialog dpkg --configure grub-pc' &&
echo "$apt_output" | grep -qE 'dpkg --configure -a' &&
echo "$apt_output" | grep -qE 'dpkg: error processing package grub-pc \(--configure\):'
then
echo "$apt_output" | grep -qE 'dpkg: error processing package grub-pc \(--configure\):'; then
# 手动选择
# DEBIAN_FRONTEND=dialog dpkg --configure grub-pc
# 设置debconf的选择
Expand All @@ -66,9 +64,9 @@ install_package() {
fi
}

check_haveged(){
check_haveged() {
_yellow "checking haveged"
if ! command -v haveged > /dev/null 2>&1; then
if ! command -v haveged >/dev/null 2>&1; then
apt-get install -o Dpkg::Options::="--force-confnew" -y haveged
fi
if which systemctl >/dev/null 2>&1; then
Expand All @@ -80,11 +78,11 @@ check_haveged(){
fi
}

check_time_zone(){
check_time_zone() {
_yellow "adjusting the time"
systemctl stop ntpd
service ntpd stop
if ! command -v chronyd > /dev/null 2>&1; then
if ! command -v chronyd >/dev/null 2>&1; then
apt-get install -o Dpkg::Options::="--force-confnew" -y chrony
fi
if which systemctl >/dev/null 2>&1; then
Expand All @@ -100,15 +98,15 @@ check_time_zone(){
}

check_cdn() {
local o_url=$1
for cdn_url in "${cdn_urls[@]}"; do
if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" > /dev/null 2>&1; then
export cdn_success_url="$cdn_url"
return
fi
sleep 0.5
done
export cdn_success_url=""
local o_url=$1
for cdn_url in "${cdn_urls[@]}"; do
if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" >/dev/null 2>&1; then
export cdn_success_url="$cdn_url"
return
fi
sleep 0.5
done
export cdn_success_url=""
}

check_cdn_file() {
Expand All @@ -126,23 +124,22 @@ is_private_ipv4() {
if [[ -z $ip_address ]]; then
return 0 # 输入为空
fi
IFS='.' read -r -a ip_parts <<< "$ip_address"
IFS='.' read -r -a ip_parts <<<"$ip_address"
# 检查IP地址是否符合内网IP地址的范围
# 去除 回环,REC 1918,多播 地址
if [[ ${ip_parts[0]} -eq 10 ]] ||
[[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] ||
[[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] ||
[[ ${ip_parts[0]} -eq 127 ]] ||
[[ ${ip_parts[0]} -eq 0 ]] ||
[[ ${ip_parts[0]} -ge 224 ]]
then
return 0 # 是内网IP地址
[[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] ||
[[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] ||
[[ ${ip_parts[0]} -eq 127 ]] ||
[[ ${ip_parts[0]} -eq 0 ]] ||
[[ ${ip_parts[0]} -ge 224 ]]; then
return 0 # 是内网IP地址
else
return 1 # 不是内网IP地址
return 1 # 不是内网IP地址
fi
}

check_ipv4(){
check_ipv4() {
IPV4=$(ip -4 addr show | grep global | awk '{print $2}' | cut -d '/' -f1 | head -n 1)
if is_private_ipv4 "$IPV4"; then # 由于是内网IPV4地址,需要通过API获取外网地址
IPV4=""
Expand All @@ -161,10 +158,11 @@ check_ipv4(){
}

statistics_of_run-times() {
COUNT=$(
curl -4 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FspiritLHLS%2Fpve&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1 ||
curl -6 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FspiritLHLS%2Fpve&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1) &&
TODAY=$(expr "$COUNT" : '.*\s\([0-9]\{1,\}\)\s/.*') && TOTAL=$(expr "$COUNT" : '.*/\s\([0-9]\{1,\}\)\s.*')
COUNT=$(
curl -4 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FspiritLHLS%2Fpve&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1 ||
curl -6 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FspiritLHLS%2Fpve&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1
) &&
TODAY=$(expr "$COUNT" : '.*\s\([0-9]\{1,\}\)\s/.*') && TOTAL=$(expr "$COUNT" : '.*/\s\([0-9]\{1,\}\)\s.*')
}

get_system_arch() {
Expand All @@ -174,53 +172,53 @@ get_system_arch() {
fi
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
case "${sysarch}" in
"i386" | "i686" | "x86_64")
system_arch="x86"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64")
system_arch="arch"
;;
*)
system_arch=""
;;
"i386" | "i686" | "x86_64")
system_arch="x86"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64")
system_arch="arch"
;;
*)
system_arch=""
;;
esac
}

check_china(){
check_china() {
_yellow "IP area being detected ......"
if [[ -z "${CN}" ]]; then
if [[ $(curl -m 6 -s https://ipapi.co/json | grep 'China') != "" ]]; then
_yellow "根据ipapi.co提供的信息,当前IP可能在中国"
read -e -r -p "是否选用中国镜像完成相关组件安装? ([y]/n) " input
case $input in
[yY][eE][sS] | [yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO] | [nN])
echo "不使用中国镜像"
;;
*)
echo "使用中国镜像"
CN=true
;;
[yY][eE][sS] | [yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO] | [nN])
echo "不使用中国镜像"
;;
*)
echo "使用中国镜像"
CN=true
;;
esac
else
if [[ $? -ne 0 ]]; then
if [[ $(curl -m 6 -s cip.cc) =~ "中国" ]]; then
_yellow "根据cip.cc提供的信息,当前IP可能在中国"
read -e -r -p "是否选用中国镜像完成相关组件安装? [Y/n] " input
case $input in
[yY][eE][sS] | [yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO] | [nN])
echo "不使用中国镜像"
;;
*)
echo "不使用中国镜像"
;;
[yY][eE][sS] | [yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO] | [nN])
echo "不使用中国镜像"
;;
*)
echo "不使用中国镜像"
;;
esac
fi
fi
Expand All @@ -240,11 +238,11 @@ install_package sudo
cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "https://cdn1.spiritlhl.net/" "https://ghproxy.com/" "https://cdn2.spiritlhl.net/")
check_cdn_file

if ! command -v docker > /dev/null 2>&1; then
if ! command -v docker >/dev/null 2>&1; then
_yellow "Installing docker"
curl -sSL https://get.docker.com/ | sh
fi
if ! command -v docker-compose > /dev/null 2>&1; then
if ! command -v docker-compose >/dev/null 2>&1; then
_yellow "Installing docker-compose"
curl -Lk "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Expand Down
6 changes: 3 additions & 3 deletions extra_scripts/check-dns.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# from
# from
# https://github.com/spiritLHLS/pve

DNS_SERVER="8.8.8.8"
Expand All @@ -13,8 +13,8 @@ if [ $? -eq 0 ]; then
else
echo "Adding DNS server ${DNS_SERVER} to ${RESOLV_CONF}..."
if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" >> ${RESOLV_CONF}
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" >>${RESOLV_CONF}
else
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 2606:4700:4700::1111\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >> ${RESOLV_CONF}
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 2606:4700:4700::1111\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >>${RESOLV_CONF}
fi
fi
Loading

0 comments on commit eea44a5

Please sign in to comment.