[dropbear] Migrate to systemd.
Jon Ciesla
limb at fedoraproject.org
Fri Apr 20 14:52:43 UTC 2012
commit 3b7f576897ed22dadc1a07c583b2078f14c9c4a6
Author: Jon Ciesla <limburgher at gmail.com>
Date: Fri Apr 20 09:52:17 2012 -0500
Migrate to systemd.
dropbear-keygen.service | 14 ++++++++++++
dropbear.service | 12 ++++++++++
dropbear.spec | 52 +++++++++++++++++++++++++++++++++++-----------
3 files changed, 65 insertions(+), 13 deletions(-)
---
diff --git a/dropbear-keygen.service b/dropbear-keygen.service
new file mode 100644
index 0000000..56e4f94
--- /dev/null
+++ b/dropbear-keygen.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Dropbear SSH Key Generatior
+Before=dropbear.service
+ConditionPathExists=!/etc/dropbear/dropbear_rsa_host_key
+ConditionPathExists=!/etc/dropbear/dropbear_dss_host_key
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
+ExecStart=/usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dropbear.service b/dropbear.service
new file mode 100644
index 0000000..086c4ed
--- /dev/null
+++ b/dropbear.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Dropbear SSH Server Daemon
+Wants=dropbear-keygen.service
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/dropbear.pid
+ExecStart=/usr/sbin/dropbear
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dropbear.spec b/dropbear.spec
index 5bf830d..d2cbb38 100644
--- a/dropbear.spec
+++ b/dropbear.spec
@@ -1,18 +1,22 @@
Name: dropbear
Version: 0.55
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: SSH2 server and client
Group: Applications/Internet
License: MIT
URL: http://matt.ucc.asn.au/dropbear/dropbear.html
Source0: http://matt.ucc.asn.au/dropbear/releases/dropbear-2012.55.tar.bz2
-Source1: dropbear.init
+Source1: dropbear.service
+Source2: dropbear-keygen.service
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: zlib-devel
-Requires: initscripts
-Requires(post): chkconfig >= 0.9, initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# For triggerun
+Requires(post): systemd-sysv
%description
Dropbear is a relatively small SSH 2 server and client. Dropbear
@@ -34,8 +38,9 @@ make %{?_smp_mflags}
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
install -d $RPM_BUILD_ROOT%{_sysconfdir}/dropbear
-install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
-install -m 0755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/dropbear
+install -d $RPM_BUILD_ROOT%{_unitdir}
+install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/dropbear.service
+install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/dropbear-keygen.service
install -d $RPM_BUILD_ROOT%{_mandir}/man1
install -m 0644 dbclient.1 $RPM_BUILD_ROOT%{_mandir}/man1/dbclient.1
install -d $RPM_BUILD_ROOT%{_mandir}/man8
@@ -46,23 +51,41 @@ install -m 0644 dropbearkey.8 $RPM_BUILD_ROOT%{_mandir}/man8/dropbearkey.8
rm -rf $RPM_BUILD_ROOT
%post
-/sbin/chkconfig --add dropbear
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
%postun
-/sbin/service dropbear condrestart > /dev/null 2>&1 || :
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart dropbear.service >/dev/null 2>&1 || :
+fi
%preun
-if [ "$1" = 0 ]
-then
- /sbin/service dropbear stop > /dev/null 2>&1 || :
- /sbin/chkconfig --del dropbear
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable dropbear.service > /dev/null 2>&1 || :
+ /bin/systemctl stop dropbear.service > /dev/null 2>&1 || :
fi
+%triggerun -- dropbear < 0.55-2
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply dropbear
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save dropbear >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del dropbear >/dev/null 2>&1 || :
+/bin/systemctl try-restart dropbear.service >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root)
%doc CHANGES INSTALL LICENSE MULTI README SMALL TODO
%attr(0755,root,root) %dir %{_sysconfdir}/dropbear
-%attr(0755,root,root) /etc/rc.d/init.d/dropbear
+%attr(0755,root,root) %{_unitdir}/dropbear*
%attr(0755,root,root) %{_bindir}/dropbearkey
%attr(0755,root,root) %{_bindir}/dropbearconvert
%attr(0755,root,root) %{_bindir}/dbclient
@@ -72,6 +95,9 @@ fi
%attr(0644,root,root) %{_mandir}/man8/dropbearkey.8*
%changelog
+* Fri Apr 20 2012 Jon Ciesla <limburgher at gmail.com> - 0.55-2
+- Migrate to systemd, BZ 770251.
+
* Sun Apr 01 2012 Itamar Reis Peixoto <itamar at ispbrasil.com.br> - 0.55-1
- new version 2012.55
More information about the scm-commits
mailing list