SHA256
1
0
forked from pool/bitlbee

Accepting request 238043 from home:mcaj:branches:server:irc

Hi bitlbee can be run ad deamon now !
for security reason its run as user bitlbee.
here is a full list of changes i did there: 

- Added init.d and systemd  to be able run the bitlbee as standard service.
- Rc$service script is runnig as symlink for systemd and init.d. 
- Improved way how user bitlbee is add into system via rpm.
- Fixed warning about wrong license:
   its still "GNU General Public License version 2 (GPL v2)" but osc marks it 
   via shorcut : GPL-2.0+
- The PID directory is /var/run/bitlbee/ or /run/bitlbee/ depends on the version.
- The PID directory is created via systemd or initd script, bacuse its in tmpfs.
- Each BuildRequires is on one line to avoid duplicate packages.
- Removed if for SLES9 - not need any more
- Run spec-clean on the spec file and fixed a small bug is spec file after clearing no "fixme" any more there.

ps : the warning bitlbee.x86_64: W: call-to-mktemp /usr/sbin/bitlbee need to be patch in future, however my C skills are very low ....

OBS-URL: https://build.opensuse.org/request/show/238043
OBS-URL: https://build.opensuse.org/package/show/server:irc/bitlbee?expand=0&rev=23
This commit is contained in:
Tomáš Chvátal 2014-06-19 09:12:17 +00:00 committed by Git OBS Bridge
parent 62825590c6
commit d4b65a63c4
4 changed files with 291 additions and 37 deletions

View File

@ -1,3 +1,36 @@
-------------------------------------------------------------------
Wed Jun 18 14:11:16 UTC 2014 - mcaj@suse.com
- Removed if for SLES9 - not need any more
- Run spec-clean on the spec file.
-------------------------------------------------------------------
Wed Jun 18 13:07:23 UTC 2014 - mcaj@suse.com
- The PID directory is /var/run/bitlbee/ or /run/bitlbee/ depends on the version.
- The PID directory is created via systemd or initd script, bacuse its in tmpfs.
- Each BuildRequires is on one line to avoid duplicate packages.
-------------------------------------------------------------------
Tue Jun 17 13:05:14 UTC 2014 - mcaj@suse.com
- I fixed systemd service sctipt to be able run under the user bitlbee.
- The PID file is now /var/run/bitlbee/bitlbee.pid.
- The directory /var/run/bitlbee/ is own by user bitlbee.
- The build is also done for pid and sock under /var/run/bitlbee/.
- The creating the user bitlbee is done via the command useradd now.
- Information about creating new user on directory is accnouce via logger now.
- Added copyrigth and credention to init and systemd service file.
-------------------------------------------------------------------
Fri Jun 6 12:32:29 UTC 2014 - mcaj@suse.com
- Added init.d and systemd to be able run the bitlbee as standard service.
- Improved way how user bitlbee is add into system via rpm.
- Fixed warning about wrong license:
its still "GNU General Public License version 2 (GPL v2)" but osc marks it
via shorcut : GPL-2.0+
-------------------------------------------------------------------
Thu Jan 30 19:17:00 UTC 2014 - cs@suse.com

123
bitlbee.init.d-suse.in Normal file
View File

