Strona 1 z 2

skrypt startowy i uruchamianie compiza

: 09 lutego 2009, 00:03
autor: milansport
Witam.
Mam pytanie dotyczące usług uruchamianych ze startem systemu. Chciałem aby ze startem uruchamiał się rtorrent i wykorzystałem do tego skrypt, który jest dostępny na stronie projektu.

Teraz chciałbym utworzyć coś podobnego dla compiza i nadać mu priorytet uruchamiania taki aby uruchamiał się przed innymi programami. Skorzystałem ze szkieletu znajdującego się tu:

Kod: Zaznacz cały

/etc/init.d/skeleton
no i zmieniłem:

Kod: Zaznacz cały

DESC="Description of the service"
NAME=daemonexecutablename
na:

Kod: Zaznacz cały

DESC="fusion-icon"
NAME=fusion-icon
Cały skrypt wygląda teraz tak:

Kod: Zaznacz cały

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="fusion-icon"
NAME=fusion-icon
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--options args"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# 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 --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
		$DAEMON_ARGS \
		|| return 2
	# Add code here, if necessary, that waits for the process to be ready
	# to handle requests from services started subsequently which depend
	# on this one.  As a last resort, sleep for some time.
}

#
# 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 --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
	RETVAL="$?"
	[ "$RETVAL" = 2 ] && return 2
	# Wait for children to finish too if this is a daemon that forks
	# and if the daemon is only ever run from this initscript.
	# If the above conditions are not satisfied then add some other code
	# that waits for the process to drop all resources that could be
	# needed by services started subsequently.  A last resort is to
	# sleep for some time.
	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
	[ "$?" = 2 ] && return 2
	# Many daemons don't delete their pidfiles when they exit.
	rm -f $PIDFILE
	return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
	#
	# If the daemon can reload its configuration without
	# restarting (for example, when it is sent a SIGHUP),
	# then implement that here.
	#
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
	return 0
}

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	do_stop
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  #reload|force-reload)
	#
	# If do_reload() is not implemented then leave this commented out
	# and leave 'force-reload' as an alias for 'restart'.
	#
	#log_daemon_msg "Reloading $DESC" "$NAME"
	#do_reload
	#log_end_msg $?
	#;;
  restart|force-reload)
	#
	# If the "reload" option is implemented then remove the
	# 'force-reload' alias
	#
	log_daemon_msg "Restarting $DESC" "$NAME"
	do_stop
	case "$?" in
	  0|1)
		do_start
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ;; # Old process is still running
			*) log_end_msg 1 ;; # Failed to start
		esac
		;;
	  *)
	  	# Failed to stop
		log_end_msg 1
		;;
	esac
	;;
  *)
	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac

:
Zapisałem go jako:

Kod: Zaznacz cały

/etc/init.d/fusion-icon
Wykonałem:

Kod: Zaznacz cały

chmod +x fusion-icon
Nastepnie:

Kod: Zaznacz cały

update-rc.d fusion-icon defaults 19
i podczas startu compiz się nie uruchamia.
Co robię źle?
Pozdrawiam!

: 09 lutego 2009, 03:05
autor: fnmirk
milansport pisze:Co robię źle?
Nie przeglądasz forum. Było o tym wielokrotnie w wielu tematach.

: 09 lutego 2009, 12:46
autor: milansport
Wierz mi, że nie napisałbym tego posta gdybym wcześniej nie użył wyszukiwarki.
Szukałem i nie znalazłem odpowiedzi na moje pytanie.

Pozdrawiam.

: 09 lutego 2009, 12:50
autor: fnmirk

: 09 lutego 2009, 12:57
autor: milansport
Tego nawet nie musialem szukac poniewaz wiem, ze tak mozna ale to nie jest rozwiazanie mojego problemu poniewaz chcialbym nadac compizowi wyzszy priorytet uruchamiania tak by uruchamial sie przed innymi programami.

: 09 lutego 2009, 14:35
autor: lis6502
update-rc.d fusion-icon defaults 19
Im niższy numer, tym większy priorytet. Nie wiem tylko czy będzie sens uruchamiać Compiza przed zalogowaniem się do środowiska. Wydaje mi się, że taki skrypt powinien raczej się znaleźć w odpowiednim xinitrc, albo jako plik samouruchamiający się po wczytaniu środowiska.

: 09 lutego 2009, 15:54
autor: milansport
lis6502 pisze:Im niższy numer, tym większy priorytet. Nie wiem tylko czy będzie sens uruchamiać Compiza przed zalogowaniem się do środowiska
Na razie mam w ogóle problem z działaniem tego skryptu bo czy dam:

Kod: Zaznacz cały

update-rc.d fusion-icon defaults 19
czy:

Kod: Zaznacz cały

update-rc.d fusion-icon defaults 20
czy nawet:

Kod: Zaznacz cały

update-rc.d fusion-icon defaults 99
to i tak fusion-icon się nie włącza przy starcie.

: 09 lutego 2009, 16:31
autor: fnmirk
milansport pisze:to i tak fusion-icon się nie włącza przy starcie.
Według mnie odpowiedź masz w prostym wyświetleniu wymagań wynikających z zależności pakietu:

Kod: Zaznacz cały

apt-cache depends fusion-icon
fusion-icon
  Wymaga: python
  Wymaga: python-central
 |Wymaga: python-gtk2
  Wymaga: python-qt4
  Wymaga: python-compizconfig
  Wymaga: x11-utils
  Wymaga: mesa-utils
 |Wymaga: compiz-gtk
 |Wymaga: compiz-kde
  Wymaga: compiz-gnome

: 09 lutego 2009, 17:01
autor: milansport
Tyle, że kiedy wpiszę w terminalu fusion-icon to wszystko elegancko działa więc wygląda na to, że zależności są spełnione.

: 09 lutego 2009, 17:12
autor: lis6502
lis6502 pisze:Nie wiem tylko czy będzie sens uruchamiać Compiza przed zalogowaniem się do środowiska
Compiz to manager okienkowania (nie wiem jak napisać sensownie :-P). W każdym razie zastępuje on metacity (compiz-real --replace). Wpisujesz w terminalu, zgoda, ale po załadowaniu się środowiska. Poszukaj informacji na temat autouruchamiania w swoim środowisku i tam wrzuć skrypt. Oczywiście nie w wersji /etc/init.d.