[*] 更新 init apt
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
				
			This commit is contained in:
		
							parent
							
								
									21945b816a
								
							
						
					
					
						commit
						6865d58e50
					
				
							
								
								
									
										54
									
								
								init-apt.sh
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								init-apt.sh
									
									
									
									
									
								
							| @ -1,51 +1,29 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" | APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" | ||||||
|  | lsb_dist=$(cat /etc/*release | grep ^ID= | cut -d= -f2) # ubuntu or debian? | ||||||
|  | release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) #  ubuntu(jammy oracular) debian(bookworm).... | ||||||
|  | components=$([ "${lsb_dist=}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${lsb_dist=}" = "ubuntu" ] && echo "main restricted universe multiverse")) | ||||||
| 
 | 
 | ||||||
| type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) | # 删除 DEB822 格式 | ||||||
| release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) | if [ -f /etc/apt/sources.list.d/${lsb_dist}.sources ]; then | ||||||
| components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse")) |   rm /etc/apt/sources.list.d/${lsb_dist}.sources | ||||||
| 
 |  | ||||||
| # DEB822 格式 |  | ||||||
| # docker.martin98.com/library/ubuntu:latest |  | ||||||
| # docker.martin98.com/library/debian:latest |  | ||||||
| if [ -f /etc/apt/sources.list.d/${type}.sources ]; then |  | ||||||
|     cat > /etc/apt/sources.list.d/${type}.sources <<EOF |  | ||||||
| $(for suite in ${release} ${release}-updates ${release}-backports; do |  | ||||||
|   echo "Types: deb" |  | ||||||
|   echo "URIs: https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/" |  | ||||||
|   echo "Suites: $suite" |  | ||||||
|   echo "Components: ${components}" |  | ||||||
|   echo "Signed-By: /usr/share/keyrings/${type}-archive-keyring.gpg" |  | ||||||
|   echo "" |  | ||||||
|   echo "Types: deb-src" |  | ||||||
|   echo "URIs: https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/" |  | ||||||
|   echo "Suites: $suite" |  | ||||||
|   echo "Components: ${components}" |  | ||||||
|   echo "Signed-By: /usr/share/keyrings/${type}-archive-keyring.gpg" |  | ||||||
|   echo "" |  | ||||||
| done) |  | ||||||
| EOF |  | ||||||
| # 传统格式 |  | ||||||
| # docker.martin98.com/library/ubuntu:22.04 |  | ||||||
| elif [ -f /etc/apt/sources.list ]; then |  | ||||||
|     cat > /etc/apt/sources.list <<EOF |  | ||||||
| $(for suite in ${release} ${release}-updates ${release}-backports; do |  | ||||||
|   echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/ ${suite} ${components}" |  | ||||||
|   echo "deb-src https://mirrors.martin98.com/repository/${type}-tsinghua-${suite}/ ${suite} ${components}" |  | ||||||
| done) |  | ||||||
| EOF |  | ||||||
| else |  | ||||||
|     echo "没有找到合适的源" |  | ||||||
|     exit 1 |  | ||||||
| fi | fi | ||||||
|  | # 配置镜像源 | ||||||
|  | echo "deb https://mirrors.martin98.com/repository/$lsb_dist $release $components" > /etc/apt/sources.list | ||||||
|  | # k8s | ||||||
|  | curl -fsSL https://mirrors.martin98.com/repository/kubernetes/core/stable/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg | ||||||
|  | echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://mirrors.martin98.com/repository/kubernetes/core/stable/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list | ||||||
|  | # docker | ||||||
|  | curl -fsSL https://mirrors.martin98.com/repository/docker-ce/linux/$lsb_dist/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||||||
|  | echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.martin98.com/repository/docker-ce/linux/$lsb_dist $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||||||
| 
 | 
 | ||||||
|  | # 关闭交互式弹窗 | ||||||
| echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | ||||||
| # 更新证书 | 
 | ||||||
| apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates | apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates | ||||||
| apt update && apt upgrade -y | apt update && apt upgrade -y | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| # NTP | # NTP | ||||||
| # 启用阿里云 ntp | # 启用阿里云 ntp | ||||||
| if pidof systemd >/dev/null 2>&1; then | if pidof systemd >/dev/null 2>&1; then | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user