Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
/ vpn-checker Public archive

A python script to check the Linux routes configured as 'default'.

Notifications You must be signed in to change notification settings

jfsanchez91/vpn-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VPN Checker service.

How to install

  1. Clone this repository into your local system.
  2. Start a new python virtual environment:
    $: sudo apt install virtualenv
    $: virtualenv -p python3 vpn_checker
  3. Activate the new virtual environment:
    $: source vpn_checker/bin/activate
  4. Move into the repository source code.
  5. Install the python requirements for this project to work:
    (vpn_checker)$: pip install -r requirements.txt
  6. Now you can run the VPN Checker service.
    (vpn_checker)$: python main.py

Creating a Linux service daemon using Systemd

  1. Create a vpn_checker.service file into the /etc/systemd/system folder with the following content:

    [Unit]
    Description=VPN Checker Service
    After=network.target
    StartLimitIntervalSec=0
    
    [Service]
    Type=simple
    Restart=always
    RestartSec=1
    User=<TYPE YOUR USERNAME HERE>
    Environment="DISPLAY=:0.0"
    Environment="DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"
    ExecStart=$VIRTUALENV_PATH/bin/python $SOURCES_PATH/main.py
    
    [Install]
    WantedBy=multi-user.target

    NOTE: You need to change the values for the DISPLAY and DBUS_SESSION_BUS_ADDRESS environment variables. Normally if you execute echo $DISPLAY and echo $DBUS_SESSION_BUS_ADDRESS you will be able to get this values and replace them. Also you need to replace the VIRTUALENV_PATH value to match the correct python virtual environment directory path in your system and the SOURCES_PATH to match the repository sources directory path also in your system :).

  2. With the previous step in place, now we can enable this new service into the systemd environment:

    $: sudo systemctl enable vpn_checker.service
  3. And finally we can start the vpn_checker service:

    $: sudo systemctl start vpn_checker

NOTE: Now, every time you start your computer, systemd will automatically start the vpn_checker service. So, if you want to stop the service manually, then you need to run sudo systemctl stop vpn_checker.

About

A python script to check the Linux routes configured as 'default'.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages