diff --git a/ArknightsMaaConfig/maa.py b/ArknightsMaaConfig/maa.py index 4ff9cf3..1335164 100755 --- a/ArknightsMaaConfig/maa.py +++ b/ArknightsMaaConfig/maa.py @@ -52,7 +52,7 @@ class CommandProcessor: # cp.Command("command") # cp.RetryCommand("command",retry_time:int) # asyncio.run(cp.AsyncCommand("command","stop track regex")) -script_dir = os.path.dirname((os.path.abspath(__file__))) +# script_dir = os.path.dirname((os.path.abspath(__file__))) cp = CommandProcessor() haveError = False def TaskFailRetry(command:str)->int: @@ -75,6 +75,7 @@ cp.Command("maa self update") cp.Command("docker stop redroid") redroid_path = os.getenv('redroid_path', "/home/lichx/.config/redroid-rk3588/") adb_address = os.getenv('adb_address', "localhost:5555") +log_dir = os.getenv('MAA_LOG', "/home/lichx/.config/redroid-rk3588/log/") os.chdir(redroid_path) cp.Command("docker compose up -d") time.sleep(15) @@ -89,7 +90,7 @@ haveError |= TaskFailRetry("maa run mall") != 0 haveError |= TaskFailRetry("maa run award") != 0 # storage error log if haveError: - cp.Command(f"cp {script_dir}/pyshell.log {script_dir}/pyshell.{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.log") + cp.Command(f"cp {log_dir}/pyshell.log {log_dir}/pyshell.{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.log") # shutdown cp.RetryCommand("maa closedown") cp.Command("docker stop redroid") diff --git a/run_all.sh b/run_all.sh index c85f557..ffde96a 100755 --- a/run_all.sh +++ b/run_all.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash + SCRIPT_DIR=$(dirname $(readlink -f "$0")) MAA_PY="$SCRIPT_DIR/ArknightsMaaConfig/maa.py" +MAA_LOG_DIR="${MAA_LOG:-/var/log/maa.log}" if [ -x "$MAA_PY" ]; then - "$MAA_PY" + "$MAA_PY" > "$MAA_LOG_DIR" 2>&1 else - python3 "$MAA_PY" + python3 "$MAA_PY" > "$MAA_LOG_DIR" 2>&1 fi \ No newline at end of file