The officially official Devuan Forum!

You are not logged in.

#1 2020-05-10 14:56:56

juic3
Member
Registered: 2018-11-27
Posts: 11  

Mullvad VPN

Hello comrades, if anyone is interested in using Mullvad VPN GUI client, It seems to work.
The client doesn't come with init script for sysvinit, but I managed to slap together a working one (modified from nginx, feel free to correct any mistakes).
Other problem is the path name to daemon containing space. I got aroud it by making a link Mullvad -> Mullvad VPN in /opt.
Here is the script:

#!/bin/sh

### BEGIN INIT INFO
# Provides:	  mullvad
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the mullvad daemon
# Description:       starts mullvad using start-stop-daemon
### END INIT INFO

#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/opt/Mullvad/resources/mullvad-daemon
#DAEMON="/opt/Mullvad\ VPN/resources/mullvad-daemon"

NAME=mullvad
DESC=mullvad

# Include mullvad defaults if available
if [ -r /etc/default/mullvad ]; then
	. /etc/default/mullvad
fi

STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"

test -x $DAEMON || exit 0

. /lib/init/vars.sh
. /lib/lsb/init-functions

PID=/run/mullvad.pid

start_mullvad() {
	# Start the daemon/service
	#
	# Returns:
	#   0 if daemon has been started
	#   1 if daemon was already running
	#   2 if daemon could not be started
	start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- \
		$DAEMON_OPTS 2>/dev/null \
		|| return 2
}

stop_mullvad() {
	# Stops the daemon/service
	#
	# Return
	#   0 if daemon has been stopped
	#   1 if daemon was already stopped
	#   2 if daemon could not be stopped
	#   other if a failure occurred
	start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME
	RETVAL="$?"
	sleep 1
	return "$RETVAL"
}

reload_mullvad() {
	# Function that sends a SIGHUP to the daemon/service
	start-stop-daemon --stop --signal HUP --quiet --pidfile $PID --name $NAME
	return 0
}

case "$1" in
	start)
		log_daemon_msg "Starting $DESC" "$NAME"
		start_mullvad
		case "$?" in
			0|1) log_end_msg 0 ;;
			2)   log_end_msg 1 ;;
		esac
		;;
	stop)
		log_daemon_msg "Stopping $DESC" "$NAME"
		stop_mullvad
		case "$?" in
			0|1) log_end_msg 0 ;;
			2)   log_end_msg 1 ;;
		esac
		;;
	restart)
		log_daemon_msg "Restarting $DESC" "$NAME"

		# Check configuration before stopping mullvad
		if ! test_config; then
			log_end_msg 1 # Configuration error
			exit $?
		fi

		stop_mullvad
		case "$?" in
			0|1)
				start_mullvad
				case "$?" in
					0) log_end_msg 0 ;;
					1) log_end_msg 1 ;; # Old process is still running
					*) log_end_msg 1 ;; # Failed to start
				esac
				;;
			*)
				# Failed to stop
				log_end_msg 1
				;;
		esac
		;;
	reload|force-reload)
		log_daemon_msg "Reloading $DESC configuration" "$NAME"

		# Check configuration before stopping mullvad
		#
		# This is not entirely correct since the on-disk mullvad binary
		# may differ from the in-memory one, but that's not common.
		# We prefer to check the configuration and return an error
		# to the administrator.
		if ! test_config; then
			log_end_msg 1 # Configuration error
			exit $?
		fi

		reload_mullvad
		log_end_msg $?
		;;
	status)
		status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $?
		;;
	*)
		echo "Usage: $NAME {start|stop|restart|reload|force-reload|status}" >&2
		exit 3
		;;
esac

Offline

#2 2020-05-24 15:47:02

climbingturtle
Member
From: Sweden
Registered: 2019-03-13
Posts: 11  

Re: Mullvad VPN

That is very nice work!
I did switch from Mullvad to an other provider just because of that reason.

There is also an old https://github.com/mullvad/mullvadvpn-app/issues/452 about this. Though the response from one of the devs there is not really getting any hopes up..

Offline

Board footer