Re: [Spacewalk-devel] [PATCH] build rhnmd on openSUSE

2011-04-15 Thread Jan Pazdziora
On Fri, Apr 15, 2011 at 01:55:45PM +0200, Michael Calmer wrote:
> Hi,
> 
> Am Freitag, 8. April 2011, 15:23:52 schrieb Michael Calmer:
> > Hi,
> > 
> > here is a patch to build rhnmd on openSUSE.
> > 
> > 0014-build-rhnmd-on-SUSE.patch
> > - modify the specfile
> > - add init script for openSUSE
> > 
> > For SUSE I have removed the ssh key generation from the %post section.
> > I added the generation into the SUSE init script. 
> > The reason for this is, that if you do it in %post and use this RPM in an 
> > appliance, you have the same ssh key on all copies of your appliance.
> > 
> > Maybe you are interrested to do this also for RedHat / Fedora. 
> 
> I changed this patch and splited one more general thing out.
> 
> build rhnmd on SUSE
> 
> - add init script for SUSE
> - BuildRequire sysconfig to make chkconfig work during build in OBS
> - openssh-server does not exist on SUSE (part of openssh)
> - no keygen in %post to use it in appliances
> - create nocpulse user in a different way to make hime work on SUSE
>   with openssh
> 
> add nocpulse config dir to filelist
> I think rhnmd requires nothing which already provides this directory.

Pushed to master as d4dfbbc37eb42e07b8d2afc6d3a19195731bcb7b
and 1e2120ddfc84f6804dda2decc6b2809c5dd154a9
and tagged as rhnmd-5.3.9-1.

Thanks,

-- 
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [PATCH] build rhnmd on openSUSE

2011-04-15 Thread Michael Calmer
Hi,

Am Freitag, 8. April 2011, 15:23:52 schrieb Michael Calmer:
> Hi,
> 
> here is a patch to build rhnmd on openSUSE.
> 
> 0014-build-rhnmd-on-SUSE.patch
> - modify the specfile
> - add init script for openSUSE
> 
> For SUSE I have removed the ssh key generation from the %post section.
> I added the generation into the SUSE init script. 
> The reason for this is, that if you do it in %post and use this RPM in an 
> appliance, you have the same ssh key on all copies of your appliance.
> 
> Maybe you are interrested to do this also for RedHat / Fedora. 

I changed this patch and splited one more general thing out.

build rhnmd on SUSE

- add init script for SUSE
- BuildRequire sysconfig to make chkconfig work during build in OBS
- openssh-server does not exist on SUSE (part of openssh)
- no keygen in %post to use it in appliances
- create nocpulse user in a different way to make hime work on SUSE
  with openssh

add nocpulse config dir to filelist
I think rhnmd requires nothing which already provides this directory.

-- 
Regards,

Michael Calmer

--
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
From e27fbdae5bb9b67afbbb75a5b7487908791e787d Mon Sep 17 00:00:00 2001
From: Michael Calmer 
Date: Fri, 15 Apr 2011 12:09:51 +0200
Subject: [PATCH 12/13] build rhnmd on SUSE

- add init script for SUSE
- BuildRequire sysconfig to make chkconfig work during build in OBS
- openssh-server does not exist on SUSE (part of openssh)
- no keygen in %post to use it in appliances
- create nocpulse user in a different way to make hime work on SUSE
  with openssh
---
 monitoring/rhnmd/rhnmd.init.SUSE |  107 ++
 monitoring/rhnmd/rhnmd.spec  |   21 +++-
 2 files changed, 127 insertions(+), 1 deletions(-)
 create mode 100644 monitoring/rhnmd/rhnmd.init.SUSE

