LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-01-2023, 01:06 PM   #1
catfoo
LQ Newbie
 
Registered: Jan 2022
Location: Lower left part of the US.
Posts: 4

Rep: Reputation: 0
calling startup vpn script from systemd - environment issues?


HW - Raspberry Pi Model 3B+
SW - Debian 11.8, OS bullseye, headless, Wireguard v1.0.20210223-1

Goal is to get a connection to PIA VPN.

After spending a week trying unsuccessfully to get openvpn/wireguard to connect using many how-to's, I ran across this github project. On a command line, their TLDR solution just worked. I was thrilled. Thought it would be trivial to make it start at boot. I was wrong. Tried modifying rc.local - several hours, no joy. Also, realized it'd probably be better to use a systemd service for reconnecting if lost.

Here is the (working) command line that runs the script:

Code:
sudo VPN_PROTOCOL=wireguard DISABLE_IPV6=yes DIP_TOKEN=no AUTOCONNECT=true PIA_PF=false PIA_DNS=true PIA_USER=pxxxxxxx PIA_PASS=xxxxxx ./run_setup.sh
Great. Then, tried systemd solution near the end of this post (you'll see I posted the same issue there - but the thread was from a year ago - not sure folks there are still paying attention). Here is the systemd service I copied/created, piavpn.system.

Code:
        [Unit]
        Description=Runs PIA over wiregaurd
        After=network-online.target

        [Service]
        Environment='VPN_PROTOCOL=wireguard'
        Environment='DISABLE_IPV6=yes'
        Environment='DIP_TOKEN=no'
        Environment='AUTOCONNECT=true'
        Environment='PIA_PF=false'
        Environment='PIA_DNS=true'
        Environment='PIA_USER=pxxxxxxx'
        Environment='PIA_PASS=xxxxxxxxxx'
        WorkingDirectory=/usr/local/bin/manual-connections
        ExecStart=/bin/bash /usr/local/bin/manual-connections/run_setup.sh
        Restart=no
        Type=simple
        User=root

        [Install]
        WantedBy=multi-user.target
Executed:
sudo systemctl daemon-reload
sudo systemctl enable piavpn.service

Here is the output from systemctl status piavpn.service.

Code:
        systemctl status piavpn.service
        ● piavpn.service - Runs PIA over wiregaurd
             Loaded: loaded (/etc/systemd/system/piavpn.service; enabled; vendor preset: enabled)
             Active: activating (start) since Thu 2023-11-30 18:48:35 PST; 36s ago
           Main PID: 829 (bash)
              Tasks: 1 (limit: 1595)
                CPU: 35.122s
             CGroup: /system.slice/piavpn.service
                     └─829 /bin/bash /usr/local/bin/manual-connections/run_setup.sh

        Nov 30 18:49:07 pi3 bash[829]: PIA password:
        Nov 30 18:49:07 pi3 bash[829]: You must provide input.
        Nov 30 18:49:07 pi3 bash[829]: PIA password:
        Nov 30 18:49:07 pi3 bash[829]: You must provide input.
        Nov 30 18:49:07 pi3 bash[829]: PIA password:
        Nov 30 18:49:07 pi3 bash[829]: You must provide input.
        Nov 30 18:49:07 pi3 bash[829]: PIA password:
        Nov 30 18:49:07 pi3 bash[829]: You must provide input.
        Nov 30 18:49:07 pi3 bash[829]: PIA password:
        Nov 30 18:49:07 pi3 bash[829]: You must provide input.
Tried rebooting, reformatting the pass string, debugging systemd, all rabbit holes. Note this issue shouldn't be specifically related to the specific goal I'm trying to achieve. I assume this would occur with any script requiring environment variables and some sort of conditional interface.

I've run out of patience/ideas. Any help would be appreciated!
 
Old 12-01-2023, 01:50 PM   #2
catfoo
LQ Newbie
 
Registered: Jan 2022
Location: Lower left part of the US.
Posts: 4

Original Poster
Rep: Reputation: 0
Never mind. Issue is how characters/strings are processed differently via command line versus systemd. Specifically, escape sequences. Will try to figure that out on my own. If I hadn't checked dmesg I would have never have found out what was going on.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
init.d script to systemd with systemd-sysv-generator tankzeu Linux - Newbie 1 09-17-2018 04:41 AM
Can't access full journalctl from script via systemd service even though user is in systemd-journal group iwtbf Linux - Newbie 0 02-19-2016 02:44 PM
vfork - suspends the calling process or the calling thread? zmau Linux - Software 3 04-21-2015 02:38 PM
calling another script , preserve environment variables? Umanga Linux - Software 1 11-20-2009 03:32 AM
odd recursion: calling "by hand" vs calling by cronscript... prx Programming 4 02-12-2005 04:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration