microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
d4f8bdebf1beb01e2e2e699b2cfe64b646281cbe

Branches

Tags

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

Clone

HTTPS

Download ZIP

ts/tools/scripts/install-shell.cmd

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