bash script works in CLI but fails in systemctl service

24 views Asked by At

I'm no linux expert but I'm trying to learn.

I wrote a simple bash script to run my vpn connection automatically upon start up.

#!/bin/bash
cyberghostvpn --country-code PL --connect

I works fine when I run it through my CLI

sudo ./cyberghostvpn-launcher.sh 

I tried to wrap it in a service like this :

[Unit]
Description=VPN start
After=network-online.target

[Service]
ExecStart=/home/xxxx/Documents/cyberghostvpn-launcher.sh

[Install]
WantedBy=multi-user.target

I ran the enable command (OK)

$ sudo systemctl enable vpn-launch.service

But I get an error when trying to start the service :

julien@uproxy:~$ sudo systemctl status vpn-launch.service                                                                            
× vpn-launch.service - VPN start
     Loaded: loaded (/etc/systemd/system/vpn-launch.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2024-03-31 17:00:12 UTC; 16s ago
    Process: 95180 ExecStart=/home/julien/Documents/cyberghostvpn-launcher.sh (code=exited, status=1/FAILURE)
   Main PID: 95180 (code=exited, status=1/FAILURE)
        CPU: 173ms

Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "cyberghostvpn.py", line 6, in <module>
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "configs/base.py", line 3, in <module>
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]:   File "configs/base.py", line 12, in BaseConfiguration
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]: TypeError: can only concatenate str (not "NoneType") to str
Mar 31 17:00:13 uproxy cyberghostvpn-launcher.sh[95182]: [95182] Failed to execute script 'cyberghostvpn' due to unhandled exception!
Mar 31 17:00:12 uproxy systemd[1]: vpn-launch.service: Failed with result 'exit-code'.

I can't understand what's wrong. Any ideas folks?

thanks for your lightings

0

There are 0 answers