From: Edward Delaporte Date: Thu, 25 Dec 2025 17:42:34 +0000 (-0600) Subject: Add invoke to upload a local mod to the Luanti server X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/commitdiff_plain/d3eaac1730b4c4dc05ec67360e78f6a7914a4229 Add invoke to upload a local mod to the Luanti server --- diff --git a/invoke/luanti-remote/tasks.py b/invoke/luanti-remote/tasks.py index 61dc1a0..196b26c 100644 --- a/invoke/luanti-remote/tasks.py +++ b/invoke/luanti-remote/tasks.py @@ -18,8 +18,10 @@ BACKUP_FILE=f'world.{TODAY}.tar' LOCAL_BACKUPS=f'{LOCAL_HOME}/backup/luanti' LUANTI=f'{HOME}/luanti' +LOCAL_LUANTI=f'{LOCAL_HOME}/.var/app/net.minetest.Minetest/.minetest' MODS=f'{LUANTI}/mods' WORLDS=f'{LUANTI}/worlds' +WORLD_CONF=f'{LUANTI}/worlds/{WORLD}/{WORLD}.mt' SERVE=f'screen -d -m {LUANTI}/bin/luantiserver --gameid minetest --worldname world' @@ -89,6 +91,42 @@ def push_updated_mod(c, mod): c.run(f'{SSH} -C tar xf {tmpdir}/{mod}.tar --directory {MODS}') c.run(f'{SSH} -C ls -l {MODS}/{mod}') +@task +def list_local_mods(c): + c.run(f'ls -al {LOCAL_LUANTI}/mods') + +@task +def push_local_mod(c, mod): + tarfile = f'{LOCAL_BACKUPS}/mods/{mod}.tar' + print(f'Compressing local mod {mod} to {tarfile}') + c.run(f'tar cf {tarfile} --directory={LOCAL_LUANTI}/mods {mod}') + c.run(f'tar --list -f {tarfile} | tail') + c.run(f'tar --list -f {tarfile} | wc') + + print(f'Pushing {tarfile} to {USER_AT_IP}:/tmp') + c.run(f'scp {tarfile} {USER_AT_IP}:/tmp') + c.run(f'{SSH} -C ls /tmp | grep {mod}') + + print(f'Unpacking {mod}.tar...') + c.run(f'{SSH} -C tar xf /tmp/{mod}.tar --directory {MODS}') + c.run(f'{SSH} -C ls -l {MODS} | grep {mod}') + c.run(f'{SSH} -C ls -l {MODS}/{mod}') + + print(f'Enable {mod} in config') + print(f'Remember to enable {mod} in config (invoke enable-mod {mod})') + +@task +def enable_mod(c, mod): + enable_line = f'load_mod_{mod} = mods/{mod}' + result = c.run(f'{SSH} -C cat {WORLD_CONF} | grep {mod} &2>/dev/null') + print(result.stdout) + if(not mod in result.stdout): + print(f'Mod {mod} not found in {WORLD_CONF}. Adding.') + c.run(f'{SSH} -C "echo {enable_line} >> {WORLD_CONF}"') + else: + print(f'{MOD} already enabled in {WORLD_CONF}') + print(f'Grep result: {result.stdout}') + print("Remember to restart the server (invoke serve)!") @task def compress_world(c):