-
Notifications
You must be signed in to change notification settings - Fork 34
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
moqsien
committed
Jun 1, 2024
1 parent
10793ac
commit 1f61b50
Showing
2 changed files
with
139 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<# | ||
@@ Copyright (c) 2024 moqsien@hotmail.com | ||
@@ | ||
@@ Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
@@ this software and associated documentation files (the "Software"), to deal in | ||
@@ the Software without restriction, including without limitation the rights to | ||
@@ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
@@ the Software, and to permit persons to whom the Software is furnished to do so, | ||
@@ subject to the following conditions: | ||
@@ | ||
@@ The above copyright notice and this permission notice shall be included in all | ||
@@ copies or substantial portions of the Software. | ||
@@ | ||
@@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
@@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
@@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
@@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
@@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
@@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
#> | ||
|
||
$sysType=systeminfo | find "System Type" | ||
|
||
Write-Host "$sysType" | ||
|
||
$arch="amd64" | ||
if ( "$sysType" -match "arm" ) | ||
{ | ||
$arch="arm64" | ||
} | ||
|
||
$version="v0.6.1" | ||
|
||
$filename="vmr_windows-" + $arch + ".zip" | ||
$download_url="https://gvc.1710717.xyz/proxy/https://github.com/gvcgo/version-manager/releases/download/" | ||
|
||
$url=$download_url + $version + "/" + $filename | ||
|
||
Write-Host "Downloading files..." | ||
|
||
Invoke-RestMethod -Uri $url -OutFile $filename | ||
|
||
$TRUE_FALSE=(Test-Path $filename) | ||
if ( $TRUE_FALSE -eq "True" ) | ||
{ | ||
Expand-Archive -Path $filename -DestinationPath .\ | ||
$TRUE_FALSE=(Test-Path "vmr.exe") | ||
if ( $TRUE_FALSE -eq "True" ) | ||
{ | ||
.\vmr.exe i | ||
remove-Item -Recurse -Force .\vmr.exe | ||
} | ||
remove-Item -Recurse -Force $filename | ||
} |
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,85 @@ | ||
#!/bin/sh | ||
# ==================================================== | ||
# Installs/Updates version-manager(vm) for MacOS/Linux | ||
# ==================================================== | ||
# Copyright (c) 2024 moqsien@hotmail.com | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
# this software and associated documentation files (the "Software"), to deal in | ||
# the Software without restriction, including without limitation the rights to | ||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
# the Software, and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
say() { | ||
printf 'vm: %s\n' "$1" | ||
} | ||
|
||
err() { | ||
say "$1" >&2 | ||
exit 1 | ||
} | ||
|
||
check_cmd() { | ||
command -v "$1" > /dev/null 2>&1 | ||
} | ||
|
||
need_cmd() { | ||
if ! check_cmd "$1"; then | ||
err "need '$1' (command not found)" | ||
fi | ||
} | ||
|
||
main() { | ||
local os_type="$(uname -s)" | ||
local os_arch="$(uname -m)" | ||
|
||
local version="v0.6.1" | ||
|
||
local download_url="https://gvc.1710717.xyz/proxy/https://github.com/gvcgo/version-manager/releases/download/" | ||
local osType="linux" | ||
if [ "$os_type" = "Darwin" ]; then | ||
osType="darwin" | ||
fi | ||
|
||
local osArch="amd64" | ||
|
||
if [ "$os_arch" = "arm64" ] || [ "$os_type" = "aarch64" ]; then | ||
osArch="arm64" | ||
fi | ||
|
||
local filename="vmr_$osType-$osArch.zip" | ||
local url="$download_url$version/$filename" | ||
echo "$url" | ||
need_cmd "curl" | ||
need_cmd "unzip" | ||
need_cmd "mkdir" | ||
|
||
echo "Downloading files..." | ||
|
||
curl -o "$filename" "$url" | ||
|
||
echo "Installing..." | ||
|
||
if [ -s "./$filename" ]; then | ||
unzip "./$filename" | ||
chmod +x "./vmr" | ||
if [ -s "./vmr" ]; then | ||
./vmr i | ||
fi | ||
rm -rf "./$filename" | ||
rm -rf "./vmr" | ||
fi | ||
} | ||
|
||
main |