Add TES3MP server

This commit is contained in:
Salt 2020-08-23 23:12:39 -05:00
parent dccb7419ac
commit 85ecd8fa68
9 changed files with 201 additions and 0 deletions

View File

@ -187,3 +187,12 @@ snmp:
36666136663930663463373731663534316232643637623732346331383737643233626235613439
3733366462613133620a386336303434303130313636356339633939623638366236346234376566
65386530663137393830636134653632623366333837616364396161666464613166
## VIDYA
# tes3mp
tes3mp:
name: "main"
server:
maxplayers: 8
name: "9iron TES3MP"
password: "dicks"

View File

@ -61,3 +61,4 @@ all:
38313431663734343931333462316633643935353038313934663466303834636533616165353961
6438356265656532396363323532616437353831613261323037
hosts:
tes3mp1.9iron.club

View File

@ -5,6 +5,22 @@
roles:
- role: base-backups
tags: [ backups ]
- hosts: tes3mp1.9iron.club
roles:
- role: tes3mp
tags: [ tes3mp ]
tasks:
- name: Assure CNAME record
route53:
state: present
overwrite: yes
zone: 9iron.club
type: CNAME
record: tes3mp.9iron.club
ttl: 300
value: [ "{{ inventory_hostname }}." ]
become: yes
tags: [ dns ]
#- hosts: game1.9iron.club
# roles:
# - role: base-backups

View File

@ -0,0 +1,14 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
tes3mp:
archive: "https://github.com/TES3MP/openmw-tes3mp/releases/download/0.7.0-alpha/tes3mp-server-GNU+Linux-x86_64-release-0.7.0-alpha-abc4090a0f-01d297f5c6.tar.gz"
dest: /opt/tes3mp
server:
name: My TES3MP server
maxplayers: 64
password: dicks
port: 25565
master:
enabled: "true"
host: master.tes3mp.com
port: 25561

View File

@ -0,0 +1,8 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: "restart tes3mp {{ tes3mp.name }}"
systemd:
name: "tes3mp@{{ tes3mp.name }}"
state: restarted
become: yes

View File

@ -0,0 +1,67 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up TES3MP
block:
- name: Set up system
block:
- name: Create user
user:
name: tes3mp
password: "!"
system: yes
home: "{{ tes3mp.dest }}"
- name: Template out service
template:
src: "tes3mp@.service"
dest: "/etc/systemd/system/tes3mp@.service"
register: t_service
- name: Reload daemons
systemd:
daemon_reload: yes
when: t_service is changed
- name: Set up TES3MP
block:
- name: Create server directory
file:
path: "{{ tes3mp.dest }}/{{ tes3mp.name }}"
state: directory
owner: tes3mp
group: tes3mp
- name: Download archive
get_url:
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}-archive.tar.gz"
url: "{{ tes3mp.archive }}"
register: get_archive
- name: Install server
block:
- name: Stop service
systemd:
name: "tes3mp@{{ tes3mp.name }}"
state: stopped
- name: Unpack zip
unarchive:
src: "{{ tes3mp.dest }}/{{ tes3mp.name }}-archive.tar.gz"
remote_src: yes
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}"
when: get_archive is changed
- name: Configure server
template:
src: "{{ item.src }}"
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}/{{ item.dest }}"
loop:
- { src: "tes3mp-server-default.cfg", dest: "tes3mp-server-default.cfg" }
notify: "restart tes3mp {{ tes3mp.name }}"
- name: Set up system
block:
- name: Start and enable service
systemd:
name: "tes3mp@{{ tes3mp.name }}"
enabled: yes
state: started
- name: Template out backup module
template:
src: "backup.sh"
dest: "/opt/backups/modules/tes3mp-{{ tes3mp.name }}.sh"
mode: "0600"
become: yes

View File

@ -0,0 +1,38 @@
#! /bin/bash
#
# tes3mp.sh
# Backup script for Minecraft. Meant to be sourced by our main backup script
# Copyright (C) 2020 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
#
set -e
export OUTDIR="$BACKUPSDIR/{{ tes3mp.name }}"
retention=7 # 7-day retention period
# Sanity checks
if [ -z "$BACKUPSDIR" ]; then
log "BACKUPSDIR was undefined. Run the main backup script instead of this one."
return 1
fi
if ! [ -d "$OUTDIR" ]; then
if ! mkdir "$OUTDIR"; then
log "Unable to find or create output directory: $OUTDIR"
return 2
fi
fi
# Purge oldest backup if we need to
currentbackupcount="$(ls -1 "$OUTDIR" | wc -l)"
if (( currentbackupcount >= retention )); then
lastbackup="$(find "$OUTDIR" -name \*.tar.gz 2>/dev/null | sort | head -n 1)"
if [ -f "$lastbackup" ]; then
log "Removing old backup: $lastbackup"
rm "$lastbackup"
fi
fi
# WE MAKE BACKUP NOW SERGEI
tar czf "$OUTDIR/{{ tes3mp.name }}-$(date -Iseconds)-tes3mp.tar.gz" "{{ tes3mp.dest }}/{{ tes3mp.name }}/"

View File

@ -0,0 +1,19 @@
[General]
# The default localAddress of 0.0.0.0 makes the server reachable at all of its local addresses
localAddress = 0.0.0.0
port = {{ tes3mp.server.port }}
maximumPlayers = {{ tes3mp.server.maxplayers }}
hostname = {{ tes3mp.server.name }}
# 0 - Verbose (spam), 1 - Info, 2 - Warnings, 3 - Errors, 4 - Only fatal errors
logLevel = 1
password = {{ tes3mp.server.password }}
[Plugins]
home = ./CoreScripts
plugins = serverCore.lua
[MasterServer]
enabled = {{ tes3mp.master.enabled }}
address = {{ tes3mp.master.host }}
port = {{ tes3mp.master.port }}
rate = 10000

View File

@ -0,0 +1,29 @@
#
# Licensed under the terms of the MIT license
# vim:ft=dosini:
#
[Unit]
Description=TES3MP Server %i
After=network.target
[Service]
User=tes3mp
Group=tes3mp
WorkingDirectory={{ tes3mp.dest }}/%i
PrivateUsers=true
ProtectSystem=full
ProtectHome=true
# Implies MountFlags=slave
ProtectKernelTunables=true
# Implies NoNewPrivileges=yes
ProtectKernelModules=true
# Implies MountAPIVFS=yes
ProtectControlGroups=true
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i {{ tes3mp.dest }}/{{ tes3mp.name }}/tes3mp-server'
Restart=on-failure
[Install]
WantedBy=multi-user.target