bonjour,
je voudrais faire un script init.d et le problème est qu'il ne marche pas pour start, je n'ai pas encore fini de le programmer pour pour restart|reload etc ...
Voici le script complet
http://pastebin.com/f36a3b47c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
#
# init script for the ps3 media server for linux : pms-server
 
# Author: paissad
 
### BEGIN INIT INFO
# Provides:          pms-linux
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Media server for the playstation 3 
### END INIT INFO
 
# Author: Torsten Landschoff <torsten@debian.org>
 
NAME="pms-linux"
version="1.10.5"  # Version du logiciel 
DAEMON="/usr/bin/java"
OPTIONS="-jar /opt/$NAME/$NAME-$version/pms.jar"
DESC="Playstation 3 Media Server"
CONFIG_FILE="/etc/PMS.conf" # fichier de conf par défaut
CONFIG_DIR="`dirname "$CONFIG_FILE"`"
USERID="paissad"
PIDFILE="/var/run/$NAME.pid"
 
. /lib/lsb/init-functions
 
#set -x
 
# On vérifie que le fichier de conf PMS.conf est bien dans le repertoire /etc
if [ ! -e "$CONFIG_FILE" ]; then
	echo "Le fichier de configuration /etc/PMS.conf est inexistant !" 
	exit 1
fi
 
if [ ! -r "$CONFIG_FILE" ]; then
	echo "Le fichier de configuration PMS.conf n'est pas disponible en lecture !"
	exit 1
fi
 
is_running(){
	pid=`pgrep -f '^[^ ]*java .*-jar.*pms.jar'`
	if [ -n "$pid" ]; then
		return 1 # pms.jar tourne
	fi
	pid=0
	return 0 # pms.jar qui est le serveur est pas lancé, ni manuellment ni par le init.d
}
is_running
echo "pid -> $pid"
 
case "$1" in 
#--------------------------------------------------------------------------
	start)
	if [ ! $pid -eq 0 ]; then
		echo "pms-linux-server is already running !"
		exit 0
	fi
	log_daemon_msg "Starting $DESC : $NAME"
	echo
	#start-stop-daemon --start --quiet --background --chdir "$CONFIG_DIR" --exec $DAEMON $OPTIONS 
	start-stop-daemon --start --quiet --background --user "$USERID:$USERID" --chdir "$CONFIG_DIR" --exec $DAEMON $OPTIONS 
	echo "$pid" > $PIDFILE
	;;
#--------------------------------------------------------------------------
	stop)
	if [ $pid -eq 0 ]; then
		echo "pms-linux-server is not running !"
		exit 0
	fi
	log_daemon_msg "Stopping $DESC : $NAME"
	echo
	kill -9 $pid
	`rm -f "$PIDFILE"`
	;;
#--------------------------------------------------------------------------
	restart|reload|force-reload)
	log_daemon_msg "Restarting $DESC : $NAME"
	echo
	start-stop-daemon --stop --quiet --exec $DAEMON
	sleep 5
	start-stop-daemon --start --quiet --exec $DAEMON
	;;
#--------------------------------------------------------------------------
	status)
	if [ ! $pid -eq 0 ]; then
		echo "pms-linux-server is running ! (PID -> $pid)"
		exit 0
	fi
	echo "pms-linux-server is not running !"
	;;
#--------------------------------------------------------------------------
	*)
	echo "Usage: /etc/init.d/$NAME-server {start|stop|restart|reload|force-reload|status}"
	exit 1
#--------------------------------------------------------------------------
esac
 
exit 0
je l'ai testé pour stop et status, ça marche bien ...
mais il a fallu que je démarre manuellement le programme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
java -jar /opt/pms-linux/*/pms.jar
Si je le démarre manuellement en console, le programme voit bien qu'il y'a un PID existant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
paissad@paissad-server:/etc/init.d$ sudo ./pms-linux-server start
pid -> 5877
pms-linux-server is already running !
mais s'il n'y avait pas de PID existant et que je fait
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
paissad@paissad-server:/etc/init.d$ sudo ./pms-linux-server start
pid -> 0
Starting Playstation 3 Media Server : pms-linux:
start-stop-daemon: invalid option -- j
Try `start-stop-daemon --help' for more information.
paissad@paissad-server:/etc/init.d$
est ce que quelqu'un peut m'aider, j'ai bien lu le manuel de start-stop-daemon, mais bon .. et j'ai aussi regardé des examples sur le repertoire /etc/init.d mais je ne trouve pas la solution
et pourtant en console, ceci marche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
exec java -jar /opt/pms-linux/*/pms.jar
Merci d'avance pour votre aide