#!/bin/bash

DNF_DATA=/data/dnf/wuhui70

mkdir -p ${DNF_DATA}

systemctl disable firewalld
systemctl stop firewalld

sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8000

mkswap /var/swap.1
swapon /var/swap.1

sed -i '$a /var/swap.1 swap swap default 0 0' /etc/fstab

docker run \
  -v ${DNF_DATA}/log:/home/neople/game/log \
  -v ${DNF_DATA}/mysql:/var/lib/mysql \
  -v ${DNF_DATA}/data:/data \
  --name=init-db-of-dof \
  1995chen/dnf:centos6-2.0.2 /bin/bash /home/template/init/init.sh

docker run -d \
  -e PUBLIC_IP=42.192.52.227 \
  -e DNF_DB_ROOT_PASSWORD=woshinidie.233 \
  -e GM_ACCOUNT=zeaslity \
  -e GM_PASSWORD=woshinidie.233 \
  -v ${DNF_DATA}/log:/home/neople/game/log \
  -v ${DNF_DATA}/mysql:/var/lib/mysql \
  -v ${DNF_DATA}/data:/data \
  -p 30000:3306/tcp \
  -p 7600:7600/tcp \
  -p 881:881/tcp \
  -p 20303:20303/tcp \
  -p 20303:20303/udp \
  -p 20403:20403/tcp \
  -p 20403:20403/udp \
  -p 40403:40403/tcp \
  -p 40403:40403/udp \
  -p 7000:7000/tcp \
  -p 7000:7000/udp \
  -p 7001:7001/tcp \
  -p 7001:7001/udp \
  -p 7200:7200/tcp \
  -p 7200:7200/udp \
  -p 10011:10011/tcp \
  -p 31100:31100/tcp \
  -p 30303:30303/tcp \
  -p 30303:30303/udp \
  -p 30403:30403/tcp \
  -p 30403:30403/udp \
  -p 10052:10052/tcp \
  -p 20011:20011/tcp \
  -p 20203:20203/tcp \
  -p 20203:20203/udp \
  -p 30703:30703/udp \
  -p 11011:11011/udp \
  -p 2311-2313:2311-2313/udp \
  -p 30503:30503/udp \
  -p 11052:11052/udp \
  --cpus=2 \
  --memory=4g \
  --memory-swap=-1 \
  --shm-size=8g \
  --name=dnf-server \
  1995chen/dnf:centos6-2.0.2

echo ""
echo "开始输出 服务器初始化日志！"
tail -f ${DNF_DATA}/log/siroco11/Log*.init