Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
62fd0f9
Update Dockerfile
jkljkl1197 Dec 13, 2017
9cd7bd4
Update Dockerfile
jkljkl1197 Dec 13, 2017
e81e015
changement mineur
jkljkl1197 Dec 13, 2017
decec42
this commit add two script
jkljkl1197 Dec 14, 2017
c24dac5
Update entrypoint.sh
jkljkl1197 Dec 14, 2017
c880fff
Update Dockerfile
jkljkl1197 Dec 14, 2017
bf5a560
Update Dockerfile
jkljkl1197 Dec 14, 2017
dc32809
Update lgsm-build.sh
jkljkl1197 Dec 14, 2017
693d9da
ReadMe
jkljkl1197 Dec 14, 2017
241cddb
Update README.md
jkljkl1197 Dec 14, 2017
fa25c3b
big edit to get work well lgsm.sh, delete useless repetition add some
jkljkl1197 Dec 14, 2017
cc6675e
README update
jkljkl1197 Dec 15, 2017
2f5e52e
Update README.md
jkljkl1197 Dec 15, 2017
92f26f5
Update README.md
jkljkl1197 Dec 15, 2017
a111406
Update README.md
jkljkl1197 Dec 15, 2017
a23e771
Update README.md
jkljkl1197 Dec 15, 2017
c806951
Update README.md
jkljkl1197 Dec 15, 2017
d3604fc
tiny error on line 15 forget ""
jkljkl1197 Dec 15, 2017
aa106dc
change maintainer
jkljkl1197 Dec 15, 2017
e060a4e
remove a invalide package and add apt-utils
jkljkl1197 Dec 15, 2017
9d8c298
change position of apt-utils because can get use by other package for
jkljkl1197 Dec 15, 2017
e8d497f
error with comments in run section???#
jkljkl1197 Dec 15, 2017
9142cf4
repair some udp ports probleme and some other stuff
jkljkl1197 Dec 15, 2017
e762aaf
some edit
jkljkl1197 Dec 15, 2017
83a27f5
add a discord alerts sender shell and do some edit about it in lgsm.sh
jkljkl1197 Dec 16, 2017
01fb53a
Update alert_discord-base.sh
jkljkl1197 Dec 16, 2017
d8da63e
some edit
jkljkl1197 Dec 16, 2017
43ec5d2
all work now contact from external network ...
jkljkl1197 Dec 17, 2017
5c68182
some little edit
Jan 17, 2018
0e8ad76
rename linuxgsm-build.sh to linuxgsm-docker-build.sh
jkljkl1197 Jan 17, 2018
687abbf
rename lgsm.sh to linuxgsm-docker.sh
jkljkl1197 Jan 17, 2018
d572538
Update README.md
jkljkl1197 Jan 17, 2018
34e4b00
Delete alert_discord-base.sh
jkljkl1197 Jan 17, 2018
4cc00c5
Update linuxgsm-docker.sh
jkljkl1197 Jan 17, 2018
88c797b
Update README.md
jkljkl1197 Jan 17, 2018
c5e4395
Update Dockerfile
jkljkl1197 Jan 17, 2018
07fcfa6
add command install
jkljkl1197 Jan 18, 2018
ca49dff
better command option
jkljkl1197 Jan 18, 2018
422c6b2
add the case to a function; need to be test
jkljkl1197 Jan 18, 2018
a62c940
Update linuxgsm-docker.sh
jkljkl1197 Jan 18, 2018
e1460b7
change a condition to something better
jkljkl1197 Jan 18, 2018
47a764f
Update linuxgsm-docker.sh
jkljkl1197 Jan 18, 2018
7724626
add command validate
jkljkl1197 Jan 18, 2018
45f6e2d
remove forget duplication my bad
jkljkl1197 Jan 18, 2018
6685f93
Update linuxgsm-docker.sh
jkljkl1197 Jan 18, 2018
c9f8002
better Shell setup ... cleaning
jkljkl1197 Jan 18, 2018
a6220c7
Update README.md
jkljkl1197 Jan 18, 2018
d83da2a
Update linuxgsm-docker.sh
jkljkl1197 Jan 18, 2018
3901f80
use a new function to stop duplication
jkljkl1197 Jan 19, 2018
185c5e4
Update linuxgsm-docker.sh
jkljkl1197 Jan 19, 2018
f1caa95
Update linuxgsm-docker.sh
jkljkl1197 Jan 19, 2018
a2e21bf
update function for more parameters
jkljkl1197 Jan 19, 2018
1a77a28
Update linuxgsm-docker.sh
jkljkl1197 Jan 22, 2018
fb15252
Update README.md
jkljkl1197 Jan 22, 2018
346b7d9
Update linuxgsm-docker.sh
jkljkl1197 Jan 22, 2018
c641d6a
Update README.md
jkljkl1197 Jan 22, 2018
97f1f4b
Update Dockerfile
jkljkl1197 Jan 22, 2018
b4c03d2
Update README.md
jkljkl1197 Jan 22, 2018
caeda77
Update linuxgsm-docker.sh
jkljkl1197 Jan 22, 2018
ab48ecf
Update README.md
jkljkl1197 Jan 22, 2018
7396e7f
Update Dockerfile
jkljkl1197 Jan 22, 2018
1422726
Update linuxgsm-docker.sh
jkljkl1197 Jan 22, 2018
4da02b7
repair some stuff
jkljkl1197 Jan 22, 2018
a511321
Update linuxgsm-docker.sh
jkljkl1197 Jan 22, 2018
0854613
Update Dockerfile
jkljkl1197 Jan 23, 2018
a61b6d2
Update linuxgsm-docker.sh
jkljkl1197 Jan 23, 2018
8b95649
Update Dockerfile
jkljkl1197 Jan 23, 2018
c5a343b
Update linuxgsm-docker.sh
jkljkl1197 Jan 23, 2018
120fa5a
remove duplication
jkljkl1197 Jan 25, 2018
338445a
Change a remark
jkljkl1197 Feb 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 89 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,107 @@
FROM ubuntu:16.04
FROM debian:stable

