Jean-Francois Dive wrote:
Tu as le classique inittab qui te permet de lancer une application vers
une console, mais ca sera lanc� en tant que root.
pas si tu lances un script qui fait un su

cat <<EOF > /etc/rc.boot/startop
#!/bin/sh
su -user -c "nice /usr/bin/top > /dev/tty2
EOF
hmm... faut pas un & ?

su -user -c "nice /usr/bin/top > /dev/tty2 &

chmod +x /etc/rc.boot/startop
/etc/rc.boot/startop
Sur SuSE/LSB, ce serait:

--8<------[/etc/init.d/boot.top]----------------------------
#!/bin/bash
### BEGIN INIT INFO
# Provides:		boot.top
# Required-Start:	boot.proc
# Required-Stop:
# Default-Start:	B
# Default-Stop:
# Description:		Starts a "top" console
### END INIT INFO
. /etc/rc.status
. /etc/rc.config

rc_reset

PIDFILE=/var/run/topconsole.pid
RUNAS_USER=nobody
NICE_LEVEL=18
CONSOLE_DEVICE=/dev/tty2

case "$1" in
  start)
	startproc \
	   -n "$NICE_LEVEL" \
	   -p "$PIDFILE" \
	   -u "$RUNAS_USER" \
           /usr/bin/top >$CONSOLE_DEVICE
	rc_status -v
	;;
  stop)
	killproc -p "$PIDFILE" /usr/bin/top
	rc_status -v
	;;
  restart)
	$0 stop
	$0 start
  status)
	checkproc -p "$PIDFILE" /usr/bin/top
	rc_status -v
	;;
  *)
	echo "Usage: $0 {start|stop|restart|status}"
	exit 1
	;;
esac
--8<------[/etc/init.d/boot.top]----------------------------

Evidemment:
chmod +x /etc/init.d/boot.top

Ensuite, pour activer le service:

chkconfig -a boot.top

Je n'ai pas test� �a, mais �a devrait marcher...

Au moins, c'est conforme � la LSB (Linux Standard Base) ;-)

--
  -o) Pascal Bleser  http://guru.unixtech.be |
  /\\              <[EMAIL PROTECTED]> |
 _\_v <[EMAIL PROTECTED]>                     |
---------------------------------------------|
Jesus saves,Buddha makes incremental backups :
---------------------------------------------'

_______________________________________________________
Linux Mailing List - http://www.unixtech.be
Subscribe/Unsubscribe: http://www.unixtech.be/mailman/listinfo/linux
Archives: http://www.mail-archive.com/[email protected]
IRC: efnet.unixtech.be:6667 - #unixtech

Répondre à