Mullvad VPN SysV Script AntiX 22

Forum Forums New users New Users and General Questions Mullvad VPN SysV Script AntiX 22

  • This topic has 15 replies, 4 voices, and was last updated Apr 12-6:33 pm by antixcat.
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #104153
    Member
    antixcat

      Hello,

      This is my first post and I just want to preface by saying I am really enjoying AntiX. I’m a long time macos user who has flirted with various linux distros, but it wasn’t until I tried out AntiX that I decided to fully switch over. I’ve been learning and setting things up the last few weeks and have created a custom environment I’m happy with (and can replicate and reproduce on almost any computer or usb stick! how cool is that?). I’m still having a few problems, though, one of which is I can’t get the mullvad vpn service to start.

      I have installed Mullvad VPN from the official AntiX “Package Installer.” Without doing anything else, trying to run “sudo service mullvad-daemon start” gives me no output. Well, as it turns out my “/etc/init.d/mullvad-daemon” file is completely empty! I found a SysV script (the init system I’m using) for mullvad, and came up with this, which I added to my “/etc/init.d/mullvad-daemon” file (by discovering that mullvad-daemon executable was located in “/usr/bin/mullvad-daemon”):

      #!/bin/sh
      ### BEGIN INIT INFO
      # Provides: mullvad-daemon
      # Required-Start:   $syslog $local_fs 
      # Required-Stop:    $syslog $local_fs 
      # Should-Start: $network 
      # Default-Start:    2 3 4 5
      # Default-Stop:     0 1 6
      # Short-Description: Mullvad VPN daemon
      ### END INIT INFO
      
      . /lib/lsb/init-functions
      prog=mullvad-daemon
      PIDFILE=/var/run/$prog.pid
      DESC=”Mullvad VPN daemon”
      start() {
          log_daemon_msg “Starting $DESC” “$prog”
          start_daemon -p $PIDFILE “/usr/bin/mullvad-daemon” -v –disable-stdout-timestamps
          if [ $? -ne 0 ]; then
              log_end_msg 1
              exit 1
          fi
          if [ $? -eq 0 ]; then
              log_end_msg 0
          fi
          exit 0
      }
      
      stop() {
          log_daemon_msg “Stopping $DESC” “$prog”
          killproc -p $PIDFILE “/usr/bin/mullvad-daemon”
          if [ $? -ne 0 ]; then
              log_end_msg 1
              exit 1
          fi
          if [ $? -eq 0 ]; then
              log_end_msg 0
          fi
      }
      
      force_reload() {
          stop
          start
      
      }
      
      case “$1” in
          start)
              start
              ;;
          stop)
              stop
              ;;
          force-reload)
              force_reload
              ;;
          restart)
              stop
              start
              ;;
      
          *)
              echo “$Usage: $prog {start|stop|force-reload|restart}”
              exit 2
      esac
      

      However this doesn’t quite work. It gives me this output:

      Starting Mullvad VPN daemon: mullvad-daemon[mullvad_daemon::version][INFO] Starting mullvad-daemon – 2023.3 2023-04-05
      [mullvad_daemon][INFO] Logging to /var/log/mullvad-vpn
      [mullvad_daemon::rpc_uniqueness_check][DEBUG] Failed to locate/connect to another daemon instance, assuming there isn’t one
      [mullvad_daemon][INFO] Management interface listening on /var/run/mullvad-vpn
      [mullvad_api::address_cache][DEBUG] Loading API addresses from /var/cache/mullvad-vpn/api-ip-address.txt
      [mullvad_api::address_cache][DEBUG] Using API address: 45.83.223.196:443
      [mullvad_api::availability][DEBUG] Suspending API requests
      [mullvad_daemon::settings][INFO] Loading settings from /etc/mullvad-vpn/settings.json
      [mullvad_daemon::version_check][DEBUG] Loading version check cache from /var/cache/mullvad-vpn/version-info.json
      [mullvad_daemon::version_check][WARN] Error: Unable to load cached version info
      Caused by: Failed to open app version cache file for reading
      Caused by: No such file or directory (os error 2)
      [mullvad_relay_selector][DEBUG] Reading relays from /var/cache/mullvad-vpn/relays.json
      [mullvad_relay_selector][DEBUG] Reading relays from /usr/bin/relays.json
      [mullvad_relay_selector][ERROR] Failed to load bundled relays: Failed to open relay cache file
      [mullvad_relay_selector][ERROR] Error: Unable to load cached relays
      Caused by: Failed to open relay cache file
      Caused by: No such file or directory (os error 2)
      [mullvad_relay_selector][INFO] Initialized with 0 cached relays from 1969-12-31 19:00:00.000
      [mullvad_api::availability][DEBUG] Pausing background API requests
      [mullvad_daemon::account_history][INFO] Opening account history file in /etc/mullvad-vpn/account-history.json
      [mullvad_daemon::target_state][DEBUG] No cached target state to load
      [talpid_core::firewall][INFO] Resetting firewall policy
      [talpid_core::firewall::imp][DEBUG] Removing table and chain from netfilter
      [mullvad_daemon][ERROR] Error: Unable to initialize daemon
      Caused by: Unable to initialize split tunneling
      Caused by: Unable to create cgroup for excluded processes
      Caused by: No such file or directory (os error 2)
      [talpid_core::dns][INFO] Resetting DNS
      [mullvad_daemon][DEBUG] Process exiting with code 1
      [talpid_core::tunnel_state_machine][DEBUG] Exiting tunnel state machine loop
      [mullvad_daemon::management_interface][INFO] Management interface shut down
       failed!
      

      I’m not really sure how to troubleshoot this or where to go from here. In the AntiX “Package Intaller” it says that Mullvad VPN installs the SysV scripts. Maybe someone has a working script they can give me?

      • This topic was modified 1 month ago by antixcat.
      • This topic was modified 1 month ago by antixcat.
      • This topic was modified 1 month ago by antixcat. Reason: formatting fix
      #104180
      Member
      Xunzi_23
        Helpful
        Up
        1
        ::

        [mullvad_daemon::settings][INFO] Loading settings from /etc/mullvad-vpn/settings.json
        [mullvad_daemon::version_check][DEBUG] Loading version check cache from /var/cache/mullvad-vpn/version-info.json
        [mullvad_daemon::version_check][WARN] Error: Unable to load cached version info
        Caused by: Failed to open app version cache file for reading

        Caused by: No such file or directory (os error 2)

        [mullvad_relay_selector][DEBUG] Reading relays from /var/cache/mullvad-vpn/relays.json
        [mullvad_relay_selector][DEBUG] Reading relays from /usr/bin/relays.json
        [mullvad_relay_selector][ERROR] Failed to load bundled relays: Failed to open relay cache file
        [mullvad_relay_selector][ERROR] Error: Unable to load cached relays
        Caused by: Failed to open relay cache file

        [mullvad_daemon][ERROR] Error: Unable to initialize daemon
        Caused by: Unable to initialize split tunneling
        Caused by: Unable to create cgroup for excluded processes
        Caused by: No such file or directory (os error 2)

        Caused by: No such file or directory (os error 2)

        Is the /var/ cache the software is looking for present. You may have to create it manualy.
        same goes for /etc/mullvad-vpn/

        If files are present you probably have a permissions issue.

        Not uncommon, happens to me a lot with Brother and other printers where a spool directory is missing.
        Not created by the installer.

        #104225
        Member
        antixcat
          Helpful
          Up
          0
          ::

          I tried creating empty files (I’m not sure what would go in them) for the errors. Particularly these two files:
          /var/cache/mullvad-vpn/version-info.json
          /var/cache/mullvad-vpn/relays.json

          This solves the “Caused by: No such file or directory (os error 2)” error, but creates new ones:

          [mullvad_daemon::settings][INFO] Loading settings from /etc/mullvad-vpn/settings.json
          [mullvad_daemon::version_check][DEBUG] Loading version check cache from /var/cache/mullvad-vpn/version-info.json
          [mullvad_daemon::version_check][WARN] Error: Unable to load cached version info
          Caused by: Failure in deserialization of the version info
          Caused by: EOF while parsing a value at line 1 column 0
          …
          [mullvad_relay_selector][DEBUG] Reading relays from /usr/bin/relays.json
          [mullvad_relay_selector][ERROR] Failed to load bundled relays: Failed to open relay cache file
          [mullvad_relay_selector][ERROR] Error: Unable to load cached relays
          

          Maybe I can copy version-info.json and relays.json from a computer with a working version of mullvad…

          I also tried running this with and without the ufw firewall with the commands “sudo ufw enable” and “sudo ufw disable” with no effect.

          At least I was able to get AirVPN with the OpenVPN service to start correctly, so if I can’t get mullvad working I may use that instead.

          • This reply was modified 1 month ago by antixcat. Reason: formatting
          #104230
          Member
          Xunzi_23
            Helpful
            Up
            1
            ::

            Hi antixcat
            Before further experiments

            Please now try a reinstall leaving the folders present.
            That has helped me on numerous occasions with various non debian software.
            What I hope is the installer can/will then write the needed configs.

            [mullvad_daemon::settings][INFO] Loading settings from /etc/mullvad-vpn/settings.json
            [mullvad_daemon::version_check][DEBUG] Loading version check cache from /var/cache/mullvad-vpn/version-info.json
            [mullvad_daemon::version_check][WARN] Error: Unable to load cached version info
            Caused by: Failure in deserialization of the version info
            Caused by: EOF while parsing a value at line 1 column 0 End of file at line 1, looks like empty file

            [mullvad_relay_selector][DEBUG] Reading relays from /usr/bin/relays.json
            [mullvad_relay_selector][ERROR] Failed to load bundled relays: Failed to open relay cache file
            [mullvad_relay_selector][ERROR] Error: Unable to load cached relays

            Is /usr/bin/relays.json present, if not please look in synaptic to see where everything is installed. It should show all locations.
            Maybe the json file is placed in, for example /usr/local/bin something not unknown due distro differences.

            #104238
            Member
            antixcat
              Helpful
              Up
              0
              ::

              I tried reinstalling Mullvad. It actually deleted the files I created!

              I was able to find in the Synaptic Package Manager that a relays.json file was created at “/opt/Mullvad VPN/resources/”. There are also two executables in “/opt/Mullvad VPN/” called “mullvad-gui” and “mullvad-vpn”, but these are not daemons, which is still located at “/usr/bin/mullvad-daemon”

              So, I tried copying the relays.json from “/opt/Mullvad VPN/resources/” to “/usr/bin/” and “/var/cache/mullvad-vpn/”, which come from the error messages.

              By doing this, I have quieted some of the errors, but still fail in the end:

              Starting Mullvad VPN daemon: mullvad-daemon[mullvad_daemon::version][INFO] Starting mullvad-daemon – 2023.3 2023-04-05
              [mullvad_daemon][INFO] Logging to /var/log/mullvad-vpn
              [mullvad_daemon::rpc_uniqueness_check][DEBUG] Failed to locate/connect to another daemon instance, assuming there isn’t one
              [mullvad_daemon][INFO] Management interface listening on /var/run/mullvad-vpn
              [mullvad_api::address_cache][DEBUG] Loading API addresses from /var/cache/mullvad-vpn/api-ip-address.txt
              [mullvad_api::address_cache][DEBUG] Using API address: 45.83.223.196:443
              [mullvad_api::availability][DEBUG] Suspending API requests
              [mullvad_daemon::settings][INFO] Loading settings from /etc/mullvad-vpn/settings.json
              [mullvad_daemon::version_check][DEBUG] Loading version check cache from /var/cache/mullvad-vpn/version-info.json
              [mullvad_daemon::version_check][WARN] Error: Unable to load cached version info
              Caused by: Failure in deserialization of the version info
              Caused by: EOF while parsing a value at line 1 column 0
              [mullvad_relay_selector][DEBUG] Reading relays from /var/cache/mullvad-vpn/relays.json
              [mullvad_relay_selector][DEBUG] Reading relays from /usr/bin/relays.json
              [mullvad_relay_selector][INFO] Initialized with 700 cached relays from 2023-04-06 18:02:16.700
              [mullvad_api::availability][DEBUG] Pausing background API requests
              [mullvad_daemon::account_history][INFO] Opening account history file in /etc/mullvad-vpn/account-history.json
              [mullvad_daemon::target_state][DEBUG] No cached target state to load
              [talpid_core::firewall][INFO] Resetting firewall policy
              [talpid_core::firewall::imp][DEBUG] Removing table and chain from netfilter
              [mullvad_daemon][ERROR] Error: Unable to initialize daemon
              Caused by: Unable to initialize split tunneling
              Caused by: Unable to create cgroup for excluded processes
              Caused by: No such file or directory (os error 2)
              [mullvad_daemon][DEBUG] Process exiting with code 1
              [mullvad_daemon::management_interface][INFO]  failed!
              

              To be clear, the file “/var/cache/mullvad-vpn/version-info.json” exists, is empty, and seems to be created automatically by trying to start mullvad-daemon. This is where the only warning is coming from this time. Also, according to Synaptic, there is no “version-info.json” file created anywhere at install.

              • This reply was modified 1 month ago by antixcat.
              • This reply was modified 1 month ago by antixcat.
              #104266
              Member
              Xunzi_23
                Helpful
                Up
                1
                ::

                Looks like you are getting nearer.

                [mullvad_daemon::account_history][INFO] Opening account history file in /etc/mullvad-vpn/account-history.json

                dos the account history file exist

                https://wiki.archlinux.org/title/Mullvad may be of help.

                #104284
                Member
                antixcat
                  Helpful
                  Up
                  0
                  ::

                  I ended up stumbling upon an alternative solution that allows me to bypass starting the mullvad-daemon. Doing it this way is quicker and more efficient so I’ll just stick with this. Maybe this will be helpful to some others, so I’ll post a how-to here.

                  You can use OpenVPN (which comes installed with AntiX) with a configuration file provided by the VPN service. It’s very easy to start:

                  sudo openvpn /file/path/your-config-file.ovpn

                  To start “in the background” (redirects terminal output to an output file):

                  sudo openvpn /file/path/your-config-file.ovpn > /file/path/output.txt 2>&1 &

                  To stop the service:

                  sudo pkill -TERM -f openvpn

                  To check if a VPN service is running:

                  ip route | grep '^0.0.0.0' > /dev/null && echo "VPN Connected" || echo "VPN Not Connected"

                  I added this to my .conkyrc (updates every 5 seconds) so I’m always aware if a VPN is connected:

                  ${execi 5 ip route | grep '^0.0.0.0' > /dev/null && echo "VPN Connected" || echo "VPN Not Connected"}

                  • This reply was modified 1 month ago by antixcat.
                  #104286
                  Moderator
                  Brian Masinick
                    Helpful
                    Up
                    0
                    ::

                    @antixcat While I do not have any specific requirements for this service at the present time, I always appreciate reading and seeing helpful suggestions from any of our members and contributors, and I thank you for your persistence in figuring out a handy, useful way to efficiently use the openvpn service that is available with antiX. I will say that prior to retirement, I did indeed occasionally use various VPN services from time to time; who knows if and when I’ll have a need once again, but whether I need it or not, this is still potentially helpful to others and I appreciate your clear, easy to understand and use suggestions!

                    --
                    Brian Masinick

                    #104300
                    Member
                    antixcat
                      Helpful
                      Up
                      0
                      ::

                      Hello Brian,

                      I use a VPN service because I am frequently on a public network and like to hide my activity while on it, otherwise I wouldn’t bother. Hopefully this may help others. For me, this marks the point where I have a fully functional (and efficient) OS for my day-to-day needs. Now if only I could get suspend and hibernate to work, it would be perfect!

                      #104304
                      Moderator
                      Brian Masinick
                        Helpful
                        Up
                        0
                        ::

                        @antixcat – when you say you want to get suspend and hibernate working, are you referring to suspending and/or hibernating antiX (or another Linux distribution?

                        One recommendation I found is:

                        “If RAM > 1 GB – swap size should be at least equal to the square root of the RAM size and at most double the size of RAM. If hibernation is used, then swap size should be equal to size of RAM plus the square root of the RAM size.”

                        My system rarely, if ever actually SWAPS, in fact, most of the time the entire usable workspace is able to execute in my physical memory space.
                        I have, however, read in the past about using swap when you want to either suspend or hibernate. If you DO NOT want to do a bunch of complex math, and you have sufficient space, create a SWAP file OR a swap partition that is AT LEAST double the size of the memory in your system and you’ll probably have success, assuming that all of the other requirements are in place. The few times that I’ve wanted to suspend or hibernate, I’ve done this and it’s worked great.

                        Hope this helps.

                        For additional reading:
                        https://wiki.debian.org/Swap
                        https://forums.debian.net/viewtopic.php?t=152498
                        https://linuxreviews.org/HOWTO_choose_the_right_swap_partition_size

                        --
                        Brian Masinick

                        #104306
                        Member
                        antixcat
                          Helpful
                          Up
                          0
                          ::

                          I am using antiX only. I have already set up my swap partition to about 32GB while installing antiX. (I have 16gb of RAM, following the same advice you gave me from a different post on this forum). When suspending, my screen blanks for a moment, but comes right back. When hibernating, the system just reboots instead. I know that my swap partition is functioning, because when backing up (or when moving large files with external drives) sometimes the swap is used. I’ve been able to get my screen to lock successfully, but otherwise my PC just runs all the time unless I turn it off. I’ve attach an image of GParted to show how my drive is set up.

                          Attachments:
                          #104327
                          Moderator
                          Brian Masinick
                            Helpful
                            Up
                            0
                            ::

                            @antixcat – that’s pretty good use of your system and your partitions. Unless you are multi-booting MANY different systems, I do not see the need for the /boot/efi partition to be that large. Even mine is arguably larger than it needs to be, and I boot 5-7 systems at times. The utilization of mine is 22% /boot/efi, so you can see that I may have possibilities for more effective selection of partitions and sizes. Suppose your /boot/efi was
                            2048*64 = 131072; maybe that would be enough for /boot/efi, and you could increase the size of your swap accordingly, and that would undoubtedly help either suspend, hibernate or both. As it currently stands, your swap is NOT QUITE twice memory size, so even a couple more GiB might improve the situation.

                            Suppose you’re somehow able to redistribute this and you could make a 48 GiB swap? I think that *may* improve the situation; if NOT, it’d be worth investigating in more depth to understand why it’s not performing correctly. 48 may not be *mandatory* but it would give you hibernation and suspend “head room”, and that could be just what it’s looking for and why it’s not working as you expect.

                            See if I’m right or wrong about this if you are able to resize anything or reinstall anything.

                            --
                            Brian Masinick

                            #104347
                            Member
                            antixcat
                              Helpful
                              Up
                              0
                              ::

                              I’m getting really unpredictable behavior. First I tried increasing the swap to 34GiB and suspend now works, but only sometimes. Sometimes it only blanks the screen for a few seconds like it did before. Sometimes it works, but when it resumes it blanks the screen a few more times a few seconds apart, or if I suspend with xlock, xlock takes 10 seconds to trigger on resume after the screen is already showing the desktop, but only sometimes.

                              At 34GiB I tried hibernating and everything froze. When I forced a reboot, it was printing extremely small text and would freeze with garbage characters on the screen. Luckily it just booted normally after a few reboots.

                              So then I tried increasing my swap to 48GiB, and suspend is having the same issue, but now hibernate is simply rebooting the system like it did before. What could be causing this if it’s not the swap size?

                              • This reply was modified 1 month ago by antixcat.
                              #104502
                              Member
                              antixcat
                                Helpful
                                Up
                                0
                                ::

                                I was able to find out the suspend/hibernate issues I’m having are related to my hardware (pre-T2 chip macbook). What I found *kind of* works:

                                https://joshtronic.com/2017/03/13/getting-suspend-in-linux-working-on-a-macbook-pro/

                                Luckily this guide does not use SystemD, as so many guides for linux seem to do. Following this guide I added the following lines to “/etc/rc.local”:

                                echo XHC1 > /proc/acpi/wakeup
                                echo LID0 > /proc/acpi/wakeup
                                exit 0

                                It now *kind of* works, because it stays suspended, but when it wakes all of my connections are killed (and cannot be fixed via Connman UI until I reboot) and in general I get slow behavior, such as Conky freezing completely, or only updating every 5-10 seconds. In particular, when I include the “echo LID0 > /proc/acpi/wakeup” line, it makes it so that I have to use the power button to wake from suspend, but then any keys I press before then are executed after the wake. For example, if I have a text editor open, then suspend, then type a sentence while suspended, then hit the power button to wake, the sentence will be typed after the computer wakes, often after a delay.

                                #104567
                                Member
                                blackcat7
                                  Helpful
                                  Up
                                  0
                                  ::

                                  Hi antiXcat, I’m also new to using antiX.

                                  Thank you for these instructions, they are helpful, but I still haven’t been able to get it to work.

                                  I tried running the command sudo openvpn /file/path/your-config-file.ovpn on a .conf file I downloaded from Mullvad through my account but it doesn’t connect for some reason, I may need to adjust the settings I used to generate the config file.

                                  Does the extension need to be .ovpn? If so, where do you download that from Mullvad? The files I got from Mullvad did not include a .ovpn file.

                                  I would prefer to get the Mullvad program working, as that would be easier to use. I installed it with the package manager, but when I try to run it, it just shows the message “Connecting to Mullvad System Service…” and doesn’t do anything.

                                  If you can give any further advice or guidance on how you got your VPN to work, I would greatly appreciate it.

                                Viewing 15 posts - 1 through 15 (of 16 total)
                                • You must be logged in to reply to this topic.