@ -0,0 +1,123 @@
#!/bin/sh
# Copyright (c) 1995-2014 SUSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Martin Caj <mcaj@suse.cz>
#
# /etc/init.d/bitlbee
#
# and it's symbolic link
#
# /usr/sbin/rcbitlbee
#
### BEGIN INIT INFO
# Provides: bitlbee
# Required-Start: $remote_fs $syslog
# Should-Start:
# Required-Stop: $remote_fs $syslog
# Should-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start bitblee IM to IRC gateway
# Short-Description: IM to IRC gateway
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
BITLBEE_BIN="/usr/sbin/bitlbee"
BITLBEE_ETC="/etc/bitlbee"
BITLBEE_PIDDIR="/var/run/bitlbee"
BITLBEE_PID=""$BITLBEE_PIDDIR"/bitlbee.pid"
BITLBEE_PARAM="-p $BITLBEE_PID"
test -x $BITLBEE_BIN || { echo "$BITLBEE_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# /var/run might be tmfs, so if $BITLBEE_PIDDIR not exist yet create it now.
if [ ! -d "$BITLBEE_PIDDIR" ]; then
/usr/bin/mkdir -p "$BITLBEE_PIDDIR"
/usr/bin/chown bitlbee.bitlbee "$BITLBEE_PIDDIR"
fi
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_status -s display "skipped" and exit with status 3
# rc_status -u display "unused" and exit with status 3
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# rc_active checks whether a service is activated by symlinks
# rc_splash arg sets the boot splash screen to arg (if active)
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting bitlbee server"
startproc $BITLBEE_BIN $BITLBEE_PARAM
rc_status -v
;;
stop)
echo -n "Shutting down bitlbee server"
killproc -TERM $BITLBEE_BIN
rc_status -v
;;
try-restart)
$0 status >/dev/null && $0 restart
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
# force-reload)
# echo -n "Reload console mouse support (bitlbee)"
# $0 stop && $0 start
# rc_status
# ;;
# reload)
# echo -n "Reload console mouse support (bitlbee)"
# rc_failed 3
# rc_status -v
# ;;
status)
echo -n "Checking for bitlbee server: "
checkproc $BITLBEE_BIN
rc_status -v
;;
probe)
BITLBEE_RESTART="False"
for file in "$BITLBEE_SYSCONFIG" "$BITLBEE_ETC"/* ; do
test "$file" -nt "$BITLBEE_PID" && BITLBEE_RESTART="True"
done
test "$BITLBEE_RESTART" = "True" && echo restart
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit

29
bitlbee.service-suse.in Normal file
View File

@ -0,0 +1,29 @@
# Copyright (c) 1995-2014 SUSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Martin Caj <mcaj@suse.cz>
#
# /usr/lib/systemd/system/bitlbee-server.service
#
# and it's symbolic link
#
# /usr/sbin/rcbitlbee
[Unit]
Description=Bitblee Daemonm the IM to IRC gateway
After=network.target
[Service]
Type=forking
ExecStartPre=/usr/bin/mkdir -p /run/bitlbee
ExecStartPre=/usr/bin/chown bitlbee.bitlbee /run/bitlbee
ExecStart=/usr/sbin/bitlbee
PIDFile=/var/run/bitlbee/bitlbee.pid
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
User=bitlbee
Group=bitlbee
[Install]
WantedBy=multi-user.target

View File

@ -1,4 +1,7 @@
# vim: set ts=4 sw=4 et:
#
# spec file for package bitlbee
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2012 Pascal Bleser <pascal.bleser@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
@ -11,25 +14,51 @@
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# See http://bugs.bitlbee.org/bitlbee/ticket/1004
# Define way to log messages for the machine:
%define nnmmsg logger -t %{name}/rpm
%if 0%{?suse_version} >= 1100
%define with_libotr 1
%endif
#define systemd for the new OpenSUSE only:
%if 0%{?suse_version} >= 1310
%define with_systemd 1
%else
%define with_systemd 0
%endif
# define patch where the service will have pid and socket store:
%if 0%{?suse_version} >= 1310
%define daemon_piddir /run/%{name}
%else
%define daemon_piddir %{_localstatedir}/run/%{name}
%endif
Name: bitlbee
Version: 3.2.1
Release: 0
Summary: IRC to other Chat Networks Gateway
License: GPL-2.0
Group: Productivity/Networking/IRC
Url: http://www.bitlbee.org/
Source: http://get.bitlbee.org/src/bitlbee-%{version}.tar.gz
Source1: %{name}.xinetd-suse.in
URL: http://www.bitlbee.org/
Group: Productivity/Networking/IRC
License: GNU General Public License version 2 (GPL v2)
BuildRoot: %{_tmppath}/build-%{name}-%{version}
Source2: %{name}.service-suse.in
Source3: %{name}.init.d-suse.in
BuildRequires: gcc
BuildRequires: glib2-devel
BuildRequires: glibc-devel
BuildRequires: gnutls-devel
BuildRequires: libgcrypt-devel
BuildRequires: lzo-devel
BuildRequires: make
BuildRequires: pkgconfig
BuildRequires: zlib-devel
Requires: logrotate
Requires: xinetd
BuildRequires: make gcc glibc-devel pkgconfig gnutls-devel libgcrypt-devel
BuildRequires: zlib-devel glib2-devel lzo-devel glib2-devel
Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1010
BuildRequires: xmlto
%endif
@ -46,8 +75,9 @@ BuildRequires: libotr-devel
%if 0%{?suse_version} >= 1110
BuildRequires: libpurple-devel
%endif
PreReq: /usr/sbin/groupadd /usr/sbin/useradd
%if %{with_systemd}
BuildRequires: systemd
%endif
%description
We are both console lovers. But it is annoying to have a few tty's open with
@ -94,13 +124,10 @@ This package contains the user guide:
%setup -q
# make it verbose!
find . -name Makefile -exec %__sed -i.orig 's|@$(CC)|$(CC)|;s|@$(LD)|$(LD)|' {} \;
find . -name Makefile -exec sed -i.orig 's|@$(CC)|$(CC)|;s|@$(LD)|$(LD)|' {} \;
%build
# fix to find the glib-2.0 pkgconfig on SLES_9
%if 0%{?suse_version} < 1030
export PKG_CONFIG_PATH="/opt/gnome/%{_lib}/pkgconfig"
%endif
# not autoconf
CFLAGS="%{optflags} -fno-strict-aliasing" \
CXXFLAGS="%{optflags} -fno-strict-aliasing" \
@ -111,9 +138,9 @@ CXXFLAGS="%{optflags} -fno-strict-aliasing" \
--mandir="%{_mandir}" \
--datadir="%{_datadir}/%{name}" \
--plugindir="%{_libdir}/%{name}" \
--pidfile="%{_localstatedir}/run/%{name}.pid" \
--pidfile="%{daemon_piddir}/%{name}.pid" \
--config="%{_localstatedir}/lib/%{name}" \
--ipcsocket="%{_localstatedir}/run/%{name}.sock" \
--ipcsocket="%{daemon_piddir}/%{name}.sock" \
%if 0%{?suse_version} >= 1110
--purple=1 \
%else
@ -136,53 +163,95 @@ CXXFLAGS="%{optflags} -fno-strict-aliasing" \
--plugins=1 \
--ssl=gnutls
%__make %{?_smp_flags}
make %{?_smp_flags}
%install
%__install -d "%{buildroot}%{_mandir}/man1"
%__install -d "%{buildroot}%{_mandir}/man8"
%__install -d "%{buildroot}%{_sysconfdir}/bitlbee"
%__install -d "%{buildroot}%{_localstatedir}/lib/bitlbee"
install -d "%{buildroot}%{_mandir}/man1"
install -d "%{buildroot}%{_mandir}/man8"
install -d "%{buildroot}%{_sysconfdir}/bitlbee"
install -d "%{buildroot}%{_localstatedir}/lib/bitlbee"
%if 0%{?suse_version} >= 1010
%__make DESTDIR="%{buildroot}" -C doc
make DESTDIR=%{buildroot} -C doc
%endif
%makeinstall install-etc
%{makeinstall} install-etc
%__install -d "%{buildroot}%{_sysconfdir}/xinetd.d"
%__sed -e "s+@@BITLBEE@@+%{_sbindir}/bitlbee+g" \
install -d "%{buildroot}%{_sysconfdir}/xinetd.d"
sed -e "s+@@BITLBEE@@+%{_sbindir}/bitlbee+g" \
< "%{SOURCE1}" > "%{buildroot}%{_sysconfdir}/xinetd.d/bitlbee"
%if 0%{?suse_version} >= 1030
%fdupes -s
%endif
%__install -d "%{buildroot}%{_docdir}/%{name}"
%if %{with_systemd}
install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
%else
install -D -p -m 0755 %{SOURCE3} %{buildroot}%{_initrddir}/%{name}
ln -s %{_initrddir}/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%endif
install -d "%{buildroot}%{_docdir}/%{name}"
LM="$PWD/%{name}.lang"
echo -n > "$LM"
for f in COPYING doc/AUTHORS doc/CHANGES doc/CREDITS doc/FAQ doc/README; do
b="${f##*/}"
%__install -m0644 "$f" "%{buildroot}%{_docdir}/%{name}/$b"
install -m0644 "$f" "%{buildroot}%{_docdir}/%{name}/$b"
echo "%doc %{_docdir}/%{name}/$b" >>"$LM"
done
%__install -d "%{buildroot}%{_docdir}/%{name}/user-guide"
%__cp -a doc/user-guide/*.{txt,html} "%{buildroot}%{_docdir}/%{name}/user-guide/"
install -d "%{buildroot}%{_docdir}/%{name}/user-guide"
cp -a doc/user-guide/*.{txt,html} "%{buildroot}%{_docdir}/%{name}/user-guide/"
%pre
/usr/bin/getent group bitlbee &>/dev/null || /usr/sbin/groupadd -r bitlbee &>/dev/null || :
/usr/bin/getent passwd bitlbee &>/dev/null || \
/usr/sbin/useradd -g bitlbee -s /bin/false -r -c "User for bitlbee" \
-d "%{_localstatedir}/run/bitlbee" bitlbee &>/dev/null || :
# create default user if its need it.
if id bitlbee > /dev/null 2>&1;then
: OK user %{name} already present
%{nnmmsg} "info: The user %{name} for package %{name} is already present"
else
useradd -r -g bitlbee -s /bin/false -c "bitlbee User" -d %{_localstatedir}/lib/%{name} bitlbee 2> /dev/null || :
%{nnmmsg} "Added user bitlbee for package %{name}"
fi
%clean
%{?buildroot:%__rm -rf "%{buildroot}"}
%if %{with_systemd}
%service_add_pre %{name}.service
%endif
%post
%if %{with_systemd}
%service_add_post %{name}.service
%else
%{fillup_and_insserv -n %{name} }
%endif
%preun
%if %{with_systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif
%postun
%if %{with_systemd}
%service_del_postun %{name}
%else
%restart_on_update %{name}
%insserv_cleanup
%endif
%files -f %{name}.lang
%defattr(-,root,root)
%doc %dir %{_docdir}/%{name}
%config(noreplace) %{_sysconfdir}/xinetd.d/bitlbee
%attr(0750,root,bitlbee) %dir %{_sysconfdir}/bitlbee
%if %{with_systemd}
%{_unitdir}/%{name}.service
%else
%attr(755,root,root) %{_initrddir}/%{name}
%endif
%{_sbindir}/rc%{name}
%config(noreplace) %attr(0640,root,bitlbee) %{_sysconfdir}/bitlbee/bitlbee.conf
%config(noreplace) %attr(0640,root,bitlbee) %{_sysconfdir}/bitlbee/motd.txt
%{_sbindir}/bitlbee