Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix README systemd email notification #127

Closed
wants to merge 2 commits into from

Conversation

giuaig
Copy link
Contributor

@giuaig giuaig commented Dec 10, 2023

Hello, thanks for your works that allow me to do scheduled backups with restic.
This are just minor fixes in the README, about systemd email notification.

I was getting this error, because $INSTALL_PREFIX was still there even if I installed it via make:

Failed to enqueue OnFailure= job, ignoring: Unit status-email-user@[email protected] has a bad unit file setting.

Removing fixed it.
HTH

Copy link
Owner

@erikw erikw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The fixes makes sense.

Though the unexpanded $INSTALL_PREFIX sounds like a bug that should be addressed in the Makefile.

I don’t have the possibility to investigate further myself right now but feel free to look into it. I would believe the variable is expanded in other file’s when installing with make.

Put this files in `/etc/systemd/system/`:
* `[email protected]`: A service that can notify you via email when a systemd service fails. Edit the target email address in this file.
Put this file in `/etc/systemd/system/`:
* `[email protected]`: A service that can notify you via email when a systemd service fails. Edit the target email address in this file and remove `$INSTALL_PREFIX` from `ExecStart` line if needed.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like a bug with the Makefike, so it would be better to try fixing this then adding a manual workaround in the README.

@giuaig
Copy link
Contributor Author

giuaig commented Dec 11, 2023

If i run installation on a fresh VM (Debian 12) i get the following after sudo make install-systemd:

cp bin/restic_backup.sh build/bin/restic_backup.sh
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/bin/restic_backup.sh; rm build/bin/restic_backup.sh.bak
install -m 0555 build/bin/restic_backup.sh /bin/restic_backup.sh
cp bin/restic_check.sh build/bin/restic_check.sh
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/bin/restic_check.sh; rm build/bin/restic_check.sh.bak
install -m 0555 build/bin/restic_check.sh /bin/restic_check.sh
cp bin/resticw build/bin/resticw
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/bin/resticw; rm build/bin/resticw.bak
install -m 0555 build/bin/resticw /bin/resticw
cp etc/restic/backup_exclude.txt build/etc/restic/backup_exclude.txt
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/etc/restic/backup_exclude.txt; rm build/etc/restic/backup_exclude.txt.bak
install -m 0600 -b --suffix=.2023-12-11_21:17:51.bak build/etc/restic/backup_exclude.txt /etc/restic/backup_exclude.txt
cp etc/restic/default.env.sh build/etc/restic/default.env.sh
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/etc/restic/default.env.sh; rm build/etc/restic/default.env.sh.bak
install -m 0600 -b --suffix=.2023-12-11_21:17:51.bak build/etc/restic/default.env.sh /etc/restic/default.env.sh
cp etc/restic/_global.env.sh build/etc/restic/_global.env.sh
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/etc/restic/_global.env.sh; rm build/etc/restic/_global.env.sh.bak
install -m 0600 -b --suffix=.2023-12-11_21:17:51.bak build/etc/restic/_global.env.sh /etc/restic/_global.env.sh
cp etc/restic/pw.txt build/etc/restic/pw.txt
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/etc/restic/pw.txt; rm build/etc/restic/pw.txt.bak
install -m 0600 -b --suffix=.2023-12-11_21:17:51.bak build/etc/restic/pw.txt /etc/restic/pw.txt
cp usr/lib/systemd/system/[email protected] build/usr/lib/systemd/system/[email protected]
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/usr/lib/systemd/system/[email protected]; rm build/usr/lib/systemd/system/[email protected]
install -m 0644 build/usr/lib/systemd/system/[email protected] /usr/lib/systemd/system/[email protected]
cp usr/lib/systemd/system/[email protected] build/usr/lib/systemd/system/[email protected]
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/usr/lib/systemd/system/[email protected]; rm build/usr/lib/systemd/system/[email protected]
install -m 0644 build/usr/lib/systemd/system/[email protected] /usr/lib/systemd/system/[email protected]
cp usr/lib/systemd/system/[email protected] build/usr/lib/systemd/system/[email protected]
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/usr/lib/systemd/system/[email protected]; rm build/usr/lib/systemd/system/[email protected]
install -m 0644 build/usr/lib/systemd/system/[email protected] /usr/lib/systemd/system/[email protected]
cp usr/lib/systemd/system/[email protected] build/usr/lib/systemd/system/[email protected]
sed -i.bak -e 's|$INSTALL_PREFIX||g' build/usr/lib/systemd/system/[email protected]; rm build/usr/lib/systemd/system/[email protected]
install -m 0644 build/usr/lib/systemd/system/[email protected] /usr/lib/systemd/system/[email protected]

No trace of [email protected] file automatically copied to destination directory, so no sed substitution happen on it.

This makes sense to me, because email notification is optional as you stated in the original README, so file [email protected] has to be copied by hands to target dir.
Hence no sed substitution happens via Makefile to [email protected].

To further investigate i checked all the files in the previous output, i found that $INSTALL_PREFIX is correctly removed everywhere except in /bin/restic_backup.sh (line 76), i think due to curly braces around ${INSTALL_PREFIX}.

I would change the Detailed Manual Setup find command too, it run sed on etc bin but not on usr dir, so $INSTALL_PREFIX would be still present in [email protected] (line 17) for example. Makefile takes already care of that.

@gerardbosch
Copy link
Contributor

To further investigate i checked all the files in the previous output, i found that $INSTALL_PREFIX is correctly removed everywhere except in /bin/restic_backup.sh (line 76), i think due to curly braces around ${INSTALL_PREFIX}.

Hi there! I just observed the same thing while adding #128

I got a little confused to with the $INSTALL_PREFIX on the source files, as it's been a long time 😅 My confusion mainly came by the notation of this placeholder, as is using the regular shell notation for variables. But as I realized that this is a template placeholder intended to be pre-processed by the build tool.

I'm wondering if would be more convenient to use a templating notation like {{ INSTALL_PREFIX }} instead. What do you think @erikw ? Just an idea 🙂, maybe something to add to a TODO list or an issue. Maybe I can give it a shot.

@erikw
Copy link
Owner

erikw commented Dec 12, 2023

Ah god find @gerardbosch

@giuaig could you please update the OR with the syntax fix?

@giuaig
Copy link
Contributor Author

giuaig commented Dec 12, 2023

@erikw OR = Original Readme? If so i think it's everything already in this PR

@gerardbosch
Copy link
Contributor

gerardbosch commented Dec 12, 2023

Hi! I packed everything together and posted #131, but I'm afraid that will be conflicts with this PR, so I added the @giuaig changes on that PR in case it gets accepted.

#131 would fix what we @giuaig said here:

To further investigate i checked all the files in the previous output, i found that $INSTALL_PREFIX is correctly removed everywhere except in /bin/restic_backup.sh (line 76), i think due to curly braces around ${INSTALL_PREFIX}.

I hope it can help

@erikw
Copy link
Owner

erikw commented Dec 13, 2023

Thanks @gerardbosch. I would be happy to go with #131 that includes this PR.

Please amend one of the commits in #131 to attribute @giuaig with https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors

co-authored-by: giuaig <[email protected]>

@erikw erikw closed this Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants