Created
December 12, 2022 18:07
-
-
Save KisaragiEffective/e2d74e170c1560a0a0841dc7600a50ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# The author of this script, KisaragiEffective and Kisaragi Marine, put this script | |
# under CC0. Please refer https://creativecommons.org/publicdomain/zero/1.0/legalcode to | |
# its full-text. | |
red() { | |
tput setaf 1 | |
} | |
green() { | |
tput setaf 2 | |
} | |
reset() { | |
tput sgr0 | |
} | |
die () { | |
echo "[$(red)ERROR$(reset)] $(echo "$@")$(reset)" | |
exit 1 | |
} | |
# is /dev/stdout piped? | |
if [ -t 1 ]; then | |
color= | |
else | |
color=1 | |
fi | |
if [[ -z "$neos_install_dir" ]]; then | |
neos_install_dir="~/.steam/steam/steamapps/common/NeosVR" | |
fi | |
if [[ ! -d "$neos_install_dir" ]]; then | |
die "install location $neos_install_dir does not found. Please set \$neos_install_dir explicitly with yout installation path. NOTE: ~ must be replaced with $HOME" | |
fi | |
latest_version="$(curl -sSL4 https://assets.neos.com/install/Pro/Public)" | |
sz="$(mktemp).7z" | |
wget -q4O "$sz" "http://assets.neos.com/install/Pro/Data/${latest_version}.7z" | |
# check file | |
du -b $sz | |
sha512sum $sz | |
# extract | |
dest="$(mktemp -d)" | |
if [[ -f "$(which 7zr 2>/dev/null)" ]]; then | |
# partial extract (more effecient) | |
echo "extracting to $dest. backend: 7zr" | |
mkdir -p "$dest/Neos_Data/Managed" | |
(cd "$dest/Neos_Data/Managed" && 7zr e "$sz" Neos_Data/Managed/FrooxEngine.dll Neos_Data/Managed/CloudX.Shared.dll) | |
clean_sz_on_exit=1 | |
elif [[ -f "$(which p7zip 2>/dev/null)" ]]; then | |
# full extract | |
echo "extracting to $dest. backend: p7zip" | |
(cd "$dest" && p7zip -d "$sz") | |
else | |
echo "$(red)p7zip is required!!$(reset)" >&2 | |
fi | |
# copy | |
for f in "FrooxEngine.dll" "CloudX.Shared.dll"; do | |
from="$dest/Neos_Data/Managed/$f" | |
to="$neos_install_dir/Neos_Data/Managed/$f" | |
echo "copy: $(green) ${from} $(reset) to $(green) $to $(reset)" | |
if [[ -z "$dry_run" ]]; then | |
cp "$from" "$to" || die "FATAL: archive does not contain $f" | |
else | |
: | |
fi | |
done | |
# finish | |
echo "$(green)Replacing is done!$(reset)" >&2 | |
rm -r "$dest" | |
[[ ! -z "$clean_sz_on_exit" ]] && rm "$sz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment