From ca5bb87cb15ba4f5d07d2484a79e9ff1ec535262f8ca0518459519299cbdfcf6 Mon Sep 17 00:00:00 2001 From: Andreas Stieger Date: Sun, 11 Aug 2013 13:21:39 +0000 Subject: [PATCH] Accepting request 186662 from home:AndreasStieger:branches:network:utilities - add systemd support - move settings from /etc/bwbar to /etc/sysconfig/bwbar and use sysconfig template fillup OBS-URL: https://build.opensuse.org/request/show/186662 OBS-URL: https://build.opensuse.org/package/show/network:utilities/bwbar?expand=0&rev=4 --- bwbar.changes | 7 ++++++ bwbar.service | 21 ++++++++++++++++++ bwbar.spec | 57 +++++++++++++++++++++++++++++++++++++----------- bwbar_initscript | 2 +- 4 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 bwbar.service diff --git a/bwbar.changes b/bwbar.changes index 1eeb3b4..e58130d 100644 --- a/bwbar.changes +++ b/bwbar.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sun Aug 11 13:13:29 UTC 2013 - andreas.stieger@gmx.de + +- add systemd support +- move settings from /etc/bwbar to /etc/sysconfig/bwbar + and use sysconfig template fillup + ------------------------------------------------------------------- Sat Oct 13 13:06:50 UTC 2012 - andreas.stieger@gmx.de diff --git a/bwbar.service b/bwbar.service new file mode 100644 index 0000000..a4beba9 --- /dev/null +++ b/bwbar.service @@ -0,0 +1,21 @@ +[Unit] +Description=Bandwith Usage Monitor +After=network.target + +[Service] +EnvironmentFile=/etc/sysconfig/bwbar +ExecStart=/usr/bin/bwbar \ + --${BWBAR_MEASURE} \ + --text-file $BWBAR_TEXTFILE \ + --png-file $BWBAR_PNGFILE \ + --interval $BWBAR_INTERVAL \ + --width $BWBAR_WIDTH \ + --height $BWBAR_HEIGHT \ + --border $BWBAR_BORDER \ + --${BWBAR_UNIT} \ + $BWBAR_DEVICE \ + $BWBAR_MAXMBPS + +[Install] +WantedBy=multi-user.target + diff --git a/bwbar.spec b/bwbar.spec index 8fc1e12..c27edf4 100644 --- a/bwbar.spec +++ b/bwbar.spec @@ -1,7 +1,7 @@ # # spec file for package bwbar # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -29,9 +29,17 @@ Source: %{name}-%{version}.tar.bz2 Source1: COPYING Source2: bwbar_config Source3: bwbar_initscript +Source4: bwbar.service # http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-analyzer/bwbar/files/bwbar-1.2.3-libpng15.patch?revision=1.1&pathrev=HEAD # PATCH-FIX-UPSTREAM bwbar-1.2.3-libpng15.patch andreas.stieger@gmx.de -- fixes build against libpng15 Patch0: bwbar-1.2.3-libpng15.patch +# +%if 0%{?suse_version} >= 1210 +BuildRequires: pkgconfig(systemd) +%{?systemd_requires} +%define has_systemd 1 +%endif +# BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -58,29 +66,52 @@ CFLAGS="-Wall $RPM_OPT_FLAGS" %__make %{?_smp_mflags} %install -install -d $RPM_BUILD_ROOT%{_bindir} -install -m 755 --strip bwbar $RPM_BUILD_ROOT%{_bindir} -install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/%{name} -install -m 755 -D %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/init.d/%{name} -mkdir -p $RPM_BUILD_ROOT/%{_sbindir} -ln -svf ../../etc/init.d/%{name} $RPM_BUILD_ROOT/%{_sbindir}/rc%{name} +install -d %buildroot%{_bindir} +install -m 755 bwbar %buildroot%{_bindir} +install -m 644 -D %{SOURCE2} %buildroot/var/adm/fillup-templates/sysconfig.%{name} +# +install -m 755 -D %{SOURCE3} %buildroot%{_sysconfdir}/init.d/%{name} +mkdir -p %buildroot%{_sbindir} +ln -svf ../../etc/init.d/%{name} %buildroot/%{_sbindir}/rc%{name} +# +%if 0%{?has_systemd} +install -m 644 -D %{SOURCE4} %buildroot/%{_unitdir}/%name.service +%endif +# -%clean -rm -rf $RPM_BUILD_ROOT +%pre +%if 0%{?has_systemd} +%service_add_pre bwbar.service +%endif + +%post +%{fillup_and_insserv} +%if 0%{?has_systemd} +%service_add_post bwbar.service +%endif + +%preun +%stop_on_removal +%if 0%{?has_systemd} +%service_del_preun bwbar.service +%endif %postun %insserv_cleanup %restart_on_update - -%preun -%stop_on_removal +%if 0%{?has_systemd} +%service_del_postun bwbar.service +%endif %files %defattr(-, root, root) %doc README COPYING %{_bindir}/* %{_sbindir}/* -%config %{_sysconfdir}/%{name} +/var/adm/fillup-templates/sysconfig.%{name} %config %{_sysconfdir}/init.d/%{name} +%if 0%{?has_systemd} +%{_unitdir}/%{name}.service +%endif %changelog diff --git a/bwbar_initscript b/bwbar_initscript index e1248eb..1677404 100644 --- a/bwbar_initscript +++ b/bwbar_initscript @@ -52,7 +52,7 @@ test -x $BWBAR_BIN || { echo "$BWBAR_BIN not installed"; else exit 5; fi; } # Check for existence of needed config file and read it -BWBAR_CONFIG=/etc/bwbar +BWBAR_CONFIG=/etc/sysconfig/bwbar test -r $BWBAR_CONFIG || { echo "$BWBAR_CONFIG not existing"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; }