Skip to content

Instantly share code, notes, and snippets.

@tommyv1987
Last active March 27, 2024 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyv1987/7d210d4daa8f7abc61f9a696d0321f19 to your computer and use it in GitHub Desktop.
Save tommyv1987/7d210d4daa8f7abc61f9a696d0321f19 to your computer and use it in GitHub Desktop.
Run the nym-vpn-client for MacOs or Linux
#!/bin/bash
echo "welcome to the NYM client installation"
echo "this will now use the NYX mainnet network"
echo "enjoy"
release_url="https://api.github.com/repos/nymtech/nym-vpn-client/releases"
version=$(curl -s $release_url | jq -r '.[].tag_name' | grep '^nym-vpn-desktop-v' | sort -Vr | head -n 1 | awk -F'-v' '{print $NF}')
mac_file="nym-vpn-desktop_${version}_macos_universal"
linux_file="nym-vpn-desktop_${version}_ubuntu-22.04_x86_64"
mainnet_env_url="https://raw.githubusercontent.com/nymtech/nym/develop/envs/mainnet.env"
nym_vpn_dir="${HOME}/nym-vpn-latest"
machine=$(uname -s)
case "$machine" in
Darwin*)
file=$mac_file
;;
Linux*)
file=$linux_file
;;
*)
echo "invalid platform. This script supports Mac and Linux only."
exit 1
;;
esac
download=https://github.com/nymtech/nym-vpn-client/releases/download/nym-vpn-desktop-v${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 .env file..."
curl -L "$mainnet_env_url" -o .env
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"
strip_dmg=$(echo "$file" | sed 's/_macos//' | sed 's/-desktop//')
dmg_path="${nym_vpn_dir}/${file}/${strip_dmg}.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."
fi
echo "creating the configuration file in the root directory"
cd $nym_vpn_dir
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} with root privileges..."
sudo "/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 "RUST_LOG=nym_vpn_desktop=debug,nym_client_core=info,nym_vpn_lib=debug ~/nym-vpn-latest/*/nym-vpn_${version}_amd64.AppImage"
;;
*)
echo "not valid machine download"
;;
esac
@tommyv1987
Copy link
Author

update versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment