Re: [systemd-devel] OnFailure=

2018-03-08 Thread Jakob Schürz
Am 2018-03-08 um 07:03 schrieb Andrei Borzenkov:
> 08.03.2018 02:37, Jakob Schürz пишет:

[...]

> 
> This is apparently wrong, because service briefly goes via "failed"
> state every time it fails. It is true that if Restart= is set it
> immediately follows by "activating" state again, but OnFailure actions
> are still taken.
> 
> So from end-user perspective unit indeed remains "failed" only when
> limits are reached, but internally it does transition via "failed" state
> every time.
> 
> 
>>
>> But in this testcase, the unit listet in OnFailure is called every time,
>> the unit failes, restarts again fails again, and after 5 times
>> (=StartLimitBurst), the unit falls into failed state... Here should be
>> the only one time, where "OnFailure=" is hit...
>>
>> My systemd-Version is 237-3 from debian.
>>
>> Should i file a Bug in bugs.freedesktop.org?
>>
> 
> 
> You should create issue on github, this this where primary bug tracker
> is today:
> 
> https://github.com/systemd/systemd/
> 

Thanks. So i filed a bug there;

https://github.com/systemd/systemd/issues/8398

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] OnFailure=

2018-03-07 Thread Jakob Schürz
Hi there!

I build a test-unit

# cat test@.service
[Unit]
Description=Testservice notification
OnFailure=notification-telegram@%n.service

[Service]
Type=simple
Restart=on-failure
#RestartSec=2
ExecStart=/bin/%i
SyslogIdentifier=test@%i.service
StartLimitBurst=5
StartLimitInterval=10


And the notification-Unit notification-telegram@%n.service

# cat notification-telegram@.service
[Unit]
Description=Send failure-notification about %i to telegram

[Service]
User=jakob
ExecStart=/bin/bash -c "/usr/local/bin/ntfy -b telegram send
\"FAILED\n$(systemctl status %i)\""

When i start the Test-Unit with systemctl start test@false i get 5
Messages in telegram...

The log is:
Mär 08 00:31:53 aldebaran systemd[1]: Started Testservice notification.
Mär 08 00:31:53 aldebaran systemd[1]: test@false.service: Main process
exited, code=exited, status=1/FAILURE
Mär 08 00:31:53 aldebaran systemd[1]: test@false.service: Failed with
result 'exit-code'.
Mär 08 00:31:53 aldebaran systemd[1]: test@false.service: Triggering
OnFailure= dependencies.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Service
hold-off time over, scheduling restart.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Scheduled
restart job, restart counter is at 1.
Mär 08 00:31:54 aldebaran systemd[1]: Stopped Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: Started Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Main process
exited, code=exited, status=1/FAILURE
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Failed with
result 'exit-code'.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Triggering
OnFailure= dependencies.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Service
hold-off time over, scheduling restart.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Scheduled
restart job, restart counter is at 2.
Mär 08 00:31:54 aldebaran systemd[1]: Stopped Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: Started Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Main process
exited, code=exited, status=1/FAILURE
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Failed with
result 'exit-code'.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Triggering
OnFailure= dependencies.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Service
hold-off time over, scheduling restart.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Scheduled
restart job, restart counter is at 3.
Mär 08 00:31:54 aldebaran systemd[1]: Stopped Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: Started Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Main process
exited, code=exited, status=1/FAILURE
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Failed with
result 'exit-code'.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Triggering
OnFailure= dependencies.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Service
hold-off time over, scheduling restart.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Scheduled
restart job, restart counter is at 4.
Mär 08 00:31:54 aldebaran systemd[1]: Stopped Testservice notification.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Start request
repeated too quickly.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Failed with
result 'exit-code'.
Mär 08 00:31:54 aldebaran systemd[1]: Failed to start Testservice
notification.
Mär 08 00:31:54 aldebaran systemd[1]: test@false.service: Triggering
OnFailure= dependencies.


You see, the Unit from OnFailure= is called 5 times, not at the "Failed
to start Testservice notification"-time.

The man-page says:

OnFailure=
   A space-separated list of one or more units that are
activated when this unit enters the "failed" state. A service unit using
Restart= enters the failed state only after the
   start limits are reached.


But in this testcase, the unit listet in OnFailure is called every time,
the unit failes, restarts again fails again, and after 5 times
(=StartLimitBurst), the unit falls into failed state... Here should be
the only one time, where "OnFailure=" is hit...

My systemd-Version is 237-3 from debian.

Should i file a Bug in bugs.freedesktop.org?

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] start user-service only with UID greater than 1000

2017-07-25 Thread Jakob Schürz
Am 2017-05-09 um 20:35 schrieb Lennart Poettering:
> On Tue, 09.05.17 17:06, Jakob Schürz (wertsto...@nurfuerspam.de) wrote:
> 
>> Hi There!
>>
>> I have two services running in systemd --user, which should only be
>> startet for login-users.
>> If i put the service-file by a deb-package in /usr/lib/systemd/user, the
>> service will also be started for Debian-exim, Debian-gdm and other users
>> with a UID below 1000. And this is not "good"...
> 
> These users should not have a PAM session normally, and hence no
> logind session either, and hence no systemd --user instance
> either. There's something really strange if you actually do get PAM
> sessions for these... Any idea why you get them?

I have no idea, why this users get a PAM-Session.
Now i can see there is also a systemd --user process for
debian-security-support:


Jul 25 23:54:49 aldebaran systemd[1]: Starting User Manager for UID 137...
Jul 25 23:54:49 aldebaran systemd[6366]: pam_unix(systemd-user:session):
session opened for user debian-security-support by (uid=0)
Jul 25 23:54:49 aldebaran systemd[6366]: Listening on Sound System.
Jul 25 23:54:49 aldebaran systemd[6366]: Listening on GnuPG network
certificate management daemon.
Jul 25 23:54:49 aldebaran systemd[6366]: Started mkbackup-userdir.path.
Jul 25 23:54:49 aldebaran systemd[6366]: Listening on GnuPG
cryptographic agent (ssh-agent emulation).
Jul 25 23:54:49 aldebaran systemd[6366]: Listening on GnuPG
cryptographic agent and passphrase cache (restricted).
Jul 25 23:54:49 aldebaran systemd[6366]: Listening on GnuPG
cryptographic agent (access for web browsers).
[...]

I don't know, why this session ist startet for the user with UID 137

I get this session every time on "dpkg-reconfigure debian-security-support"

Jakob

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd-networkd different static ip and dhcp in different networks

2017-06-21 Thread Jakob Schürz
Hi!

I'm fiddeling around with network, to find out, how it works. I know,
it's not made for use in Laptops moving in different networks.

But there is a solution with wpa_supplicant to connect to different
WLANs. I also found a Solution when i connect to my mobile phone, using
usb-thetering for the network-connection. This also works.

My question is - and i googled the half last night - how to configure
networkd to set dhcp on on wireless-network (especially internet-cafe,
wlan in trains...) and give a fixed ip-address at the home-wlan or the
wlan at work (different ip then the home-fixed-ip)

Is there also a possibility to set different fixed and dynamic
ip-addresses when connection to different wired lans? Also the home-lan
(static ip) and the lan at work (static) and the lan in university (dhcp).

Someone said, this is not possible. Is this correct?
If this is correct, i can't use systemd-networkd.

Are there plans to develop such a functionality? This would be great.

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Handling on network-connections and networkmanager

2017-06-17 Thread Jakob Schürz
Hi there!

I didn't found anything about the following problem:
There is network.target and network-online.target. In combination with
NetworkManager network-online.target get started, when
NetworkManager-wait-online.service exits successfull.

This is all ok, if i have a computer with permanent LAN/WLAN-connection.
But it doesn't fit the needs for laptops moved in different networks.

I need NetworkManager, because i use LAN, WLAN, Modem-Connections as
well as USB-Thetering. So a setup with networkd is not the best way in
my case.

I have some ftp-mountpoints, which i have configured with automount and
auto-unmounting after idle-time.
When the automount is activated on boot, a simple ls on this mountpoint
can block the whole system, when there is no network. So i bound the
automount-unit to network-online.target with
"BindsTo=network-online.target". This works fine. ls gives me an empty
directory, when no network-connection is active, and gives me back the
content of the mounted dir, when the network-connection is active.

BUT

