Re: [Openvpn-users] automatically restart openvpn

2017-06-04 Thread David Sommerseth
On 04/06/17 10:26, Xen wrote:
> David Sommerseth schreef op 31-05-2017 18:28:
> 
>> As you use systemctl, that implies systemd.  Then that hack is truly
>> ugly compared to what systemd provides.
> 
> You know David,
> 
> I just tried to use a simple Path file for something and then a simple
> Unit file (Service file) with systemd to send an email when that happened.
> 
> Fine, I didn't use any built-in email facility.
> 
> I used:
> 
> /bin/sh -c 'echo | /usr/bin/mail -s subject root'
> 
> And that simply didn't work.
> The command worked from the shell, and the command works from a cron job.
> But the command doesn't work from systemd.

That was not what I was commenting on.  I commented on the ugly "restart
failed service" hack you put into cron.

> It's systemd that's really ugly

Any tool you don't learn to use properly may appear ugly.  It doesn't
mean it is ugly.  It just means you're doing it wrong.  In those cases
you need to debug what goes wrong and fix that.  Not band-aid it with
ugly hacks.

This also isn't a systemd mailing list, so if you want to rant about
systemd not capable of sending an email, you need to target the proper
audience.  Here we primarily discuss OpenVPN and occasionally systemd if
it intersects with OpenVPN.  But not "systemd doesn't send mails".


--
kind regards,

David Sommerseth



signature.asc
Description: OpenPGP digital signature
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-06-04 Thread Xen

David Sommerseth schreef op 31-05-2017 18:28:


As you use systemctl, that implies systemd.  Then that hack is truly
ugly compared to what systemd provides.


You know David,

I just tried to use a simple Path file for something and then a simple 
Unit file (Service file) with systemd to send an email when that 
happened.


Fine, I didn't use any built-in email facility.

I used:

/bin/sh -c 'echo | /usr/bin/mail -s subject root'

And that simply didn't work.
The command worked from the shell, and the command works from a cron 
job.

But the command doesn't work from systemd.

It's systemd that's really ugly.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Xen

Samuli Seppänen schreef op 31-05-2017 19:10:


Hi,

A few months back I looked into exactly this issue. Back then there was
no easy way to make systemd send emails. That is why I still use monit
which has good notification capabilities:




Hi, yes, that sounds pretty awesome!!!

The SystemD thing that Debbie sent me involves making service files that 
then get referenced by other unit files and that get a parameter that 
you can use to customize the script or output of your program.


I have been polling stuff too and I think it is a good system but then I 
am usually not running as a daemon.


Monit sounds like a very good solution.

I'll have a look some time, thank you.


Monit works by polling service states periodically, so some delay is
always involved. Monit can, however, do whatever you want when a 
problem

is encountered and is not limited to just restarting the service.

Combining systemd instantaneous restarts with monit's notifications is 
a

pretty good system imho.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Samuli Seppänen
On 31/05/2017 19:50, Xen wrote:
> David Sommerseth schreef op 31-05-2017 18:28:
>> On 31/05/17 17:05, Xen wrote:
>>> Riccardo Paolo Bestetti schreef op 31-05-2017 16:01:
 It's not OpenVPN you should configure, but your Operating System.
 You should refer to its documentation or its relevant mailing list.
>>>
>>> You can also do:
>>>
>>> # crontab -l | { cat; echo "*/15 * * * * /bin/sh -c 'ifconfig | grep
>>> tun0 > /dev/null || systemctl restart openvn'"; } | crontab
>>>
>>> This will check very 15 minutes whether tun0 is up and if not will use
>>> systemctl to restart openvpn service.
>>>
>>> Not sure what runs on Raspbian.
>>
>> As you use systemctl, that implies systemd.  Then that hack is truly
>> ugly compared to what systemd provides.
> 
> So how can you get systemd to send you emails?
> 
> Can you let it run a script on restart?
> 

Hi,

A few months back I looked into exactly this issue. Back then there was
no easy way to make systemd send emails. That is why I still use monit
which has good notification capabilities:



Monit works by polling service states periodically, so some delay is
always involved. Monit can, however, do whatever you want when a problem
is encountered and is not limited to just restarting the service.

