17 Commits
0.1.0 ... 0.1.2

Author SHA1 Message Date
3e913215f1 [*] 更新 git proxy
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
[-] 已安装docker的不执行重启
2025-01-15 15:51:28 +08:00
96141a2f97 [*] 修改 apt 脚本
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 1m6s
2025-01-15 15:25:43 +08:00
24179ff666 [+] 增加 src 源
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 12s
2025-01-14 16:08:18 +08:00
1158047f6f [*] 修复bash
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 12s
2025-01-13 21:24:02 +08:00
2a1bac7666 移除无用文件
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 11s
2025-01-13 21:13:31 +08:00
9eda3ac981 [+] 历史版本兼容
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 22m24s
2025-01-13 21:12:49 +08:00
b1688d45a8 [*] 修改为 group
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 9s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 18m11s
2025-01-13 20:08:43 +08:00
5c7ccf4f4f 修改 ubuntu debian 源 2025-01-13 20:07:25 +08:00
ed14758b6b 取消密钥
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 3m5s
2025-01-13 16:27:00 +08:00
e01366ede1 [*] 更新私有化actions
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 56s
2025-01-13 16:23:45 +08:00
1fe510105a [+] 测试 vars
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 2m14s
2025-01-13 16:07:39 +08:00
ede14fd99b [+] 增加自动化构建
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 1m12s
2025-01-13 15:51:37 +08:00
f4ec37b97c [+] 增加 git pip npm bash 2025-01-13 15:42:08 +08:00
b504790438 [+] fix 粘贴 2025-01-06 16:53:04 +08:00
28a83e30f5 [*] 修改判断条件
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 38s
2025-01-05 23:55:09 +08:00
1d36cdba41 [*] 兼容action测试
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 5m59s
2025-01-05 23:45:23 +08:00
33b6b3013a [+] 添加 action 测试
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2m31s
2025-01-05 23:35:53 +08:00
10 changed files with 185 additions and 51 deletions

View File

@@ -0,0 +1,29 @@
name: Build Docker Image
on:
push:
branches:
- main
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://git.martin98.com/actions/checkout.git@v4
- name: Log in to Docker Hub
uses: https://git.martin98.com/actions/login-action.git@v3
with:
registry: ${{ vars.DOCKER_HUB }}
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ vars.DOCKER_PASSWORD }}
- name: Build and push
uses: https://git.martin98.com/actions/build-push-action.git@v4
with:
context: .
platforms: linux/amd64
push: true
tags: |
docker.martin98.com/martin_farm/init:latest
docker.martin98.com/martin_farm/init:${{ github.sha }}

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM scratch
COPY *.sh /scripts/

View File

@@ -5,43 +5,47 @@
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
# docker-ce
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash
# npm
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-npm.sh | bash
# pip
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-pip.sh | bash
# git
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-git.sh | bash
# 初始化全部
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-all.sh | bash
```
#### Python 镜像源配置测试
```bash
pip config set global.index-url https://mirrors.martin98.com/repository/pypi-group/simple
```
#### NPM
```bash
npm config set registry https://mirrors.martin98.com/repository/npm-group/
```
##### docker 容器中
```bash
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
sed -i '6,$d' /etc/apt/sources.list.d/dhttps://mirrors.mebian.sources && \
sed -i 's|http://deb.debian.org/debian|artin98.com/repository/debian-tsinghua/|g' /etc/apt/sources.list.d/debian.sources && \
apt update && \
apt install -y --no-install-recommends \
gcc \
g++ \
python3-dev
```
#### dockerfile
#### 进入容器
```bash
docker compose run debian bash
```
```bash
docker compose run ubuntu bash
COPY --from=docker.martin98.com/martin_farm/init:latest /scripts /scripts
RUN /scripts/init-apt.sh
```
#### APT 镜像源配置测试
```bash
docker compose run debian ./init-apt.sh
docker compose run debian ./init-all.sh
```
```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

@@ -13,4 +13,8 @@ services:
ubuntu:
<<: *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,6 +1,28 @@
#!/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
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
download_and_run "init-apt.sh"
# docker-ce
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-docker.sh | bash
download_and_run "init-docker.sh"
# npm
download_and_run "init-npm.sh"
# pip
download_and_run "init-pip.sh"
# git
download_and_run "init-git.sh"

View File

@@ -1,41 +1,69 @@
#!/bin/bash
# 配置 ubuntu 源
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
cat > /etc/apt/sources.list.d/ubuntu.sources <<EOF
Types: deb
URIs: https://mirrors.martin98.com/repository/ubuntu-tsinghua/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
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)
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"))
# 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
# 配置 debian 源
elif [ -f /etc/apt/sources.list.d/debian.sources ]; then
cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: https://mirrors.martin98.com/repository/debian-tsinghua/
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
# 传统格式
# 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
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 && update-ca-certificates
apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates
apt update && apt upgrade -y
# NTP
# 启用阿里云 ntp
apt install chrony -y
cat > /etc/chrony.conf <<EOF
if pidof systemd >/dev/null 2>&1; then
apt install chrony -y
cat > /etc/chrony.conf <<EOF
server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp5.aliyun.com iburst
driftfile /var/lib/chrony/drift
allow 127.0.0.1
EOF
systemctl restart chrony && systemctl enable chrony
systemctl restart chrony && systemctl enable chrony
else
echo "systemctl 不存在,跳过 chrony 的重启"
fi
# fix vim 粘贴
if pidof vim >/dev/null 2>&1; then
if ! grep -q "set pastetoggle=" ~/.vimrc; then
echo "set pastetoggle=" >> ~/.vimrc
fi
fi

View File

@@ -3,15 +3,22 @@
command_exists() {
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
echo "docker 已安装.... 跳过"
( set -x; sleep 5 )
if is_wsl; then
echo "检测到 WSL 环境,建议使用 Docker Desktop."
exit 0
elif command_exists docker; then
echo "Docker 已安装.... 跳过安装"
else
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/docker-install.sh | sh
fi
cat > /etc/docker/daemon.json <<EOF
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.martin98.com",
@@ -20,5 +27,9 @@ cat > /etc/docker/daemon.json <<EOF
]
}
EOF
sudo systemctl restart docker
if pidof systemd >/dev/null 2>&1; then
systemctl restart docker
else
echo "systemctl 不存在,跳过 docker 重启。"
fi
fi

12
init-git.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# 检查 git 是否安装
if command -v git > /dev/null 2>&1; then
echo "git 已安装,正在配置镜像源..."
# 曾经设置过的强制取消
git config --global --unset url."https://git-proxy.hk.martin98.com/".insteadOf
git config --global url."https://git-proxy.hk.martin98.com/https://github.com/".insteadOf "https://github.com/"
echo "镜像源配置完成。"
else
echo "git 不存在,跳过..."
fi

11
init-npm.sh Normal file
View File

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

10
init-pip.sh Normal file
View File

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