forked from XternA/income-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.bat
49 lines (40 loc) · 1.29 KB
/
start.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
@echo off
setlocal
winget --version >nul 2>&1
if %errorlevel% neq 0 (
echo No winget found on the system. Please install winget before proceeding.
exit /b 1
)
wsl --version >nul 2>&1
if %errorlevel% equ 0 (
wsl ! [ -d $HOME/.income-generator ] && call :GetTool
call :CheckAndRegisterAlias
wsl ${SHELL##*/} -ilc "igm"
) else (
echo No Windows Subsystem for Linux found on the system. Ensure WSL is enabled before proceeding.
)
exit /b 0
REM -- Sub-calls -------------
:CheckAndRegisterAlias
wsl -e sh -c "if [ -f $HOME/.aliases ]; then exit 0; else exit 1; fi"
if %errorlevel% equ 0 (
wsl grep -q "igm='(cd ~/.income-generator; sh start.sh)'" "$HOME/.aliases" || call :RegisterToAliases
) else (
wsl grep -q "igm='(cd ~/.income-generator; sh start.sh)'" "$HOME/.${SHELL##*/}rc" || call :RegisterToRC
)
exit /b 0
:RegisterToAliases
wsl -e sh -c "echo \"alias igm='(cd ~/.income-generator; sh start.sh)'\" >> $HOME/.aliases"
exit /b 0
:RegisterToRC
wsl -e sh -c "echo \"alias igm='(cd ~/.income-generator; sh start.sh)'\" >> $HOME/.${SHELL##*/}rc"
exit /b 0
:GetTool
echo:
echo No Income Generator found. Fetching...
echo:
wsl git clone --depth=1 https://github.com/XternA/income-generator.git $HOME/.income-generator
echo:
echo Launching...
timeout /t 2 /nobreak >nul 2>&1
exit /b 0