diff --git a/monitoring/rhnmd/rhnmd.init.SUSE b/monitoring/rhnmd/rhnmd.init.SUSE
new file mode 100644
index 000..a1662f6
--- /dev/null
+++ b/monitoring/rhnmd/rhnmd.init.SUSE
@@ -0,0 +1,107 @@
+#!/bin/bash
+#
+# Init file for rhnmd daemon
+#
+# chkconfig: 2345 99 1
+# description: rhnmd server daemon
+#
+# processname: rhnmd
+
+### BEGIN INIT INFO
+# Provides: rhnmd
+# Required-Start: $local_fs $network $remote_fs
+# Required-Stop: $local_fs $network $remote_fs
+# Default-Start: 3 5
+# Default-Stop: 0 1 6
+# Short-Description: rhnmd server daemon
+# Description: Provides wrapper around sshd
+#   so NOCpulse monitoring can connect to your machine
+#   and run probes, which requires local account.
+### END INIT INFO
+
+# source function library
+. /etc/rc.status
+
+prog="rhnmd"
+
+# Some functions to make the below more readable
+SU="/bin/su -s /bin/bash - nocpulse -c"
+SSHD="/usr/sbin/rhnmd"
+SSHD_PIDFILE="/var/run/rhnmd.pid"
+
+do_restart_sanity_check()
+{
+	$SU "$SSHD -t -f /etc/nocpulse/rhnmd_config"
+	RETVAL=$?
+	if [ ! "$RETVAL" = 0 ]; then
+		rc_failed
+		echo "Configuration file or keys are invalid"
+	fi
+}
+
+start()
+{
+	echo -n $"Starting $prog:"
+	IDENTITY="/var/lib/nocpulse/.ssh/nocpulse-identity"
+	if [ ! -f "$IDENTITY" ]
+	then
+		/bin/su -s /bin/bash -c "/usr/bin/ssh-keygen -q -t dsa -N '' -f $IDENTITY" - nocpulse
+		if [ ! -e "/var/lib/nocpulse/.bashrc" ]; then
+			echo 'LANG="C"' > /var/lib/nocpulse/.bashrc
+		fi
+	fi
+	startproc -p $SSHD_PIDFILE $SSHD -f /etc/nocpulse/rhnmd_config -o "PidFile=$SSHD_PIDFILE"
+	rc_status
+	touch /var/lock/subsys/rhnmd
+	rc_status -v
+}
+
+stop()
+{
+	echo -n $"Stopping $prog:"
+	rm -f /var/lock/subsys/rhnmd
+	killproc -p $SSHD_PIDFILE -TERM $SSHD
+rc_status -v
+}
+
+reload()
+{
+	echo -n $"Reloading $prog:"
+	killproc -p $SSHD_PIDFILE -HUP $SSHD
+	rc_status -v
+}
+
+case "$1" in
+	start)
+		start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		stop
+		start
+		;;
+	reload)
+		reload
+		;;
+	condrestart|try-restart)
+		if [ -f /var/lock/subsys/rhnmd ] ; then
+			do_restart_sanity_check
+			if [ "$RETVAL" = 0 ] ; then
+stop
+# avoid race
+sleep 3
+start
+			fi
+		fi
+		;;
+	status)
+	echo -n "Checking for service rhnmd: "
+		checkproc -p $SSHD_PIDFILE $SSHD
+		rc_status -v
+		;;
+	*)
+		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
+esac
+rc_exit
diff --git a/monitoring/rhnmd/rhnmd.spec b/monitoring/rhnmd/rhnmd.spec
index 6779bb5..93f85bb 100644
--- a/monitoring/rhnmd/rhnmd.spec
+++ b/monitoring/rhnmd/rhnmd.spec
@@ -14,7 +14,13 @@ License:GPLv2
 BuildArch:  noarch
 Group:  System Environment/Daemons
 BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires:   openssh-server openssh
+Requires:   openssh
+%if 0%{?suse_version}
+# make chkconfig work d

[Spacewalk-devel] [PATCH] build rhnmd on openSUSE

2011-04-08 Thread Michael Calmer
Hi,

here is a patch to build rhnmd on openSUSE.

0014-build-rhnmd-on-SUSE.patch
- modify the specfile
- add init script for openSUSE

For SUSE I have removed the ssh key generation from the %post section.
I added the generation into the SUSE init script. 
The reason for this is, that if you do it in %post and use this RPM in an 
appliance, you have the same ssh key on all copies of your appliance.

Maybe you are interrested to do this also for RedHat / Fedora. 

-- 
Regards,

Michael Calmer

--
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
From 4122bb4df08db847813f13fc53f37ef76568f749 Mon Sep 17 00:00:00 2001
From: Michael Calmer 
Date: Wed, 6 Apr 2011 12:24:08 +0200
Subject: [PATCH 14/17] build rhnmd on SUSE

- modify the specfile
- add init script for SUSE
---
 monitoring/rhnmd/rhnmd.init.SUSE |  107 ++
 monitoring/rhnmd/rhnmd.spec  |   21 +++-
 2 files changed, 127 insertions(+), 1 deletions(-)
 create mode 100644 monitoring/rhnmd/rhnmd.init.SUSE

