-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
192 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
function LOG_impl() { | ||
local -r loglevel=$1 | ||
local -r messages=${*:2} | ||
local -r timestamp=$(date +'%Y/%m/%d %H:%M:%S.%3N') | ||
echo "[${timestamp}] ${loglevel} ${messages}" | ||
} | ||
|
||
function LOGD() { | ||
local -r messages=$* | ||
local -r LEVEL='D' | ||
LOG_impl ${LEVEL} "${messages}" | ||
} | ||
|
||
function LOGI() { | ||
local -r messages=$* | ||
local -r LEVEL='I' | ||
LOG_impl ${LEVEL} "${messages}" | ||
} | ||
|
||
function LOGE() { | ||
local -r messages=$* | ||
local -r LEVEL='E' | ||
LOG_impl ${LEVEL} "${messages}" | ||
} | ||
|
||
function update_scoop() { | ||
LOGI "Update scoop" | ||
scoop update | ||
} | ||
|
||
function update_installed_packages() { | ||
LOGI "Update installed packages" | ||
scoop update '*' | ||
} | ||
|
||
function add_bucket() { | ||
local -r bucket_name=$1 | ||
|
||
local exists=0 | ||
set +e | ||
scoop bucket list | grep "${bucket_name}" > /dev/null | ||
exists=$? | ||
set -e | ||
|
||
if [ ${exists} -eq 0 ]; then | ||
LOGD "Already added ${bucket_name}" | ||
return | ||
fi | ||
|
||
LOGI "Add bucket ${bucket_name}" | ||
scoop bucket add "${bucket_name}" | ||
} | ||
|
||
function install_package() { | ||
local -r package_name=$1 | ||
|
||
local exists=0 | ||
set +e | ||
scoop list | grep "${package_name}" > /dev/null | ||
exists=$? | ||
set -e | ||
|
||
if [ ${exists} -eq 0 ]; then | ||
LOGD "Already installed ${package_name}" | ||
return | ||
fi | ||
|
||
LOGI "Install ${package_name}" | ||
scoop install "${package_name}" | ||
} | ||
|
||
function main() { | ||
local mode=$1 | ||
|
||
update_scoop | ||
update_installed_packages | ||
|
||
add_bucket "extras" | ||
add_bucket "versions" | ||
|
||
git config --global core.autocrlf false | ||
|
||
local packages=(\ | ||
"consolez" \ | ||
"gimp" \ | ||
"jq" \ | ||
"make" \ | ||
"peazip" \ | ||
"python37" \ | ||
"shellcheck" \ | ||
"terminus" \ | ||
"vagrant" \ | ||
"vscode-portable" \ | ||
"winmerge" \ | ||
) | ||
|
||
case ${mode} in | ||
"1" ) | ||
packages+=(\ | ||
"cryptomator" \ | ||
"flac" \ | ||
"libreoffice-fresh" \ | ||
) | ||
;; | ||
"2" ) | ||
packages+=(\ | ||
"cmake" \ | ||
"winscp" \ | ||
) | ||
;; | ||
"3" ) | ||
packages+=(\ | ||
"firefox-esr" \ | ||
) | ||
;; | ||
* ) | ||
LOGE "Invalid mode specified (mode=${mode})" | ||
return 1 | ||
;; | ||
esac | ||
|
||
for package in "${packages[@]}"; do | ||
install_package "${package}" | ||
done | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@echo off | ||
|
||
:Main | ||
setlocal | ||
where scoop > nul 2> nul | ||
if %ERRORLEVEL% == 1 ( | ||
call :LogError "You must install scoop. https://github.com/lukesampson/scoop" | ||
exit /b | ||
) | ||
|
||
call :InstallPackage "git-with-openssh" | ||
call :InstallPackage "aria2" | ||
|
||
exit /b | ||
endlocal | ||
|
||
:InstallPackage | ||
setlocal | ||
set PACKAGE_NAME=%~1 | ||
|
||
scoop list | find " %PACKAGE_NAME% " > nul | ||
if %ERRORLEVEL% == 0 ( | ||
call :LogDebug "Already installed" %PACKAGE_NAME% | ||
) else ( | ||
call :LogInfo "Install" %PACKAGE_NAME% | ||
call scoop install %PACKAGE_NAME% | ||
) | ||
|
||
exit /b | ||
endlocal | ||
|
||
:LogDebug | ||
setlocal | ||
call :LogImpl D %* | ||
exit /b | ||
endlocal | ||
|
||
:LogInfo | ||
setlocal | ||
call :LogImpl I %* | ||
exit /b | ||
endlocal | ||
|
||
:LogError | ||
setlocal | ||
call :LogImpl E %* | ||
exit /b | ||
endlocal | ||
|
||
:LogImpl | ||
setlocal | ||
set /p NOP=%date% < nul | ||
set /p NOP=%time% < nul | ||
for %%s in (%*) do ( | ||
set /p NOP=%%~s < nul | ||
) | ||
echo; | ||
exit /b | ||
endlocal |