diff --git a/tor.lsb b/tor.lsb deleted file mode 100755 index c0962c8..0000000 --- a/tor.lsb +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -# Init file for tor - An Anonymizing overlay network for TCP -# -# chkconfig: - 99 01 -# description: An Anonymizing overlay network for TCP -# -### BEGIN INIT INFO -# Default-Start: 4 -# Default-Stop: 0 1 2 6 -# Short-Description: An Anonymizing overlay network for TCP -# Description: An Anonymizing overlay network for TCP -# Required-Start: $network -# Should-Start: $syslog $time $remote_fs -### END INIT INFO - -. /lib/lsb/init-functions - -f=/etc/sysconfig/tor - -TOR_SHUTDOWN_WAIT=30 -TOR_OPTS=--quiet -TOR_PIDFILE=/var/run/tor/tor.pid -TOR_USER=toranon -test ! -r "$f" || . "$f" - -prog="/usr/bin/tor" - -lockfile=/var/lock/subsys/tor -pidfile=$TOR_PIDFILE - -start() { - echo -n $"Starting $prog: " - - start_daemon $prog --PIDFile "$pidfile" --RunAsDaemon 1 $TOR_OPTS - rc=$? - if test $rc -eq 0 && touch $lockfile; then - log_success_msg - else - log_failure_msg - fi - - return $rc -} - -stop() { - echo -n $"Stopping $prog: " - if ! killproc -p "$pidfile" $prog -INT; then - log_failure_msg - else - cnt=$TOR_SHUTDOWN_WAIT - while let '--cnt > 0' && killproc -p "$pidfile" $prog -0; do - sleep 1 - done - - if test $cnt -ne 0 || killproc -p "$pidfile" $prog; then - log_success_msg - else - log_failure_msg - fi - fi - - rm -f $pidfile $lockfile -} - -restart() { - stop - start -} - -reload() { - echo -n $"Reloading $prog: " - killproc -p "$pidfile" $prog -HUP && log_success_msg || log_failure_msg -} - -status() { - pidofproc -p "$pidfile" "$prog" >/dev/null 2>&1 - rc=$? - case $rc in - (0) echo $"$prog is running";; - (1) echo $"program is dead and /var/run pid file exists";; - (2) echo $"program is dead and /var/lock lock file exists";; - (3) echo $"program is not running";; - (4) echo $"program or service status is unknown";; - (*) echo $"status $rc of $prog";; - esac - - return $rc -} - -case $1 in - (start|stop|reload|status|restart) - $1 - ;; - (force-reload) - restart - ;; - (condrestart|try-restart) - if [ -f $lockfile ]; then - restart - fi - ;; - (*) - echo $"Usage: $0 {start|stop|force-reload|reload|try-restart|status}" - exit 3 -esac diff --git a/tor.spec b/tor.spec index 292d8ed..7682793 100644 --- a/tor.spec +++ b/tor.spec @@ -8,12 +8,13 @@ %global homedir %_var/lib/%name %global logdir %_var/log/%name +%{!?_unitdir:%global _unitdir /lib/systemd/system} %{?with_noarch:%global noarch BuildArch: noarch} %{!?release_func:%global release_func() %%{?prerelease:0.}%1%%{?prerelease:.%%prerelease}%%{?dist}} Name: tor Version: 0.2.1.27 -Release: %release_func 1500 +Release: %release_func 1501 Group: System Environment/Daemons License: BSD Summary: Anonymizing overlay network for TCP (The onion router) @@ -50,36 +51,20 @@ Requires: %name-core = %version-%release %{?noarch} -%package lsb -Summary: LSB initscripts for tor +%package systemd +Summary: Systemd initscripts for tor Group: System Environment/Daemons -Provides: init(%name) = lsb -Conflicts: init(%name) = sysv -Requires: %name-core = %version-%release -Source10: tor.lsb -Source11: tor.tmpfiles -Requires(pre): %name-core -Requires(postun): lsb-core-noarch %name-core -Requires(post): lsb-core-noarch -Requires(preun): lsb-core-noarch -%{?noarch} - +Source10: tor.systemd.service +Provides: init(%name) = systemd +Requires(post): /bin/systemctl +Requires(preun): /bin/systemctl +Requires(postun): /bin/systemctl -%package sysv -Summary: Tor initscripts for Red Hat's proprietary initsystem -Group: System Environment/Daemons -Provides: init(%name) = sysv -Conflicts: init(%name) = lsb -Requires: %name-core = %version-%release -Source30: tor.sysv -Requires(pre): %name-core -Requires(post): chkconfig -Requires(preun): chkconfig -# This is for /sbin/service -Requires(preun): initscripts -# This is for /sbin/service -Requires(postun): initscripts -%{?noarch} +# TODO: remove me in F17 +Obsoletes: %name-lsb < %version-%release +Provides: %name-lsb = %version-%release +Obsoletes: %name-sysv < %version-%release +Provides: %name-sysv = %version-%release %package upstart @@ -126,26 +111,20 @@ Tor is a connection-based low-latency anonymous communication system. This package provides documentation for "tor". -%description lsb +%description systemd Tor is a connection-based low-latency anonymous communication system. -This package contains the LSB compliant initscripts to start the "tor" +This package contains the systemd initscripts to start the "tor" daemon. -%description sysv -Tor is a connection-based low-latency anonymous communication system. - -This package contains the initscripts to start the "tor" daemon with -Red Hat's proprietary initsystem. - - %description upstart Tor is a connection-based low-latency anonymous communication system. This package contains the upstart compliant initscripts to start the "tor" daemon. + %prep %setup -q @@ -171,8 +150,7 @@ mv $RPM_BUILD_ROOT%_sysconfdir/tor/torrc{.sample,} mkdir -p $RPM_BUILD_ROOT{%logdir,%homedir,%_var/run/%name} -install -D -p -m 0755 %SOURCE10 $RPM_BUILD_ROOT%_initrddir/%name -install -D -p -m 0755 %SOURCE11 $RPM_BUILD_ROOT%_sysconfdir/tmpfiles.d/%name.conf +install -D -p -m 0644 %SOURCE10 $RPM_BUILD_ROOT%_unitdir/%name.service install -D -p -m 0644 %SOURCE2 $RPM_BUILD_ROOT%_sysconfdir/logrotate.d/tor install -D -p -m 0644 %SOURCE20 $RPM_BUILD_ROOT%_sysconfdir/init/tor.conf @@ -188,31 +166,16 @@ install -D -p -m 0644 %SOURCE20 $RPM_BUILD_ROOT%_sysconfdir/init/tor.conf %__fe_groupdel %username &>/dev/null || : -%post lsb -/usr/lib/lsb/install_initd %_initrddir/tor - -%preun lsb -test "$1" != 0 || %_initrddir/tor stop &>/dev/null || : -test "$1" != 0 || /usr/lib/lsb/remove_initd %_initrddir/tor - -%postun lsb -test "$1" = 0 || env -i %_initrddir/tor try-restart &>/dev/null +%post systemd +test "$1" -ne 1 || /bin/systemctl daemon-reload >/dev/null 2>&1 || : +%preun systemd +test "$1" -ne 1 || /bin/systemctl disable %name.service > /dev/null 2>&1 || : +test "$1" -ne 1 || /bin/systemctl stop %name.service > /dev/null 2>&1 || : -%post sysv -# This adds the proper /etc/rc*.d links for the script -/sbin/chkconfig --add