• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

SPEC

Hi,

wie kann ich denn mit einem RPM einen Daemon starten. Also ich habe einen Damon zum starten von Logsurfer geschrieben und möchte diesen mit meiner RPM automatisch im unlevel3 starten lassen.


Ausserdem möchte ich den DHCP nach der RPM installation aktivieren und den samba service.

Danke

iea
 
Das sollte eigentliche ohne Probleme über die %post Section gehen.
Du kannst folgendes probieren:
Code:
%post
# damit wird <service> beim booten automatisch gestartet
%{_sbindir}/chkconfig -s <service>

}-Tux-{
 
[Allgemein] runlevel scripte - Scripts selber erstellen
http://www.linux-club.de/viewtopic.php?t=16069

und hier die SuSE Spezifika:
http://forgeftp.novell.com//library/SUSE%20Package%20Conventions/spc.html

Kapitel 3 RPM-macros, dorst insserv* lesen

Code:
%post
%{fillup_and_insserv dein-init-script}

%preun
%stop_on_removal dein-init-script

%postun
%restart_on_update dein-init-script
%insserv_cleanup
 
OP
iea

iea

Hi,

danke funktioniert für dhcp wunderbar, nur startet mein DAEMON script nicht automatisch. Weder im boot noch rc3.d Modus?

Kann es sein das ich was falsch mache, also manuell kann ich rclogsurfer start eingeben und es funktioniert, doch im runlevel startet es nicht automatisch ? Woran kann das liegen

Ich habe auch mit insserv /etc/init.d/logserver,start=3 die s links hinzugefügt (erfolgreich)

Hier der CODE

Code:
#! /bin/sh
# /etc/init.d/logsurfer
#
#   and symbolic its link
#
# /usr/sbin/rclogsurfer
#
# System startup script for the logsurfer
#
### BEGIN INIT INFO
# Provides: logsurfer
# Required-Start: $network $syslog
# Required-Stop:  $network $syslog
# Default-Start:  3 5
# Default-Stop:
# Description:    Start logsurfer as daemon.
### END INIT INFO

# Source SuSE config
. /etc/rc.status

# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}

# Force execution if not called by a runlevel directory.
test $link = $base && START_LOGSURFER=yes
test "$START_LOGSURFER" = yes || exit 0

LOGSURFER_BIN=/usr/bin/logsurfer
LOGSURFER_ARGS="-l $(wc -l < /var/log/messages) \
               -f /var/log/messages -c /etc/logsurfer.conf"
test -x $LOGSURFER_BIN || exit 5

# 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_failed        set local and overall rc status to failed
#      rc_failed   set local and overall rc status to 
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /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 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

case "$1" in
    start)
	echo -n "Starting logsufer"
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.

	# NOTE: startproc return 0, even if service is 
	# already running to match LSB spec.
	startproc -s $LOGSURFER_BIN $LOGSURFER_ARGS 

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down logsurfer"
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killall -TERM $LOGSURFER_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    status)
	echo -n "Checking for logsufer: "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.

	# Status has a slightly different for the status command:
	# 0 - service running
	# 1 - service dead, but /var/run/  pid  file exists
	# 2 - service dead, but /var/lock/ lock file exists
	# 3 - service not running

	# NOTE: checkproc returns LSB compliant status values.
	checkproc $LOGSURFER_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status}"
	exit 1
	;;
esac
rc_exit
 
ein Blick in die /var/log/boot.msg sollte dir Aufschluss darüber geben, ob das runlevel -script aufgerufen wurde bzw ob es einen Fehler enthält.

beim booten: erscheint da eine Zeile: logsurfer .... done/failed/skipped ?
 
OP
iea

iea

Also die einzigen Zeilen in der logsurfer vorkommen, sind diese und aus denen werde ich nicht schlau.

<notice>start services (smbfs resmgr portmap logsurfer)
.
.
.
<notice>exit status of (smbfs resmgr portmap logsurfer) is (6 0 0 0)

Das problem wenn ich insserv /etc/init.d/logsurfer,start=3 mache kommt die Fehlermeldung

S08logsurfer
K14logsurfer sind beide in der /etc/init.d/rc3.d


Wenn ich den Service manuell hinzufügen möchte kommt die Meldung insserv exiting aber mit Yast geht es ???

Alles ein bissel komisch? Das Script stimmt doch... rc... start geht auch und stop und status auch
 
Code:
<notice>start services (smbfs resmgr portmap logsurfer)

<notice>exit status of (smbfs resmgr portmap logsurfer) is (6 0 0 0)

demnach wird logsurfer gestartet und liefert als Returncode eine 0. Also sieht das erstmal gut aus.

Bist du sicher das der logsurfer korrekt startet wenn du es mit rclogsurfer aufrufst ?
Lass dich von dem [DONE] nicht blenden! Kontrolliere mit
Code:
ps -ef | grep logsurf
ob er wirklich gestartet wurde ...
 
OP
iea

iea

Also ich weiss das er gestartet wird weil mein MAC Script danach funktioniert und vorher nicht.
 
OP
iea

iea

Erstmal wieder DANKE oc2pus :D ohne dich wäre ich oft aufgeschmissen...

Hier die Lösung falls es jemanden interessiert:

Irgendwie lag es an dem Script.

Code:
### BEGIN INIT INFO
# Provides:          logsurfer
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: logsurfer log analyser
### END INIT INFO

. /etc/rc.status
rc_reset

case "$1" in
    start)
        echo -n "Starting logsurfer "
        startproc /usr/bin/logsurfer -f /var/logsurfer.fifo
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down logsurfer "
        killproc -TERM /usr/bin/logsurfer
        rc_status -v
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac
rc_exit
 
oc2pus schrieb:
[und hier die SuSE Spezifika:
http://forgeftp.novell.com//library/SUSE%20Package%20Conventions/spc.html

Kapitel 3 RPM-macros, dorst insserv* lesen

Code:
%post
%{fillup_and_insserv dein-init-script}

%preun
%stop_on_removal dein-init-script

%postun
%restart_on_update dein-init-script
%insserv_cleanup
Arghs *kopfauftischschlag*
Wie bin ich blos auf chkconfig gekommen?! :roll: :oops:
 
Oben