]>
us-delaporte.pagekite.me Git - dotfiles.git/blob - invoke/minecraft-remote/tasks.py
6f3dbd17f8758bf083a99cc4a676b9649b8e5697
1 from invoke
import task
2 from invoke
import tasks
4 from datetime
import datetime
as dt
6 IP
=os
.environ
.get('LUANTI_IP')
7 USER
=os
.environ
.get('LUANTI_USER')
8 HOME
=os
.environ
.get('LUANTI_HOME')
9 LOCAL_HOME
=os
.environ
.get('HOME')
11 TODAY
= dt
.now().strftime('%Y.%m.%d')
13 USER_AT_IP
=f
'{USER}@{IP}'
14 SSH
=f
'ssh {USER}@{IP}'
15 SCP
=f
'scp {USER}@{IP}'
17 DATE_TAR
=f
'{TODAY}.tar'
20 LOCAL_BACKUPS
=f
'{LOCAL_HOME}/backup/minecraft'
22 MINECRAFT
=f
'{HOME}/Minecraft'
24 dims
= ['world', 'world_nether', 'world_the_end']
27 def compress_world(c
):
29 c
.run(f
'{SSH} -C tar cf /tmp/{world}.{DATE_TAR} --directory={MINECRAFT} {world}')
30 c
.run(f
'{SSH} -C ls /tmp | grep .tar')
35 stopped
= input("Is the server stopped?")
37 print("so go stop the server...")
39 c
.run(f
'mkdir -p {LOCAL_BACKUPS}')
42 c
.run(f
'{SCP}:/tmp/{world}.{DATE_TAR} {LOCAL_BACKUPS}')
44 c
.run(f
'ls -lh {LOCAL_BACKUPS} | grep .tar')
50 c
.run(f
'tar tvf {LOCAL_BACKUPS}/{world}.{DATE_TAR} | tail')
51 c
.run(f
'tar tvf {LOCAL_BACKUPS}/{world}.{DATE_TAR} | wc')
55 result
= c
.run(f
'ssh {USER}@{IP} -C screen -ls')
59 print(f
"Attempting to connect to {IP}")
60 result
= c
.run(f
'ssh {USER}@{IP} -C {SERVE}')
61 print(f
'Server should now be running in a remote screen session.')