diff --git a/monitoring/rhnmd/rhnmd.init.SUSE b/monitoring/rhnmd/rhnmd.init.SUSE
new file mode 100644
index 000..a77edff
--- /dev/null
+++ b/monitoring/rhnmd/rhnmd.init.SUSE
@@ -0,0 +1,107 @@
+#!/bin/bash
+#
+# Init file for rhnmd daemon
+#
+# chkconfig: 2345 99 1
+# description: rhnmd server daemon
+#
+# processname: rhnmd
+
+### BEGIN INIT INFO
+# Provides: rhnmd
+# Required-Start: $local_fs $network $remote_fs
+# Required-Stop: $local_fs $network $remote_fs
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: rhnmd server daemon
+# Description: Provides wrapper around sshd
+#   so NOCpulse monitoring can connect to your machine
+#   and run probes, which requires local account.
+### END INIT INFO
+
+# source function library
+. /etc/rc.status
+
+prog="rhnmd"
+
+# Some functions to make the below more readable
+SU="/bin/su -s /bin/bash - nocpulse -c"
+SSHD="/usr/sbin/rhnmd"
+SSHD_PIDFILE="/var/run/rhnmd.pid"
+
+do_restart_sanity_check()
+{
+	$SU "$SSHD -t -f /etc/nocpulse/rhnmd_config"
+	RETVAL=$?
+	if [ ! "$RETVAL" = 0 ]; then
+		rc_failed
+		echo "Configuration file or keys are invalid"
+	fi
+}
+
+start()
+{
+	echo -n $"Starting $prog:"
+	IDENTITY="/var/lib/nocpulse/.ssh/nocpulse-identity"
+	if [ ! -f "$IDENTITY" ]
+	then
+		/bin/su -s /bin/bash -c "/usr/bin/ssh-keygen -q -t dsa -N '' -f $IDENTITY" - nocpulse
+		if [ ! -e "/var/lib/nocpulse/.bashrc" ]; then
+			echo 'LANG="C"' > /var/lib/nocpulse/.bashrc
+		fi
+	fi
+	startproc -p $SSHD_PIDFILE $SSHD -f /etc/nocpulse/rhnmd_config -o "PidFile=$SSHD_PIDFILE"
+	rc_status
+	touch /var/lock/subsys/rhnmd
+	rc_status -v
+}
+
+stop()
+{
+	echo -n $"Stopping $prog:"
+	rm -f /var/lock/subsys/rhnmd
+	killproc -p $SSHD_PIDFILE -TERM $SSHD
+rc_status -v
+}
+
+reload()
+{
+	echo -n $"Reloading $prog:"
+	killproc -p $SSHD_PIDFILE -HUP $SSHD
+	rc_status -v
+}
+
+case "$1" in
+	start)
+		start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		stop
+		start
+		;;
+	reload)
+		reload
+		;;
+	condrestart|try-restart)
+		if [ -f /var/lock/subsys/rhnmd ] ; then
+			do_restart_sanity_check
+			if [ "$RETVAL" = 0 ] ; then
+stop
+# avoid race
+sleep 3
+start
+			fi
+		fi
+		;;
+	status)
+	echo -n "Checking for service rhnmd: "
+		checkproc -p $SSHD_PIDFILE $SSHD
+		rc_status -v
+		;;
+	*)
+		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
+esac
+rc_exit
diff --git a/monitoring/rhnmd/rhnmd.spec b/monitoring/rhnmd/rhnmd.spec
index 6779bb5..66fcc1f 100644
--- a/monitoring/rhnmd/rhnmd.spec
+++ b/monitoring/rhnmd/rhnmd.spec
@@ -14,7 +14,12 @@ License:GPLv2
 BuildArch:  noarch
 Group:  System Environment/Daemons
 BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires:   openssh-server openssh
+Requires:   openssh
+%if 0%{?suse_version}
+BuildRequires:  openssh sysconfig
+%else
+Requires:   openssh-server
+%endif
 BuildRequires:  pam-devel
 Obsoletes:  rhnmd.i386 < 5.3.0-5
 Obsoletes:  rhnmd.x86_64 < 5.3.0-5
@@ -42,7 +47,11 @@ mkdir -p $RPM_BUILD_ROOT%{_var}/lib/%{np_name}/.ssh
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pam.d
 mkdir -p $RPM_BUILD_ROOT%{_libdir}
 ln -sf sshd $RPM_BUILD_ROOT%{_usr}/sbin/rhnmd
+%if 0%{?suse_version}
+install -pm 0755 rhnmd.init.SUSE $RPM_BUILD_ROOT%{_initddir}/rhnmd
+%else
 install -pm 0755 rhnmd-init $RPM_BUILD_ROOT%{_initddir}/rhnmd
+%endif
 install -pm 0644 rhnmd_config $RPM_BUILD_ROOT%{_sysconfdir}/%{np_name}/rhnmd_config
 install -pm 0600 authorized_keys $RPM_BUILD_ROOT%{_var}/lib/%{np_name}/.ssh/authorized_keys
 install -pm 0644 rhnmd-pam_config $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/rhnmd
@@ -50,9