Skip to content

Instantly share code, notes, and snippets.

@serinko
Last active February 20, 2024 09:53
Show Gist options
  • Save serinko/e0a9f7ff3d79e974ec6f6783caa1137e to your computer and use it in GitHub Desktop.
Save serinko/e0a9f7ff3d79e974ec6f6783caa1137e to your computer and use it in GitHub Desktop.
Donwload, verify and run NymVPN desktop alpha binary
#!/bin/bash
# this is an edited version of a script called nym-vpn-install-run.sh by @tommy1987
# link to the original script https://gist.github.com/tommyv1987/7d210d4daa8f7abc61f9a696d0321f19
echo "welcome to the NYM client installation"
echo "disclaimer: macOS arch version is only available post 0.0.4"
version="0.0.4"
mac_file="nym-vpn-desktop_${version}_macos_x86_64"
linux_file="nym-vpn-desktop_${version}_ubuntu-22.04_x86_64"
mac_arch_file="nym-vpn-desktop_${version}_macos_aarch64"
sandbox_env_url="https://raw.githubusercontent.com/nymtech/nym/develop/envs/sandbox.env"
download_page="https://github.com/nymtech/nym/releases/tag/nym-vpn-alpha-${version}"
nym_vpn_dir="${HOME}/nym-vpn-latest"
machine=$(uname -s)
# not sure if this is needed let's see...
# this is more from a dev perspective given the pre-reqs by https://tauri.app/v1/guides/getting-started/prerequisites/
check_and_install_packages() {
for pkg in build-essential libssl-dev libayatana-appindicator3-dev libgtk-3-dev librsvg2-dev librsvg2-dev libwebkit2gtk-4.0-dev; do
if ! dpkg -l | grep -qw $pkg; then
apt --fix-broken install #just in case something isn't correct
echo "installing missing package: $pkg"
sudo apt-get install -y $pkg
else
echo "package $pkg is already installed."
fi
done
}
case "$machine" in
Darwin*)
arch=$(uname -m)
case "$arch" in
x86_64)
file=$mac_file
;;
arm64)
file=$mac_arch_file
;;
*)
echo "unsupported macOS architecture: $arch"
exit 1
;;
esac
;;
Linux*)
file=$linux_file
check_and_install_packages
;;
*)
echo "invalid platform. This script supports Mac and Linux only."
exit 1
;;
esac
download="https://github.com/nymtech/nym/releases/download/nym-vpn-alpha-${version}/${file}.tar.gz"
if [ -d "$nym_vpn_dir" ]; then
echo "deleting existing directory $nym_vpn_dir..."
rm -rf "$nym_vpn_dir"
fi
echo "creating $nym_vpn_dir directory..."
mkdir -p "$nym_vpn_dir"
cd "$nym_vpn_dir"
echo "downloading $file.tar.gz..."
curl -LO "$download"
echo "extracting $file.tar.gz..."
tar -xvf "$file.tar.gz"
read -p "do you want to verify the checksum? [y/N]: " verify_checksum
if [[ $verify_checksum == [yY] ]]; then
echo "please enter the full text for example: '2e0b33c1468a7453745f9a3325989399ba216972689b6a76348a1c6759a5e7e6' for your ${file}.tar.gz"
read -p "what is the checksum presented on the downloads page for the tar.gz file: ${download_page}? " checksum
if command -v sha256sum &>/dev/null; then
calculated_checksum=$(sha256sum "$file.tar.gz" | awk '{print $1}')
elif command -v shasum &>/dev/null; then
calculated_checksum=$(shasum -a 256 "$file.tar.gz" | awk '{print $1}')
else
echo "checksum tool not found. unable to verify the checksum. 🤔 "
exit 1
fi
if [ "$calculated_checksum" == "$checksum" ]; then
echo "checksum verified. download is valid."
else
echo "checksum does not match. the binary may be corrupted or tampered with - contact a nym member"
exit 1
fi
else
echo "skipping checksum verification..."
fi
echo "to run the vpn, we have to mount the dmg then move it to Applications"
echo "🏎 🛠 - time to mount - 🏎 🛠 "
if [ "$machine" == "Darwin" ]; then
echo "running on macOS"
app_name="nym-vpn.app"
dmg_path="${nym_vpn_dir}/${file}/${file}.dmg"
mount_point="/tmp/nym-vpn-mount"
mkdir -p "$mount_point"
echo "mounting .dmg file..."
hdiutil attach -mountpoint "$mount_point" "$dmg_path"
echo "copying ${app_name} to /Applications..."
cp -R "$mount_point/$app_name" /Applications/
echo "unmounting .dmg file..."
if ! hdiutil detach "$mount_point"; then
echo "regular unmount failed, attempting to force unmount..."
hdiutil detach "$mount_point" -force
fi
echo "${app_name} has been installed to /Applications."
else
chmod u+x ./"$file"/nym-vpn_${version}_amd64.AppImage
echo "moving the nym-vpn client binary to $nym_vpn_dir..."
mv ./"$file"/nym-vpn_${version}_amd64.AppImage $nym_vpn_dir
fi
echo "creating the configuration file in the root directory"
cd $nym_vpn_dir
echo "downloading .env file..."
curl -L "$sandbox_env_url" -o .env
echo "script completed. the VPN binary and configuration files are in $nym_vpn_dir."
echo "to run the VPN please use:"
echo "MacOS: sudo -E /Applications/nym-vpn.app/Contents/MacOS/nym-vpn"
echo "Linux: sudo -E ~/nym-vpn-latest/nym-vpn_${version}_amd64.AppImage"
case "$machine" in
Darwin*)
echo "cleaning up files..."
rm -rf "macos" "dmg" "$file".tar.gz
echo "opening ${app_name}..."
open "/Applications/nym-vpn.app/Contents/MacOS/nym-vpn"
;;
Linux*)
echo "cleaning up files"
rm -rf "$file".tar.gz
echo "now running the vpn binary"
sudo -E ~/nym-vpn-latest/nym-vpn_${version}_amd64.AppImage
;;
*)
echo "not valid machine download"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment