baodrate / snap-sync

Use snapper snapshots to backup to external drive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What needs to be done on a non-systemd system?

tleydxdy opened this issue · comments

Hi, I want to use this on an non-systemd system, any pointers as to areas I need to change to make it not depend on systemd?

I looked into a bit and it's literally only one line: line 42 calling systemd-cat. Just change that to w/e sends logs to syslog for you. I think logger is the typical command as it works for me on a runit based system, but I don't know if that is true for all inits besides systemd.

@wesbarnett If you'd like, I could make a PR for you. I'd simply add the command ps h -p 1 -o cmd to get the name of the command of process 1 which is always (or should always) be the init system, and then do a check for different inits and execute the appropriate logging command.

don't systemd already handles logging from stdout/stderr?

I do not know, but assuming that systemd does, my guess is that @wesbarnett wanted systemd to log it with the specified tag "snap-sync" presumably to make it easier to grep for problems. Otherwise (again, just guessing) systemd doesn't log it with any clear distinction.

upon further thought, why would it log to systemd at all? isn't printing out of stderr enough?

That's a good question. I think printing to stderr might get garbled with stdout, but redirecting to a separate log file makes the most sense to me in terms of keeping the script init system agnostic.

stderr and stdout won't affect each other, what do you mean?

... good catch, had a brain fart there. I think my rationale was that it would be outputted on the terminal with the stdout, but you could easily just redirect stderr to a log file while keeping stdout on the terminal