The officially official Devuan Forum!

You are not logged in.

#1 2019-04-21 20:10:37

pota
Member
Registered: 2019-02-08
Posts: 12  

Devuan and WireGuard / Mullvad VPN

I'm trying to configure WireGuard (with Mullvad) on Devuan by following this guide:
https://mullvad.net/it/guides/easy-wire … ultihop-wg
everything works.
the only problem is the following passage which obviously on devuan is not possible:

Q: How do I make WireGuard start automatically on boot?
A: systemctl enable wg-quick@mullvad-se4

how to do on devuan?
thank you!

Offline

#2 2019-04-21 20:42:57

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

Here is the unit file:

https://git.zx2c4.com/WireGuard/plain/s … k@.service

The ExecStart line is the command that is executed by the unit file, replace %i with mullvad-se4 and incorporate it into a boot script for sysvinit.


Brianna Ghey — Rest In Power

Offline

#3 2019-04-22 08:18:50

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

Head_on_a_Stick wrote:

Here is the unit file:

https://git.zx2c4.com/WireGuard/plain/s … k@.service

The ExecStart line is the command that is executed by the unit file, replace %i with mullvad-se4 and incorporate it into a boot script for sysvinit.

Thank you for your answer.
in which folder do I find the file unit to be edited?
excuse ignorance

Offline

#4 2019-04-22 08:53:32

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

The wgquick@.service unit file uses the .ini style ('cos the devs love Windows, presumably) and so cannot be used with sysvinit, you will need to convert it to a shell script instead.

Something like this executable file in /etc/init.d/wireguard might work:

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          wireguard
# Required-Start:    mountkernfs $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: WireGuard via wg-quick(8)  
### END INIT INFO

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

do_start() {
   /usr/bin/wg-quick up mullvad-se4
}
do_stop() {
   /usr/bin/wg-quick down mullvad-se4
}

case $1 in
(start|restart|reload|force-reload)
   do_invoke start
   ;;
(stop)
   do_invoke stop
   ;;
(*)
   echo >&2 "Usage: $0 {start|stop|restart|reload|force-reload}"
   exit 3
   ;;
esac

Enable it with

# update-rc.d wireguard defaults

Disclaimer: I'm crap with sysvinit scripts so perhaps wait for somebody to point out my mistakes before trying this.


Brianna Ghey — Rest In Power

Offline

#5 2019-04-22 09:50:46

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

Head_on_a_Stick wrote:

The wgquick@.service unit file uses the .ini style ('cos the devs love Windows, presumably) and so cannot be used with sysvinit, you will need to convert it to a shell script instead.

Something like this executable file in /etc/init.d/wireguard might work:

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          wireguard
# Required-Start:    mountkernfs $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: WireGuard via wg-quick(8)  
### END INIT INFO

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

do_start() {
   /usr/bin/wg-quick up mullvad-se4
}
do_stop() {
   /usr/bin/wg-quick down mullvad-se4
}

case $1 in
(start|restart|reload|force-reload)
   do_invoke start
   ;;
(stop)
   do_invoke stop
   ;;
(*)
   echo >&2 "Usage: $0 {start|stop|restart|reload|force-reload}"
   exit 3
   ;;
esac

Enable it with

# update-rc.d wireguard defaults

Disclaimer: I'm crap with sysvinit scripts so perhaps wait for somebody to point out my mistakes before trying this.

so. summarizing. I have to create a "blank file" in /etc/init.d/wireguard with the extension .ini named as I want. I paste into it the content of the text you provided me. I make it executable and active with the command

# update-rc.d wireguard defaults

okay?
Sorry again and thanks

Offline

#6 2019-04-22 10:22:40

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

pota wrote:

with the extension .ini

No "extension" is needed, that's a Windows thing. And .ini-style files are what systemd uses.

Also, please don't full quote for a straight reply, it reduces the readability of the thread.


Brianna Ghey — Rest In Power

Offline

#7 2019-04-22 11:27:20

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

Head_on_a_Stick wrote:
pota wrote:

with the extension .ini

No "extension" is needed, that's a Windows thing. And .ini-style files are what systemd uses.

Also, please don't full quote for a straight reply, it reduces the readability of the thread.

Okay. Sorry. So I'm giving this command:

nano /etc/init.d/wireguard

I insert the text you posted to me. and finally activate it with the command:

update-rc.d wireguard defaults

right?

Offline

#8 2019-04-22 11:30:34

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

Yes.

Thinking about this a bit more: you may have to add networking to the Required-Start line to get the network up before the VPN is started but I'm not really sure.

I can't believe you full-quoted me again though (and even included the request to stop full-quoting in the quote). Ah well.

Last edited by Head_on_a_Stick (2019-04-22 11:39:51)


Brianna Ghey — Rest In Power

Offline

#9 2019-04-22 11:43:13

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

update-rc.d wireguard defaults
insserv: script wireguard is not an executable regular file, skipped!

Releases me this error.

(I thought you were asking me not to mention long fragments of conversation. now I have not mentioned anything. excuse me.)

Offline

#10 2019-04-22 12:20:18

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

# chmod +x /etc/init.d/wireguard

Brianna Ghey — Rest In Power

Offline

#11 2019-04-22 12:38:18

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

Thank you. done but not working. does not start automatically

Offline

#12 2019-04-22 14:19:14

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

In which case check the journal logs to find out what's going wrong and then fiddle with the service file to get it to work.


Brianna Ghey — Rest In Power

Offline

#13 2019-04-22 16:16:53

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

I'm sorry, but I don't have the necessary skills.
I start it manually.
Is it possible to remove what we have done so far?
thanks. excuse the trouble

Offline

#14 2019-04-22 16:37:36

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Devuan and WireGuard / Mullvad VPN

pota wrote:

I don't have the necessary skills

Me neither, that's why it didn't work big_smile

pota wrote:

Is it possible to remove what we have done so far?

Of course: just run

# update-rc.d -f wireguard remove
# rm /etc/init.d/wireguard
pota wrote:

excuse the trouble

That's OK, it was no trouble at all.

Sorry I couldn't get it working for you.


Brianna Ghey — Rest In Power

Offline

#15 2019-04-23 09:00:19

pota
Member
Registered: 2019-02-08
Posts: 12  

Re: Devuan and WireGuard / Mullvad VPN

I solved it using OpenVPN instead of WireGuard ;-)

Offline

#16 2019-07-24 22:34:19

paulxx
Member
Registered: 2019-07-24
Posts: 1  

Re: Devuan and WireGuard / Mullvad VPN

For anyone else needing help, unless I'm missing something, just add

wg-quick up wg0   

to   /etc/rc.local   before the "exit 0" line. That will run it on startup.

Offline

#17 2021-12-29 16:32:09

user068681
Member
Registered: 2020-05-02
Posts: 2  

Re: Devuan and WireGuard / Mullvad VPN

Greetings!

Mullvad's philosophy is spot on: both accessible and permissive in exactly the sense a privacy application should be.

Please find here simpler SysVinit script which either runs the binary, hangs up, or employs devuan's init-functions to query the status.   

1 install Mullvad's .deb package
2 create this /etc/init.d/mullvad

#! /bin/sh 

### BEGIN INIT INFO
# Provides:             mullvad-daemon
# Required-Start:
# Required-Stop:
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    Start and stop mullvad-daemon
# Description:          A simple init for Mullvad VPN
### END INIT INFO

. /lib/lsb/init-functions
name=${0##*/}
bin=/opt/Mullvad\ VPN/resources/mullvad-daemon

case "$1" in
        start)
                "$bin" &
                ;;
        stop)
                start-stop-daemon --stop --exec "$bin" --
                ;;
        status)
                status_of_proc "mullvad-daemon" "$name"
                ;;
          *)
                log_action_msg "Usage: $0 {start|stop|status}"
                ;;
esac
exit 0

3 update-rc.d mullvad defaults

The daemon will now run at startup. Configure wireguard or anything as a normal user with mullvad(1) client program.

All the best,

Offline

Board footer