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

Generate /etc/yggdrasil.conf automatically after install or update #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions yggdrasil.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ install -m 0755 -D contrib/systemd/yggdrasil.service %{buildroot}/%{_sysconfdir}
%{_sysconfdir}/systemd/system/yggdrasil.service

%post
if [ -e %{_sysconfdir}/yggdrasil.conf ]; then
TMPDIR=$(mktemp -d)
%{_bindir}/yggdrasil -useconffile %{_sysconfdir}/yggdrasil.conf -normaliseconf > $TMPDIR/yggdrasil.conf
if ! cmp -s "%{_sysconfdir}/yggdrasil.conf" "$TMPDIR/yggdrasil.conf"; then
mv -f "$TMPDIR/yggdrasil.conf" "%{_sysconfdir}/yggdrasil.conf.rpmnew"
chmod 640 %{_sysconfdir}/yggdrasil.conf.rpmnew
echo "An updated %{_sysconfdir}/yggdrasil.conf was saved as %{_sysconfdir}/yggdrasil.conf.rpmnew"
fi
rm -rf $TMPDIR
else
echo "Generating initial configuration file %{_sysconfdir}/yggdrasil.conf"
echo "Please familiarize yourself with this file before starting Yggdrasil"
%{_bindir}/yggdrasil -genconf > %{_sysconfdir}/yggdrasil.conf
chmod 640 %{_sysconfdir}/yggdrasil.conf
fi
%systemd_post yggdrasil.service

%preun
Expand Down