-
Notifications
You must be signed in to change notification settings - Fork 11
/
keep-mega-alive.bat
63 lines (50 loc) · 1.09 KB
/
keep-mega-alive.bat
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
51
52
53
54
55
56
57
58
59
60
61
62
63
@echo off
@rem Keep-MEGA-Alive
@rem https://github.com/3ncod3/keep-mega-alive
setlocal EnableDelayedExpansion
set VERSION=1.2
if "%~1"=="--version" (
echo Keep-MEGA-Alive v%VERSION%
goto :eof
)
where /q mega-version
if %errorlevel% neq 0 (
echo Error: MEGAcmd is not installed. Get it from https://mega.io/cmd
goto :eof
)
if "%~1" == "" (
set "LOGINS=mega-logins.csv"
) else (
set "LOGINS=%1"
)
call MEGAcmdServer & /dev/null
call mega-logout >NUL
call :log
call :log Starting Keep-MEGA-Alive v%VERSION%
for /F "tokens=1,2" %%i in (%LOGINS%) do (
call :process %%i %%j > keep-mega-alive.tmp 2>&1
type keep-mega-alive.tmp >> keep-mega-alive.log
type keep-mega-alive.tmp
)
goto :cleanup
:log
echo [%DATE% %TIME%] %* >> keep-mega-alive.log
goto :eof
:process
call :log Trying to login as %1
echo %1
call mega-login %1 %2 && (
call :log Successfully logged in as %1
) || (
call :log [ERROR] Unable to login as %1
)
call mega-df -h
call mega-logout >NUL
call :log Logged out from %1
echo.
goto :eof
:cleanup
del keep-mega-alive.tmp
call :log Finished running Keep-MEGA-Alive
pause
:eof