Skip to content

Commit

Permalink
start minecraft off in the right directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronak Rahman committed Oct 26, 2021
1 parent 28c02bc commit 6dab5de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions applications/mcserver/mcadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def stopMCworld():
#Connect to screen session using subprocess
# https://unix.stackexchange.com/questions/541254/python-open-screen-and-execute-inside-screen
#Running commands in screen: https://serverfault.com/questions/104668/create-screen-and-run-command-without-attaching
subprocess.run('screen -dmS myserver "/stop"', shell=True)
subprocess.run('screen -S myserver -p 0 -X quit', shell=True)
return 'Minecraft server has been stopped'

@app.route('/form')
Expand All @@ -54,7 +54,7 @@ def restoreMCworld():
if os.path.exists(filePath):
stopMCworld()
subprocess.run('unzip -o /tmp/minecraft_save.zip -d /', shell=True)
subprocess.run('screen -dmS myserver /usr/bin/java -jar /opt/minecraft/server.jar --nogui', shell=True)
subprocess.run('screen -dmS myserver /usr/bin/java -jar /opt/minecraft/server.jar --nogui', shell=True, cwd='/opt/minecraft')
return 'MC Server restored!'
else:
return 'Save file does not exist in /tmp, have you uploaded it?'
Expand Down

0 comments on commit 6dab5de

Please sign in to comment.