LABEL maintainer="[email protected]"
ENV LGSM_DOCKER_IMAGE LinuxGameServerManager
LABEL maintainer="jkljkl1197 on github"

ENV DEBIAN_FRONTEND noninteractive
ARG DEBIAN_FRONTEND="noninteractive"

## Base System
## Ports Use can use -p port:port also
#I open bolth tcp and udp but udp in not all time necessary.
#Line 1 commun ports steam tcp
#Line 2 commun ports steam udp
#Line 3 Rcon and Web port for some server update agent tcp
#Line 4 Rcon and Web port for some server update agent udp
EXPOSE 27015:27015 7777:7777 7778:7778 \
27015:27015/udp 7777:7777/udp 7778:7778/udp \
27020:27020 443:443 80:80 \
27020:27020/udp 443:443/udp 80:80/udp

## Base System package
# install apt-utils before because some installer deb script need it
RUN dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y \
binutils \
mailutils \
postfix \
curl \
wget \
file \
bzip2 \
gzip \
unzip \
bsdmainutils \
python \
util-linux \
ca-certificates \
tmux \
lib32gcc1 \
libstdc++6 \
libstdc++6:i386

ENV LGSM_DOCKER_VERSION 17.07.27

## lgsm.sh
RUN wget -N --no-check-certificate https://gameservermanagers.com/dl/linuxgsm.sh
apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends apt-utils
## Tools (Optional)
#add packet you want to add here.
RUN apt-get install -y \
nano \
net-tools
## Dependency
RUN apt-get install -y \
binutils \
mailutils \
postfix \
bc \
curl \
wget \
file \
bzip2 \
gzip \
unzip \
xz-utils \
libmariadb2 \
bsdmainutils \
python \
util-linux \
ca-certificates \
tmux \
lib32gcc1 \
libstdc++6 \
libstdc++6:i386 \
libstdc++5:i386 \
libsdl1.2debian \
default-jdk \
lib32tinfo5 \
speex:i386 \
libtbb2 \
libcurl4-gnutls-dev:i386 \
libtcmalloc-minimal4:i386 \
libncurses5:i386 \
zlib1g:i386 \
libldap-2.4-2:i386 \
libxrandr2:i386 \
libglu1-mesa:i386 \
libxtst6:i386 \
libusb-1.0-0-dev:i386 \
libxxf86vm1:i386 \
libopenal1:i386 \
libgtk2.0-0:i386 \
libdbus-glib-1-2:i386 \
libnm-glib-dev:i386 \
apt-transport-https \
procps \
locales \
cron

ENV LGSM_DOCKER_VERSION 17.11.0

## UTF-8 Probleme tmux...
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

## linuxgsm.sh
RUN wget -N --no-check-certificate https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/linuxgsm.sh

## if you have a permission probleme, check uid gid with the command id of the main linux user lgsm
## you need to have the same guid and uid as your real machine storage/data folder
## for me, my real user uid is 1001 so i need to create a user for the virtual docker image with the same uid
## user config
RUN adduser --disabled-password --gecos "" lgsm && \
RUN adduser --disabled-password --gecos "" --uid 1001 lgsm && \
chown lgsm:lgsm /linuxgsm.sh && \
chmod +x /linuxgsm.sh && \
cp /linuxgsm.sh /home/lgsm/linuxgsm

cp /linuxgsm.sh /home/lgsm/linuxgsm.sh && \
usermod -G tty lgsm #solve tmux script error

USER lgsm
WORKDIR /home/lgsm

#need to fake it linuxgsm
ENV TERM=xterm

## Docker Details

ENV PATH=$PATH:/home/lgsm

COPY entrypoint.sh /entrypoint.sh
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ Dockerhub https://hub.docker.com/r/akshmakov/linuxgsm/

Run Game Servers in Docker, multiplex multiple LinuxGSM deployments easily by taking advantage of Dockers port mapping.

## Easy step

The script create a user name lgsm with a home directory path /home/lgsm/

Use root user of the main linux system to build and use the script

- Download the git repo git clone ...
- Change permission to executable : chmod +x linuxgsm-docker-build.sh && chmod +x linuxgsm-docker.sh
- Edit DockerFile and open the proper Ports for the server type you want to install(default steam base 777[7-8], 2015...)
- Execute linuxgsm-docker-build.sh
- Edit some variable at the top of the linuxgsm-docker.sh script
- Execute linuxgsm-docker.sh all you need is in this script

if you want to edit server config from main linux system you need to have lgsm user as the same uid than in docker for the user or the owner ship going to be diffrent in container and the main linux system get permission issue or need to chown it but you can't do that from the main linux system because the user for the chown is on a other os...


### After this line the documentation is out updated but most of it is usefull

## Image Tags

- `latest` `base` - base image with linuxgsm.sh script and user setup
Expand Down Expand Up @@ -96,7 +114,7 @@ then any extended image may be run as such
```
# build the custom image
$ docker build -tag local/linuxgsm:$SERVERNAME .
# start the server
sudo docker run --name arkserver --rm -it -d -v "/home/lgsm/:/home/lgsm" lgsm-docker bash# start the server
$ docker run -d --name my-custom-server local/linuxgsm:$SERVERNAME
```

Expand Down Expand Up @@ -164,7 +182,7 @@ $ docker-compose stop q2server

## Container Overview

`linuxgsm.sh` script is particularly picky about paths and does things a little different from a typical daemon.
`linuxgsm-docker.sh` script is particularly picky about paths and does things a little different from a typical daemon.

In particular this docker images seeks to encapsulate LinuxGSM exactly as it is, to allow for easy transition from non-docker based deployments

Expand All @@ -176,7 +194,4 @@ These quirks are
- Script runs server in a tmux session (Difficult to attach to output)


This Container runs `linuxgsm.sh` under a generic user `lgsm` and script and server data installed under the home directory `/home/lgsm`



This Container runs `linuxgsm-docker.sh` under a generic user `lgsm` and script and server data installed under the home directory `/home/lgsm`
2 changes: 0 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ else
tmux set -g status off && tmux attach 2> /dev/null
fi



exit 0
4 changes: 4 additions & 0 deletions linuxgsm-docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

## simple building script to create the image/container
sudo docker build -t lgsm-docker .
160 changes: 160 additions & 0 deletions linuxgsm-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/bin/bash

## can be simplified.

