[+] 历史版本兼容
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 22m24s

This commit is contained in:
Martin 2025-01-13 21:12:49 +08:00
parent b1688d45a8
commit 9eda3ac981
8 changed files with 58 additions and 17 deletions

View File

@ -63,8 +63,11 @@ docker compose run ubuntu bash
#### APT 镜像源配置测试 #### APT 镜像源配置测试
```bash ```bash
docker compose run debian ./init-apt.sh docker compose run debian ./init-all.sh
``` ```
```bash ```bash
docker compose run ubuntu ./init-apt.sh docker compose run ubuntu ./init-all.sh
```
```bash
docker compose run ubuntu-2204 ./init-all.sh
``` ```

View File

@ -14,3 +14,7 @@ services:
ubuntu: ubuntu:
<<: *app-config <<: *app-config
image: docker.martin98.com/library/ubuntu:latest image: docker.martin98.com/library/ubuntu:latest
ubuntu-2204:
<<: *app-config
image: docker.martin98.com/library/ubuntu:22.04

View File

@ -1,12 +1,28 @@
#!/bin/bash #!/bin/bash
download_and_run() {
local filename="$1"
local url="https://git.martin98.com/MartinFarm/init/raw/branch/main/$1"
if [ ! -f "$filename" ]; then
echo "文件 $filename 不存在,正在下载..."
curl -sSL "$url" -o "$filename"
if [ $? -ne 0 ]; then
echo "下载失败请检查网络连接或URL是否正确。"
exit 1
fi
fi
bash "$filename"
}
# apt + ntp # apt + ntp
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash download_and_run "init-apt.sh"
# docker-ce # docker-ce
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash download_and_run "init-docker.sh"
# npm # npm
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-npm.sh | bash download_and_run "init-npm.sh"
# pip # pip
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-pip.sh | bash download_and_run "init-pip.sh"
# git # git
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-git.sh | bash download_and_run "init-git.sh"

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false"
type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) type=$(cat /etc/*release | grep ^ID= | cut -d= -f2)
release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2)
components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse")) components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse"))
@ -31,9 +33,9 @@ else
exit 1 exit 1
fi fi
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# 更新证书 # 更新证书
APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" 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 && update-ca-certificates
apt update && apt upgrade -y apt update && apt upgrade -y

View File

@ -3,10 +3,19 @@
command_exists() { command_exists() {
command -v "$@" > /dev/null 2>&1 command -v "$@" > /dev/null 2>&1
} }
is_wsl() {
case "$(uname -r)" in
*microsoft* ) true ;; # WSL 2
*Microsoft* ) true ;; # WSL 1
* ) false;;
esac
}
if command_exists docker; then if is_wsl; then
echo "docker 已安装.... 跳过" echo "检测到 WSL 环境,建议使用 Docker Desktop."
( set -x; sleep 5 ) exit 0
elif command_exists docker; then
echo "Docker 已安装.... 跳过安装"
else else
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh
fi fi

View File

@ -1,8 +1,10 @@
#!/bin/bash #!/bin/bash
# 检查 git 是否安装 # 检查 git 是否安装
if command -v pip &> /dev/null; then if command -v git > /dev/null 2>&1; then
echo "git 已安装,正在配置镜像源..." echo "git 已安装,正在配置镜像源..."
git config --global url."https://git-proxy.hk.martin98.com/".insteadOf "https://" git config --global url."https://git-proxy.hk.martin98.com/".insteadOf "https://"
echo "镜像源配置完成。" echo "镜像源配置完成。"
else
echo "git 不存在,跳过..."
fi fi

View File

@ -1,8 +1,11 @@
#!/bin/bash #!/bin/bash
# 检查 npm 是否安装 # 检查 npm 是否安装
if command -v npm &> /dev/null; then
if command -v npm > /dev/null 2>&1; then
echo "npm 已安装,正在配置镜像源..." echo "npm 已安装,正在配置镜像源..."
npm config set registry https://mirrors.martin98.com/repository/npm-group/ npm config set registry https://mirrors.martin98.com/repository/npm-group/
echo "镜像源配置完成。" echo "镜像源配置完成。"
else
echo "npm 不存在,跳过..."
fi fi

View File

@ -1,8 +1,10 @@
#!/bin/bash #!/bin/bash
# 检查 pip 是否安装 # 检查 pip 是否安装
if command -v pip &> /dev/null; then if command -v pip > /dev/null 2>&1; then
echo "pip 已安装,正在配置镜像源..." echo "pip 已安装,正在配置镜像源..."
pip config set global.index-url https://mirrors.martin98.com/repository/pypi-group/simple pip config set global.index-url https://mirrors.martin98.com/repository/pypi-group/simple
echo "镜像源配置完成。" echo "镜像源配置完成。"
else
echo "pip 不存在,跳过..."
fi fi