When i stop the network-connection from the gnome-nm-applet, or when i'm
sitting in a train and there is no network-connection possible (in case
of a tunnel), the automount-unit should be stopped. But in normal
configuration this never will happen.

Do you have any suggestions, how to solve this problem?

I tried a solution:

i created a simple script, which checks the connection every minute. Is
there a connection, and is this connection working (realized with a ping
to a server in the internet), then network-online.target gets (re)started.
If there is no connection, or the connection is not working (think about
WLAN in a train in a tunnel, WLAN is working, but no connection to the
internet is possible), network-online.target gets stopped.

Also a simple script in NetworkManager/dispatcher.d/, wich starts
network-online.target, when a connection changes its state zu up, and
stop this target, when a connection changes to down.

All services, which should stop on closing the network-connection have
the dependency BindsTo=network-online.target

But i'm not sure, if this is a good solution to change the behaviour of
network-online.target. Should i create a own target? Or is there
another, better solution?

greets

jakob

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] start user-service only with UID greater than 1000

2017-05-10 Thread Jakob Schürz
Am 2017-05-09 um 18:19 schrieb Mantas Mikulėnas:
> That might be nice... but, how come your services register a logind
> session in the first place? That doesn't happen unless something
> deliberately calls pam_systemd – and the service startup process
> generally doesn't involve calling PAM in the first place. So something
> doesn't add up. (Are you using su?)

Good point!
The User-Session for Debian-exim maybe really come from a su in a
script... I rewrote this script, now the User-Session for Debian-gdm
seems not to be startet again.

But gdm... it starts this service, in case of starting a user-session
for systemd.
This seems to be another Problem, understanding the following answers
from the others in this thread...

Thanks for your suggestion.

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] start user-service only with UID greater than 1000

2017-05-09 Thread Jakob Schürz
Hi There!

I have two services running in systemd --user, which should only be
startet for login-users.
If i put the service-file by a deb-package in /usr/lib/systemd/user, the
service will also be started for Debian-exim, Debian-gdm and other users
with a UID below 1000. And this is not "good"...

Is there a mechanism in systemd --user to start services only for UIDs >
1000 (on Debian... other Distros may have the first login-user with
UID=500... how can i catch this?)
Or is it possible, to start Units only, if the user is in a special
unix-group? For example a group called "cups-fuse" or "backup", then the
service is startet in the users systemd only, if the user is in this group.

For now i have a

[Service]
ExecStartPre=/bin/sh -c '/usr/bin/test %U -ge 1000'

This produces a failed unit... That is not "beautiful" and leads to
wrong thoughts, watching the journal.

I need this services really only for logged in real users. Not
Debian-gdm or Debian-exim. And i need a solution, to activate it per
package-installation automatically for all the users who should be able
to login...

Maybe a Condition for a set usershell or another item, which identifies
a user as a login-user...

Any ideas or suggestions?

regards

jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd-user and xdg-user-dir

2017-01-10 Thread Jakob Schürz
Hi there!

I can not find anything valuable for my problem. So i come here...

in ~/.config/user-dirs.dirs are xdg-specific directories for desktop,
downloads and so on. You know this.

I rewrote a fuse-Filesystem for cups and want wo provide it with a
systemd-unit.

There should be a Directory on the desktop called "Printer". In english.
But my Desktop is called "Schreibtisch", because i'm from Austria... And
printers are called "Drucker" here.

if i create a new xdg-user-dir with

$ xdg-user-dirs-update --set PRINTERS $(xdg-user-dir DESKTOP)/Drucker

I get back:

$ xdg-user-dir PRINTERS
/home/jakob/Schreibtisch/Drucker

As expected and wanted.

Now i want to use this XDG_PRINTERS_DIR-Variable in systemd.mount and
systemd.path... in a systemd-user-session.

I made a separate unit to set the environment:

[Unit]
Description=Set environment

[Service]
Type=simple
ExecStart=/bin/sh -c '/bin/systemctl --user set-environment
XDG_PRINTERS_DIR=$(xdg-user-dir PRINTERS)'


But i want to activate this fuse-filesystem only if the directory
$XDG_PRINTERS_DIR exist. But systemd.path accepts no Variable for
"PathExists=..."

How can I manage this path-Unit?

Regards

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Condition and path (maybe timer too) restarts failed unit many times in a few seconds

2015-09-30 Thread Jakob Schürz

Hi there!

I have a strange behaviour on my Debian Jessie.

I found on the Archlinux-Forum a solution to send an email on a failed unit.

This works fine. BUT...

In my unit is "OnFailure=mailing.service" and 
"ConditionPathExists=!/run/btrfs-balance-systemd.lock" which is a 
lockfile, when it exists, the unit should fail.


How to say... it works, but i get 35 emails in 2 seconds, when this unit 
is started by a timer, and the lockfile exists at this time.


Is this a bug? Or how can i find more information about this behaviour?

My systemd-version is

# dpkg -l|grep systemd
ii  libpam-systemd:amd64 
215-17+deb8u2amd64system and service 
manager - PAM module
ii  libsystemd-dev:amd64 
215-17+deb8u2amd64systemd utility 
library - development files
ii  libsystemd0:amd64 
215-17+deb8u2amd64systemd utility library
ii  libsystemd0:i386 
215-17+deb8u2i386 systemd utility library
ii  python3-systemd 230-1+b1 
amd64Python 3 bindings for systemd
ii  systemd 
215-17+deb8u2amd64system and service manager
ii  systemd-sysv 
215-17+deb8u2amd64system and service 
manager - SysV links
ii  systemd-ui  3-2 
 amd64graphical frontend for systemd



greez

Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd-service for each user

2014-11-11 Thread Jakob Schürz

Hi!

I don't know, for which words I have to search to find a solution for my 
Problem.


On my server i created a mailserver.target, on which all relevant 
services for the mailserver depend. So i can [re]start and stop all 
services (exim4, cyrus, saslauthd, amavis...) only with


systemctl start|restart|stop mailserver.target

The thing is, i have users not each with ~/.fetchmailrc
So i've written a unit
/etc/systemd/system/fetchmail@.service

[Unit]
Description=fetchmail for User %i
BindsTo=mailserver.target
After=cyrus-imapd.service exim4.service
ConditionFileNotEmpty=/home/%i/.fetchmailrc

[Service]
Type=simple
User=%i
Environment=FETCHMAILUSER=%i
ExecStart=/usr/bin/fetchmail --nodetach
#PIDFile=/home/%i/.fetchmail.pid

[Install]
WantedBy=mailserver.target

But i don't know, how to start this unit for each user.
systemctl start mailserver should scan each user and start 
fetchmail@user1.service, fetchmail@user2.service...


Is this possible with systemd? Or should i create a shell-script to do 
the job?


greetings
Jakob
--
http://xundeenergie.at
http://verkehrsloesungen.wordpress.com/
http://cogitationum.wordpress.com/

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-service for each user

2014-11-11 Thread Jakob Schürz

Am 2014-11-11 um 20:35 schrieb Mantas Mikulėnas:

On Tue, Nov 11, 2014 at 7:52 PM, Jakob Schürz wertsto...@nurfuerspam.de wrote:

Hi!

I don't know, for which words I have to search to find a solution for my
Problem.

On my server i created a mailserver.target, on which all relevant services
for the mailserver depend. So i can [re]start and stop all services (exim4,
cyrus, saslauthd, amavis...) only with

systemctl start|restart|stop mailserver.target



But i don't know, how to start this unit for each user.
systemctl start mailserver should scan each user and start
fetchmail@user1.service, fetchmail@user2.service...

Is this possible with systemd? Or should i create a shell-script to do the
job?


I'm not sure I understand the point of having fetchmail download *from
localhost*... it looks like it should be completely independent from
cyrus/etc.


My configuration here is:
I have a Mailserver running on my laptop. So i can use different 
mailclients to see my emails. (It's an Imap-server). So fetchmail is 
running on my machine to fetch mails from all my mail-accounts. Also for 
the other Users on this machine.




Anyway, there is no command to scan each user. To start multiple
units at once, make the target want all of them individually:
mailserver.target.wants/fetchmail@user1.service, and so on.



I know that point. I have to do this individually. But i like a solution 
which detects and run this automatically...
Maybe it's a good solution to connect this to some script, which adds 
and removes users... Ok. Thanks for this hint. I'll think about it. 
Because i have to add new users to cyrus at all an sasldb...


Jakob
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel