]> us-delaporte.pagekite.me Git - dotfiles.git/commitdiff
WIP add serve command for Minecraft
authorEdward Delaporte <edward@delaporte.us>
Thu, 1 Jan 2026 21:55:06 +0000 (15:55 -0600)
committerEdward Delaporte <edward@delaporte.us>
Thu, 1 Jan 2026 21:55:06 +0000 (15:55 -0600)
invoke/minecraft-remote/tasks.py

index 6f3dbd17f8758bf083a99cc4a676b9649b8e5697..724b43be67f27cbabcfab1593ec6b37195dd5a7c 100644 (file)
@@ -21,11 +21,17 @@ LOCAL_BACKUPS=f'{LOCAL_HOME}/backup/minecraft'
 
 MINECRAFT=f'{HOME}/Minecraft'
 
-dims = ['world', 'world_nether', 'world_the_end']
+DIRS = ['world', 'world_nether', 'world_the_end', 'plugins']
+
+# TODO: Set these
+JAVA=f'{HOME}/java/jdk21/bin/java'
+JAVA_OPTS=f'--Xms3000 --Xmx6000'
+OPTIONS=f'--nogui'
+SERVE=f'screen -S Minecraft -d -m {JAVA} {JAVA_OPTS} {MINECRAFT}/server.jar {OPTIONS}'
 
 @task
 def compress_world(c):
-    for world in dims:
+    for world in DIRS:
         c.run(f'{SSH} -C tar cf /tmp/{world}.{DATE_TAR} --directory={MINECRAFT} {world}')
     c.run(f'{SSH} -C ls /tmp | grep .tar')
 
@@ -38,7 +44,7 @@ def backup(c):
         exit()
     c.run(f'mkdir -p {LOCAL_BACKUPS}')
 
-    for world in dims:
+    for world in DIRS:
         c.run(f'{SCP}:/tmp/{world}.{DATE_TAR} {LOCAL_BACKUPS}')
 
     c.run(f'ls -lh {LOCAL_BACKUPS} | grep .tar')
@@ -46,7 +52,7 @@ def backup(c):
 
 @task
 def verify_backup(c):
-    for world in dims:
+    for world in DIRS:
         c.run(f'tar tvf {LOCAL_BACKUPS}/{world}.{DATE_TAR} | tail')
         c.run(f'tar tvf {LOCAL_BACKUPS}/{world}.{DATE_TAR} | wc')
 
@@ -61,3 +67,11 @@ def serve(c):
     print(f'Server should now be running in a remote screen session.')
     print(result)
 
+
+@task
+def serve(c):
+    print(f"Attempting to connect to {IP}")
+    result = c.run(f'ssh {USER}@{IP} -C {SERVE}')
+    print(f'Server should now be running in a remote screen session.')
+    print(result)
+