Skip to content

Instantly share code, notes, and snippets.

@polkaulfield
Last active March 16, 2024 22:00
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 polkaulfield/018824ab3cb082ae2570c88c3e7df57e to your computer and use it in GitHub Desktop.
Save polkaulfield/018824ab3cb082ae2570c88c3e7df57e to your computer and use it in GitHub Desktop.
update-mullvad-void.sh
#!/bin/sh
DIR=/tmp/mullvad-updater
LOCAL_VERSION=$(mullvad version 2> /dev/null | head -n 1 | sed 's/.*: //')
REMOTE_VERSION=$(curl -Ls -o /dev/null -w %{url_effective} https://mullvad.net/download/app/deb/latest/ -I | cut -d '-' -f 2 | cut -d '_' -f 1)
if [ "$LOCAL_VERSION" = "$REMOTE_VERSION" ]; then
echo Already at the latest verison !
exit 0
fi
# Get the deb package
mkdir $DIR
cd $DIR
wget --trust-server-names https://mullvad.net/download/app/deb/latest
wget --trust-server-names https://mullvad.net/download/app/deb/latest/signature
# Check signature
gpg --verify MullvadVPN-*.deb.asc || exit 1
ar x MullvadVPN-*.deb
tar xvf data.tar.xz
# Check if the service file is already created
if [ ! -f /etc/sv/mullvad/run ]; then
# Create service file
sudo mkdir /etc/sv/mullvad/
sudo tee /etc/sv/mullvad/run << EOF
#!/bin/sh
exec 2>&1
sv check dbus > /dev/null || exit 1
exec /opt/Mullvad\ VPN/resources/mullvad-daemon -v --disable-stdout-timestamps
EOF
# Enable service
sudo chmod +x /etc/sv/mullvad/run
sudo ln -s /etc/sv/mullvad /var/service/
fi
# Stop mullvad service
sudo sv stop mullvad
pkill -9 mullvad-gui
# Copy everything to /opt/ and /usr/local/ because it's not a package
sudo cp -r opt/* /opt/
sudo cp -r usr/local/* /usr/local/
sudo cp -r usr/share/* /usr/local/share/
# Cleanup tmp
cd - && rm -rf /tmp/mullvad-updater
# Start service
sudo sv up mullvad
@polkaulfield
Copy link
Author

polkaulfield commented Aug 16, 2022

Works for installing the mullvad app and updating it on Void Linux

@polkaulfield
Copy link
Author

polkaulfield commented Aug 17, 2022

You need to add the key to gpg for this to work first
https://mullvad.net/it/help/verifying-signatures/

@mblouka
Copy link

mblouka commented Feb 8, 2024

No longer works because the Mullvad daemon file no longer exists.

@chadcurtis
Copy link

No longer works because the Mullvad daemon file no longer exists.

In this case, it looks like they moved the file to a different directory in that package file.

I managed to work around this by modifying line 33 to:
exec /usr/bin/mullvad-daemon -v --disable-stdout-timestamps

And adding the following line after line 47:
sudo cp -r usr/bin/* /usr/bin

Thank you for writing this script also, it was extremely helpful!

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