microsoft/TypeAgent

Public

mirrored from https://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1fc57adce609e952e7e3362a5afd0fe2442b31be

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ts/tools/scripts/install-shell.cmd

128lines · modecode

1:: Copyright (c) Microsoft Corporation.
2:: Licensed under the MIT License.
3
4@echo off
5setlocal
6
7IF "%1" == "" (
8 call :Error No storage account specified.
9 exit /B 1
10)
11
12set STORAGE=%1
13IF "%2" == "" (
14 set CONTAINER=%1
15) ELSE (
16 set CONTAINER=%2
17)
18
19IF "%3" == "" (
20 set CHANNEL=lkg
21) ELSE (
22 set CHANNEL=%3
23)
24
25set DEST=%TEMP%\install-shell
26mkdir %DEST% > nul 2>&1
27IF ERRORLEVEL 1 (
28 call :Error Failed to create %DEST% directory.
29 exit /B 1
30)
31del /Q /S %DEST%\* > nul 2>&1
32IF ERRORLEVEL 1 (
33 call :Error Failed to delete files in %DEST% directory.
34 exit /B 1
35)
36
37call :Info Getting TypeAgent Shell from %CHANNEL% channel in %STORAGE%/%CONTAINER%.
38call :DownloadYml %PACKAGE%
39IF ERRORLEVEL 1 (
40 call :Cleanup
41 exit /B 1
42)
43
44FOR /F "tokens=1-2 delims=:" %%i IN (%DEST%\%CHANNEL%.yml) DO (
45 IF "%%i" == "path" (
46 set PACKAGE=%%j
47 )
48)
49
50IF "%PACKAGE%" == "" (
51 call :Error Failed to find path in %CHANNEL%.yml. Ensure that the file is valid.
52 call :Cleanup
53 exit /B 1
54)
55
56call :DownloadPackage %PACKAGE%
57IF ERRORLEVEL 1 (
58 call :Cleanup
59 exit /B 1
60)
61
62
63call :ExecutePackage %PACKAGE%
64IF ERRORLEVEL 1 (
65 call :Cleanup
66 exit /B 1
67)
68
69call :Cleanup
70exit /B 0
71
72:DownloadYml
73call :Info Downloading %CHANNEL%.yml
74call az storage blob download --account-name %STORAGE% --container-name %CONTAINER% --name %CHANNEL%.yml --file %DEST%\%CHANNEL%.yml --overwrite --auth-mode login > %DEST%\install-shell.log 2>&1
75IF ERRORLEVEL 1 (
76 call :Error Failed to download %CHANNEL%.yml from %STORAGE%/%CONTAINER%.
77 call :Error Ensure you that you are logged into azure cli with 'az login' and have access to the storage account.
78 type %DEST%\install-shell.log
79 exit /B 1
80)
81exit /B 0
82
83:DownloadPackage
84call :Info Downloading %1
85call az storage blob download --account-name %STORAGE% --container-name %CONTAINER% --name %1 --file %DEST%\%1 --overwrite --auth-mode login > %DEST%\install-shell.log 2>&1
86IF ERRORLEVEL 1 (
87 call :Error Failed to download %1 from %STORAGE%/%CONTAINER%.
88 type %DEST%\install-shell.log
89 exit /B 1
90)
91exit /B 0
92
93:ExecutePackage
94call :Info Running %1
95%DEST%\%1 > %DEST%\install-shell.log 2>&1
96IF ERRORLEVEL 1 (
97 call :Error Failed to install %1
98 type %DEST%\install-shell.log
99 exit /B 1
100)
101
102call :Success %1 installed successfully.
103call :Success TypeAgent Shell will start automatically.
104exit /B 0
105
106:Usage
107echo Usage: %0 ^<storage^> [^<container^>] [^<channel^>]
108echo ^<storage^> - The name of the storage account to use.
109echo ^<container^> - The name of the container to use. ^<storage^> will be used if not specified.
110echo ^<channel^> - The channel to use. Default to 'lkg' if not specified.
111exit /B 0
112
113:Info
114echo INFO: %*
115exit /B 0
116
117:Success
118echo SUCCESS: %*
119exit /B 0
120
121:Error
122echo ERROR: %*
123exit /B 0
124
125:Cleanup
126del /Q /S %DEST%\* > nul 2>&1
127rmdir /S /Q %DEST% > nul 2>&1
128exit /B 0