-
Notifications
You must be signed in to change notification settings - Fork 0
/
ark_force_update_mods_old.py
50 lines (39 loc) · 1.54 KB
/
ark_force_update_mods_old.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
from random import choice
from ark_manager import *
from paths import ARK_MODS_DIR
import os, shutil
from locks import Lock
from debug import get_logger
log = get_logger("arkbot")
import argparse
parser = argparse.ArgumentParser(description='Restart ark server.')
parser.add_argument("--message", dest='message', default=None, help="Message to add to broadcast, usually reason for restart.")
args = parser.parse_args()
if args.message:
args.message = args.message.strip()
if not args.message.endswith("."):
args.message = args.message + ". "
else:
args.message = args.message + " "
lock = Lock()
if lock.locked:
log.debug("Another script already running, exit...")
sys.exit()
print ("Starting...")
log.info("Admin initialized force update mods.")
# rm -rf /home/arkserver/serverfiles/ShooterGame/Content/Mods && mkdir /home/arkserver/serverfiles/ShooterGame/Content/Mods
# \\192.168.1.185\root\home\arkserver\.local\share\Steam\steamapps\workshop\content\346110
stop_server()
for file in os.listdir(ARK_MODS_DIR):
filepath = os.path.join(ARK_MODS_DIR, file)
try:
if os.path.isfile(filepath):
os.remove(filepath)
elif os.path.isdir(filepath):
shutil.rmtree(filepath)
except Exception as e:
log.error(f"Could not remove {filepath}", exc_info=True)
print ("Remove lock...")
lock.unlock()
broadcast(f"Server was restarted to force update mods. Should be back up in a few minutes as it redownloads mods and starts up. {args.message}{choice(random_funny_bits)}", False)