Skip to content
Snippets Groups Projects
Commit 4043c0c1 authored by Ferenc Schulcz's avatar Ferenc Schulcz
Browse files

Handle Minecraft in docker

parent edea641c
Branches
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ import services ...@@ -3,6 +3,7 @@ import services
import db import db
import mysql.connector import mysql.connector
AUTHME_DB_HOST="172.16.25.101"
def register(add_endpoint, add_postable_endpoint, add_menu): def register(add_endpoint, add_postable_endpoint, add_menu):
add_endpoint('minecraft', minecraft) add_endpoint('minecraft', minecraft)
...@@ -46,7 +47,7 @@ def minecraft_username(**kwargs): ...@@ -46,7 +47,7 @@ def minecraft_username(**kwargs):
with Client('127.0.0.1', 25575, passwd='nagy0nmen0rc0n') as mcclient: with Client('127.0.0.1', 25575, passwd='nagy0nmen0rc0n') as mcclient:
response = mcclient.run('kick', x['mcuser']) response = mcclient.run('kick', x['mcuser'])
authmedb = mysql.connector.connect( authmedb = mysql.connector.connect(
host='localhost', user='authme', password='12345', database='authme') host=AUTHME_DB_HOST, user='authme', password='12345', database='authme', charset="utf8mb3")
authmecursor = authmedb.cursor() authmecursor = authmedb.cursor()
sql = "UPDATE authme SET realname=%s, username=%s where realname=%s" sql = "UPDATE authme SET realname=%s, username=%s where realname=%s"
val = (request.form['username'], val = (request.form['username'],
......
...@@ -124,7 +124,8 @@ def mcrestart(**kwargs): ...@@ -124,7 +124,8 @@ def mcrestart(**kwargs):
if not services.authorize_user(session['username'], 'mcadmin'): if not services.authorize_user(session['username'], 'mcadmin'):
return rqtools.get_403(None) return rqtools.get_403(None)
# this line needs the following in sudoers: `[user running this server] ALL=(root) NOPASSWD: /usr/bin/systemctl restart minecraft-spigotd.service` # this line needs the following in sudoers: `[user running this server] ALL=(root) NOPASSWD: /usr/bin/systemctl restart minecraft-spigotd.service`
os.system('sudo /usr/bin/systemctl restart minecraft-spigotd.service') #os.system('sudo /usr/bin/systemctl restart minecraft-spigotd.service')
os.system('/usr/bin/docker restart minecraft')
db.sendMessage(session['username'], 'Server is restarting.') db.sendMessage(session['username'], 'Server is restarting.')
return rqtools.redirect(rqtools.url_for('service', servicename='mcadmin')) return rqtools.redirect(rqtools.url_for('service', servicename='mcadmin'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment