1 Star 0 Fork 2

微云服务/shell

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
debian.sh 5.94 KB
一键复制 编辑 原始数据 按行查看 历史
微云服务 提交于 2025-01-13 10:30 . update debian.sh.
#!/usr/bin/env bash
# Copyright (C) 2023 - 2030 Teddysun <vm@vmosc.com>
#按现有物理内存的1.5倍增加虚拟内存
function SetSwap(){
local swap=/home/swap
local MemTotal=$(awk '($1 == "MemTotal:"){print $2}' /proc/meminfo)
local MemSwap=$((MemTotal+MemTotal/2))
dd if=/dev/zero of=${swap} bs=1024 count=${MemSwap}
mkswap ${swap};swapon ${swap};chmod 600 ${swap}
echo "${swap} swap swap defaults 0 0" >> /etc/fstab
local SwpPiness=$(cat /proc/sys/vm/swappiness)
if [ "$SwpPiness" -lt "60" ];then
sysctl vm.swappiness=60
echo "vm.swappiness = 60" >> /etc/sysctl.conf
fi
}
#安装Docker
function InstDocker(){
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
}
#配置Docker加速
function ConfDocker(){
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://przs4wj2.mirror.aliyuncs.com",
"https://hub.daocloud.io",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
#sudo apt-get install docker-compose-plugin
}
#安装Caddy
function InstCaddy(){
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt install -y caddy
}
#Docker安装memos博客
function DockerMemos(){
mkdir -p /usr/docker/memos && cd /usr/docker/memos/
sudo tee /usr/docker/memos/compose.yml <<-'EOF'
services:
memos:
restart: unless-stopped
image: neosmemo/memos:stable
container_name: memos
user: root
ports:
- 2800:5230
volumes:
- .memos/:/var/opt/memos
EOF
docker compose up -d
}
#memos代理配置
function wwwCaddy(){
sudo tee /etc/caddy/Caddyfile <<-'EOF'
{
email wangtl2001@163.com
}
www.vmosc.com {
reverse_proxy :2800
}
EOF
sudo systemctl reload caddy
}
#Docker安装Gitea仓库
function DockerGitea(){
mkdir -p /usr/docker/gitea && cd /usr/docker/gitea/
mkdir -p /usr/docker/gitea/{data,config}
sudo tee /usr/docker/gitea/compose.yml <<-'EOF'
services:
server:
image: docker.io/gitea/gitea:1.22.6-rootless
restart: always
volumes:
- ./data:/var/lib/gitea
- ./config:/etc/gitea
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "2222:2222"
EOF
sudo chown 1000:1000 config/ data/
docker compose up -d
}
#Gitea代理配置
function GitCaddy(){
sudo tee /etc/caddy/Caddyfile <<-'EOF'
{
email wangtl2001@163.com
}
www.vmosc.com {
reverse_proxy :2800
}
git.vmosc.com {
reverse_proxy :3000
}
EOF
sudo systemctl reload caddy
}
#Docker安装drone-runner
function DockerDrone(){
#- 3200:443
#local DRONE_RPC_SECRET=$(openssl rand -hex 16)
#read -p "Gitea ID:" DRONE_GITEA_CLIENT_ID
#read -p "Gitea Secret:" DRONE_GITEA_CLIENT_SECRET
mkdir -p /usr/docker/drone && cd /usr/docker/drone/
sudo tee /usr/docker/drone/compose.yml <<-'EOF'
services:
drone:
restart: always
image: drone/drone:latest
container_name: drone
ports:
- 3200:80
volumes:
- ./data/drone:/var/lib/drone/
- ./data/data:/data/
environment:
- DRONE_SERVER_HOST=dr.vmosc.com
- DRONE_SERVER_PROTO=https
- DRONE_RPC_SECRET=a04cc51ed713173925f7efe48cac42c4
- DRONE_GITEA_CLIENT_ID=5deff0f7-322e-40a1-8a78-b3819f74ef3c
- DRONE_GITEA_CLIENT_SECRET=gto_r4i26daemq755mpxe37kssn5bqcab64w2pf7dyxccuhkq6qzymfq
- DRONE_GITEA_SERVER=https://git.vmosc.com
runner:
restart: always
image: drone/drone-runner-docker:latest
container_name: runner
ports:
- 3300:3000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RPC_PROTO=https
- DRONE_RPC_HOST=drone
- DRONE_RPC_SECRET=a04cc51ed713173925f7efe48cac42c4
depends_on:
- drone
EOF
docker compose up -d
}
#Drone代理配置
function DrCaddy(){
sudo tee /etc/caddy/Caddyfile <<-'EOF'
{
email wangtl2001@163.com
}
www.vmosc.com {
reverse_proxy :2800
}
git.vmosc.com {
reverse_proxy :3000
}
dr.vmosc.com {
reverse_proxy :3200
}
EOF
sudo systemctl reload caddy
}
#随机16位
function RandSll(){
DRONE_RPC_SECRET=$(openssl rand -hex 16)
echo $(DRONE_RPC_SECRET)
}
#Docker安装caddy
function DockerCaddy(){
mkdir -p /usr/compose/caddy && cd /usr/compose/caddy/
sudo tee /usr/compose/caddy/compose.yml <<-'EOF'
services:
caddy:
image: caddy:<version>
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./site:/srv
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
caddy_config:
EOF
sudo tee /usr/compose/caddy/Caddyfile <<-'EOF'
{
email wangtl2001@163.com
}
www.vmosc.com {
reverse_proxy :2800
}
git.vmosc.com {
reverse_proxy :3000
}
dr.vmosc.com {
reverse_proxy :3200
}
EOF
cd /usr/compose/caddy/
docker compose up -d
}
sudo apt update
if [ $(cat /proc/sys/vm/swappiness) -lt "60" ];then
SetSwap
fi
if ! [ -x "$(command -v docker)" ];then
until [ -x "$(command -v docker)" ]
do
InstDocker
done
ConfDocker
fi
if ! [ -x "$(command -v caddy)" ];then
InstCaddy
fi
if ! [ -n "$(docker ps -q -f "name=memos")" ]; then
DockerMemos
wwwCaddy
fi
if ! [ -n "$(docker ps -q -f "name=gitea")" ]; then
DockerGitea
GitCaddy
fi
if ! [ -n "$(docker ps -q -f "name=drone")" ]; then
DockerDrone
DrCaddy
fi
#if ! [ -n "$(docker ps -q -f "name=runner")" ]; then
#DockerRunner
#fi
#DockerCaddy
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/vmosc/shell.git
git@gitee.com:vmosc/shell.git
vmosc
shell
shell
master

搜索帮助