一.编写install.sh
#!/bin/bash
# 变量
# 8082端口映射
port_8082=8082
# 服务名称
services_name="dst_server"
# 容器名称
container_name="dst_server"
# 存档目录
dir_rchive="$(pwd)/rchive"
# 备份目录
dir_backup="$(pwd)/backup"
# 模组目录
dir_mod="$(pwd)/mod"
# 服务目录
dir_server="$(pwd)/server"
# SteamCMD 目录
dir_steamcmd="$(pwd)/steamcmd"
# 容器内存档目录
dir_rchive_container="/root/.klei/DoNotStarveTogether"
# 容器内备份目录
dir_backup_container="/app/backup"
# 容器内模组目录
dir_mod_container="/app/mod"
# 容器内服务目录
dir_server_container="/app/dst-dedicated-server"
# 容器内SteamCMD 目录
dir_steamcmd_container="/app/steamcmd"
# 当前用户UID
uid=$(id -u)
# 当前用户组ID
gid=$(id -g)
# 运行容器的身份
es_user="${uid}:${gid}"
# 镜像名称
image_name="hujinbo23/dst-admin-go"
# 镜像标签
image_tag=1.2.8
# 创建目录
mkdir $dir_rchive
mkdir $dir_backup
mkdir $dir_mod
mkdir $dir_server
mkdir $dir_steamcmd
# 生成docker-compose.yml文件
cat <<EOF > docker-compose.yml
version: '3'
services:
$services_name:
container_name: $container_name
image: $image_name:$image_tag
ports:
- "$port_8082:8082"
volumes:
- $dir_rchive:$dir_rchive_container
- $dir_backup:$dir_backup_container
- $dir_mod:$dir_mod_container
- $dir_server:$dir_server_container
- $dir_steamcmd:$dir_steamcmd_container
#user: 1005:1005
EOF
评论已关闭