Pagina 1 di 1

script di avvio da debian/inet.d a Slackware/rc.d

Inviato: mer 4 nov 2009, 7:20
da freax
mettendo su Fuppes va tutto ok , compilato da sorgente , installato , funziona , è ok , il problema è seguire questo tutorial non proprio pensato per rc.d

http://fuppes.ulrich-voelkel.de/wiki/in ... ith_Init.d

anche non avendo esperienza con gli script di avvio ho provato ad abbozzare il cambiamento più semplice e naturale ovvero da init.d a rc.d cambiando il valore delle variabili di conseguenza

Codice: Seleziona tutto

#! /bin/sh
### BEGIN INIT INFO
# Provides:          fuppesd
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: UPnP Media Server
# Description:       Fuppes UPnP media server.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DESC="UPnP Media Server"
NAME=fuppesd
DAEMON=`which $NAME`
DAEMON_ARGS="--config-dir /etc/fuppes/ --database-file 
/var/lib/fuppes/fuppes.db --log-level 1"
SCRIPTNAME=/etc/rc.d/rc.$NAME
FUPPES_USER=fuppes
FUPPES_GROUP=fuppes

# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
{
        echo "Couldn't find $DAEMON"
        exit 99
}
fi

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
	# Return
	#   0 if daemon has been started
	#   1 if daemon was already running
	#   2 if daemon could not be started
	start-stop-daemon --start --quiet --chuid 
$FUPPES_USER:$FUPPES_GROUP --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --chuid 
$FUPPES_USER:$FUPPES_GROUP --exec $DAEMON -- $DAEMON_ARGS \
		|| return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
	# Return
	#   0 if daemon has been stopped
	#   1 if daemon was already stopped
	#   2 if daemon could not be stopped
	#   other if a failure occurred
	start-stop-daemon --stop --signal 2 --retry 5 --quiet --name 
$NAME
	RETVAL="$?"
	[ "$RETVAL" = 2 ] && return 2
	return "$RETVAL"
}

case "$1" in
  start)
	log_daemon_messaggio "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0|1) log_end_messaggio 0 ;;
		2) log_end_messaggio 1 ;;
	esac
	;;
  stop)
	log_daemon_messaggio "Stopping $DESC" "$NAME"
	do_stop
	case "$?" in
		0|1) log_end_messaggio 0 ;;
		2) log_end_messaggio 1 ;;
	esac
	;;
  restart|force-reload)
	log_daemon_messaggio "Restarting $DESC" "$NAME"
	do_stop
	case "$?" in
	  0|1)
		do_start
		case "$?" in
			0) log_end_messaggio 0 ;;
			1) log_end_messaggio 1 ;; # Old process is still 
running
			*) log_end_messaggio 1 ;; # Failed to start
		esac
		;;
	  *)
	  	# Failed to stop
		log_end_messaggio 1
		;;
	esac
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac

:
salta all'occhio questo

Codice: Seleziona tutto

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
che non ho ben capito cosa sia e di conseguenza a cosa serva e soprattutto come si possa sostituire in Slackware .

PS
lo script di avvio è posizionato in /etc/rc.d/ con permessi di esecuzione e si chiama rc.fuppesd

Re: script di avvio da debian/inet.d a Slackware/rc.d

Inviato: mer 4 nov 2009, 8:15
da targzeta
Quello che ti serve è lsb-base, che esiste "pacchettizzato" per debian ma non sembra esistere per Slackware.

Emanuele

Re: script di avvio da debian/inet.d a Slackware/rc.d

Inviato: mer 4 nov 2009, 9:54
da fgcl2k
In Debian lsb-base contiene:

Codice: Seleziona tutto

$ dpkg -L lsb-base
/.
/etc
/etc/lsb-base
/usr
/usr/share
/usr/share/doc
/usr/share/doc/lsb-base
/usr/share/doc/lsb-base/changelog.Debian.gz
/usr/share/doc/lsb-base/README.Debian.gz
/usr/share/doc/lsb-base/copyright
/lib
/lib/lsb
/lib/lsb/init-functions
L'unico file "utile" è /lib/lsb/init-functions che contiene varie funzioni richiamate dagli init-script.

Re: script di avvio da debian/inet.d a Slackware/rc.d

Inviato: sab 7 nov 2009, 0:21
da freax
proverò ad usare lo script di Archlinux pubblicato nello stesso howto che usa rc.d e cerco di adattare quello allora .