## name of the docker container
InstanceName='arkserver'
## arkserver for me (it's the script name in the serveur directory)
# for you need to be the server type name of the lgsm script
ServerType='arkserver'
## Image name to run (i have build with the lgsm-build.sh)
Img='lgsm-docker'
## current path; plz execute this script from it's folder
Path=$(pwd)
## Set the Network Used by docker
Network='host'
## Set the hostname for the docker container
Hostname='LGSM'
## Set it to False if you don't have a discord custom script like me
DiscordNotifier="false"

## check if the container already running; return (true or '')
status=$(sudo docker inspect --format="{{.State.Running}}" $InstanceName 2> /dev/null)

fn_discord_custom_sender(){
if [ "${DiscordNotifier}" == "true" ]
then
sleep 2
sudo docker exec ${InstanceName} alert_discord.sh "${cmd}"
fi
}

## need to be test
fn_exec_cmd_sender(){
if [ "${1}" == "exec" ]
then
if [ "${2}" == "install" ]
then
sudo docker "${1}" ${InstanceName} bash /home/lgsm/linuxgsm.sh "${3}"
else
sudo docker "${1}" ${InstanceName} ${ServerType} "${2}" "${3}"
fi
else
sudo docker "${1}" ${InstanceName}
fi
}

fn_command_support(){

case ${cmd} in
"install")
if [ "${3}" != "" ]
then
fn_exec_cmd_sender exec install "${3}"
else
# Get List of game server name for install
sudo docker exec ${InstanceName} bash /home/lgsm/linuxgsm.sh install
echo "enter the server name; ctrl+c to cancel"
read -a type
fn_exec_cmd_sender exec install "${type}"
fi
;;

"start")
fn_exec_cmd_sender exec start
fn_discord_custom_sender "${cmd}"
;;

"stop")
if [ "$status" == "true" ]
then
fn_exec_cmd_sender exec stop
fn_discord_custom_sender "${cmd}"
sudo docker kill ${InstanceName}
fi
;;

"restart")
fn_exec_cmd_sender exec restart
fn_discord_custom_sender "${cmd}"
;;

"update") ## update stop the server if is already running(lgsm script).
fn_exec_cmd_sender exec update
fn_discord_custom_sender "${cmd}"
;;

"console")
fn_exec_cmd_sender exec console
;;

"monitor")
fn_exec_cmd_sender exec monitor
;;

"validate")
fn_exec_cmd_sender exec validate
;;

"backup")
fn_exec_cmd_sender exec backup
;;

"details")
fn_exec_cmd_sender exec details
;;

"alerts")
fn_exec_cmd_sender exec alerts
;;

"conjob")
crontab -l > CronTemp
echo "* */3 * * * bash ${Path}/linuxgsm-docker.sh command bash check_version.sh >/dev/null 2>&1" >> CronTemp
crontab CronTemp
rm CronTemp
;;

"attach")
echo "dettach with ctrl+p & ctrl+q"
fn_exec_cmd_sender attach
;;

"command")
## Need to be test (take all parameter after the first one)
sudo docker exec -it ${InstanceName} "${@:2}"
;;

*)
echo "Parameter invalid, exit."
exit 1
esac

}


## check if the the container already running; if not start it if command is not Stop;
if [ "${status}" != "true" ] && [ "$1" != "stop" ]
then
echo "docker container was not running. start it for you."
sudo docker rm ${InstanceName} 2> /dev/null
sudo docker run --name ${InstanceName} --restart always --net=${Network} --hostname ${Hostname} -it -d -v "/home/lgsm/:/home/lgsm" ${Img} bash 2> /dev/null
elif [ "${status}" == "true" ]
then
echo "docker container already running, append command."
else
echo "docker container not running."
fi

## check if we have a parameter
if [ "${#}" -gt 0 ]
then
cmd=${1}
fn_command_support "${cmd}" "${2}"
else
echo $"Usage: $0 {start|stop|restart|console|monitor|update|backup|details|alerts|cronjob|attach|command|install}"
read -a cmd
fn_command_support "${cmd}" "${2}"
fi

#sudo docker run --name arkserver --rm -it -d -v "/home/lgsm/:/home/lgsm" lgsm-docker bash $@