Combining systemd instantaneous restarts with monit's notifications is a
pretty good system imho.

-- 
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Xen

David Sommerseth schreef op 31-05-2017 18:28:

On 31/05/17 17:05, Xen wrote:

Riccardo Paolo Bestetti schreef op 31-05-2017 16:01:

It's not OpenVPN you should configure, but your Operating System.
You should refer to its documentation or its relevant mailing list.


You can also do:

# crontab -l | { cat; echo "*/15 * * * * /bin/sh -c 'ifconfig | grep
tun0 > /dev/null || systemctl restart openvn'"; } | crontab

This will check very 15 minutes whether tun0 is up and if not will use
systemctl to restart openvpn service.

Not sure what runs on Raspbian.


As you use systemctl, that implies systemd.  Then that hack is truly
ugly compared to what systemd provides.


So how can you get systemd to send you emails?

Can you let it run a script on restart?

Regards.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread David Sommerseth
On 31/05/17 17:05, Xen wrote:
> Riccardo Paolo Bestetti schreef op 31-05-2017 16:01:
>> It's not OpenVPN you should configure, but your Operating System.
>> You should refer to its documentation or its relevant mailing list.
> 
> You can also do:
> 
> # crontab -l | { cat; echo "*/15 * * * * /bin/sh -c 'ifconfig | grep
> tun0 > /dev/null || systemctl restart openvn'"; } | crontab
> 
> This will check very 15 minutes whether tun0 is up and if not will use
> systemctl to restart openvpn service.
> 
> Not sure what runs on Raspbian.

As you use systemctl, that implies systemd.  Then that hack is truly
ugly compared to what systemd provides.

Copy the openvpn unit file you want to use to /etc/systemd/system ...
and add this line to that file in the [Service] section:

Restart=on-failure

To enable OpenVPN during boot:  systemctl enable $UNIT_NAME


--
kind regards,

David Sommerseth



signature.asc
Description: OpenPGP digital signature
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Xen

Riccardo Paolo Bestetti schreef op 31-05-2017 16:01:

It's not OpenVPN you should configure, but your Operating System.
You should refer to its documentation or its relevant mailing list.


You can also do:

# crontab -l | { cat; echo "*/15 * * * * /bin/sh -c 'ifconfig | grep 
tun0 > /dev/null || systemctl restart openvn'"; } | crontab


This will check very 15 minutes whether tun0 is up and if not will use 
systemctl to restart openvpn service.


Not sure what runs on Raspbian.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Riccardo Paolo Bestetti
It's not OpenVPN you should configure, but your Operating System.
You should refer to its documentation or its relevant mailing list.

Best regards,
Riccardo Paolo Bestetti

-Original Message-
From: Jannis Ohms [mailto:jannis.oh...@ostfalia.de] 
Sent: 31 May 2017 15:43
To: openvpn-users@lists.sourceforge.net
Subject: [Openvpn-users] automatically restart openvpn

hi

how can i configure openvpn to restart after  the service crashes ?
iam running on raspbian

--
Check out the vibrant tech community on one of the world's most engaging tech 
sites, Slashdot.org! http://sdm.link/slashdot 
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


Re: [Openvpn-users] automatically restart openvpn

2017-05-31 Thread Joe Patterson
If openvpn crashing is a regular problem, that's very interesting in its
own right, and I'm sure we'd like to know more, and there's nothing much
you can do *within* openvpn to respond when openvpn crashes.

If openvpn is exiting normally and you don't want it to, my guess is that
you could look to the "connect-retry-max" and "auth-retry" config options,
depending on why it's exiting.

And in either case you *could* if you wanted to, kluge your way around it
by wrapping openvpn in a shell script that does something like "while true;
do openvpn..." (though, if you do that, make sure you don't have the
'daemon' option in your config)

-Joe

On Wed, May 31, 2017 at 9:48 AM Jannis Ohms 
wrote:

> hi
>
> how can i configure openvpn to restart after  the service crashes ?
> iam running on raspbian
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Openvpn-users mailing list
> Openvpn-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-users
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users


[Openvpn-users] automatically restart openvpn

2017-05-31 Thread Jannis Ohms

hi

how can i configure openvpn to restart after  the service crashes ?
iam running on raspbian

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users