79 lines
1.5 KiB
Plaintext
79 lines
1.5 KiB
Plaintext
%global dch_libexecdir %{_libexecdir}/dch
|
|
%global dch_datadir %{_datarootdir}/dch
|
|
|
|
%define _debugsource_template %{nil}
|
|
|
|
Name: dch-autoprovision
|
|
Version: 1
|
|
Release: %autorelease
|
|
Summary: Automation for provisioning hosts on Dustin's infrastructure.
|
|
|
|
License: 0BSD
|
|
URL: https://git.pyrocufflink.net/infra/dch-autoprovision
|
|
Source0: %{name}-%{version}.tar.gz
|
|
|
|
BuildRequires: systemd-rpm-macros
|
|
Requires: /usr/bin/curl
|
|
%{systemd_requires}
|
|
|
|
%description
|
|
%{summary}.
|
|
|
|
%prep
|
|
%autosetup
|
|
|
|
|
|
%build
|
|
:
|
|
|
|
|
|
%install
|
|
%__install -m u=rwx,go=rx -d \
|
|
"${RPM_BUILD_ROOT}%{dch_libexecdir}"
|
|
%__install -m u=rwx,go=rx \
|
|
notify-online.sh \
|
|
"${RPM_BUILD_ROOT}%{dch_libexecdir}"/notify-online
|
|
|
|
mkdir -p "${RPM_BUILD_ROOT}%{_unitdir}"
|
|
%__install -m u=rw,go=r \
|
|
notify-online.service \
|
|
"${RPM_BUILD_ROOT}%{_unitdir}"
|
|
mkdir -p "${RPM_BUILD_ROOT}%{_presetdir}"
|
|
%__install -m u=rw,go=r \
|
|
notify-online.preset \
|
|
"${RPM_BUILD_ROOT}%{_presetdir}"
|
|
|
|
%__install -m u=rwx,go=rx -d \
|
|
"${RPM_BUILD_ROOT}%{dch_datadir}"
|
|
%__install -m u=rw,go=r \
|
|
host-provisioner.key \
|
|
"${RPM_BUILD_ROOT}%{dch_datadir}/"
|
|
|
|
|
|
%post
|
|
%systemd_post notify-online.service
|
|
|
|
|
|
%preun
|
|
%systemd_preun notify-online.service
|
|
|
|
|
|
%posttrans
|
|
if [ $1 -eq 1 ]; then
|
|
printf 'expiry-time="%s",restrict,pty %s\n' \
|
|
"$(date -d +1hour +%Y%m%d%H%M)" \
|
|
"$(cat %{dch_datadir}/host-provisioner.key)" \
|
|
>> /root/.ssh/authorized_keys
|
|
fi
|
|
|
|
|
|
%files
|
|
%{dch_libexecdir}
|
|
%{dch_datadir}
|
|
%{_unitdir}/*
|
|
%{_presetdir}/*
|
|
|
|
|
|
%changelog
|
|
%autochangelog
|