Skip to content
Snippets Groups Projects
Commit 3ad8246f authored by Recolic K's avatar Recolic K
Browse files

add env check

parent 4c8c176b
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,11 @@ Designed for linux, can 100% run on windows and macOS, but not tested. It is you
All these dependencies are confirmed to support Linux (natively), WSL (natively), and win32 (Use your google to find smbclient for win32).
These dependencies could also be found on BSD, MacOS, and any OS with a working C++ compiler.
json2table >1.0.6 <https://git.recolic.net/root/json2table>, bash, smbclient <https://wiki.archlinux.org/index.php/samba#Client>, curl, unix binutil (cut,cat,tr,grep,,find,curl).
json2table >1.0.6 <https://git.recolic.net/root/json2table>, bash, smbclient (optional) <https://wiki.archlinux.org/index.php/samba#Client>, curl, unix binutil (cut,cat,tr,grep,,find,curl).
You may also need bearer-gen to generate bearer-token from PFX in your config file: <https://m365fleetagc.visualstudio.com/Core/_git/bearer-gen>
> If you are a Windows user, refer to <https://m365fleetagc.visualstudio.com/Core/_git/antidote-CIS-windows>
## Usage
......
......@@ -43,6 +43,22 @@ function curl_wrapped () {
return 0
}
function validate_environment () {
# This function helps user to check known environment errors. (especially for windows user)
[[ $ANTIDOTE_DISABLE_ENV_CHECK = 1 ]] && return
type curl | grep -i system32 > /dev/null && {
echo2 "Error: You are using curl.exe provided by Windows OS ($(type curl)). It's very likely that 'curl -o' will fail because of different directory tree. "
echo2 "You are recommended to install curl.exe provided by your GNU environment. (Usually MSYS, Cygwin or MinGW)"
echo2 "Run 'curl https://google.com -o /tmp/out.html' to see if you are victim of this error. If you are sure it's not a problem, set ANTIDOTE_DISABLE_ENV_CHECK=1 to disable the check. "
return 1
}
type json2table > /dev/null || {
echo2 "Error: You must install the dependency 'json2table'. You may compile from source at https://git.recolic.net/root/json2table/, or download pre-built windows executable at https://m365fleetagc.visualstudio.com/Core/_git/antidote-CIS-windows"
echo2 "If you are sure it's not a problem, set ANTIDOTE_DISABLE_ENV_CHECK=1 to disable the check. "
return 1
}
}
##############################################################################
function upload_to_smb_share () {
......@@ -368,27 +384,35 @@ done
# Call the actual subcommand
case "$subcmd" in
push)
validate_environment &&
subcmd_push "${filteredArgs[@]}" ; exit $?
;;
setdef)
validate_environment &&
subcmd_setdef "${filteredArgs[@]}" ; exit $?
;;
cloudrun)
validate_environment &&
subcmd_cloudrun "${filteredArgs[@]}" ; exit $?
;;
jobstatus)
validate_environment &&
subcmd_jobstatus "${filteredArgs[@]}" ; exit $?
;;
release)
validate_environment &&
subcmd_release "${filteredArgs[@]}" ; exit $?
;;
listver )
validate_environment &&
subcmd_listver "${filteredArgs[@]}" ; exit $?
;;
jobtype-upload )
validate_environment &&
subcmd_xmlupload "${filteredArgs[@]}" ; exit $?
;;
jobtype-download )
validate_environment &&
subcmd_xmldownload "${filteredArgs[@]}" ; exit $?
;;
*)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment