Das Script sieht so aus:
Code: Alles auswählen
#!/bin/bash
INSTANZ="Beispiel-Programm"
BPDIR=/opt/programme/beispiel
Pidfile=/opt/programme/beispiel/bsp.pid
if [ -f $Pidfile ]
then
Pid=`cat $Pidfile`
fi
case "$1" in
'start')
if [ -f $Pidfile ] ; then
if test `ps -e | grep -c $Pid` = 1; then
echo "Not starting $INSTANZ - instance already running with PID: $Pid"
else
echo "Starting $INSTANZ"
cd $BPDIR
nohup ./bsp.sh &> /dev/null &
echo $! > $Pidfile
fi
else
echo "Starting $INSTANZ"
cd $BPDIR
nohup ./bsp.sh &> /dev/null &
echo $! > $Pidfile
fi
;;
'stop')
if [ -f $Pidfile ] ; then
echo "stopping $INSTANZ"
kill -15 $Pid
else
echo "Cannot stop $INSTANZ - no Pidfile found!"
fi
;;
'restart')
$0 stop
sleep 5
$0 start
;;
'status')
if [ -f $Pidfile ] ; then
if test `ps -e | grep -c $Pid` = 0; then
echo "$INSTANZ not running"
else
echo "$INSTANZ running with PID: [$Pid]"
fi
else
echo "$Pidfile does not exist! Cannot process $INSTANZ status!"
exit 1
fi
;;
*)
echo "usage: $0 { start | stop | restart | status }"
;;
esac
exit 0
So habe ich gedacht aber wo ist nun der Fehler denn er startet nur die eine INSTANZ und das in ein und dem selben Terminal.
Code: Alles auswählen
#!/bin/bash
INSTANZ= cd /home/zeealtis2/arma3/game && wine arma3server.exe -config=/server.cfg -basic=/basic.cfg -mod="@Arma2NET;@life_server"
INSTANZ2=cd /home/zeealtis2/arma3/game/bec && wine Bec.exe
BPDIR=/home/zeealtis2/arma3/game
Pidfile=/home/zeealtis2/arma3/game/loas.pid
Pidfile2=/home/zeealtis3/arma3/game/loasb.pid
if [ -f $Pidfile ]
then
Pid=`cat $Pidfile`
fi
if [ -f $Pidfile2 ]
then
Pid2=`cat $Pidfile2`
fi
case "$1" in
'start')
if [ -f $Pidfile ] ; then
if test `ps -e | grep -c $Pid &&` = 1; then
echo "Not starting $INSTANZ - Server already running with PID: $Pid"
else
terminal -e
echo "Starting $INSTANZ Sever"
cd $BPDIR
nohup ./loas.sh &> /dev/null &
echo $! > $Pidfile
fi
else
terminal -e
echo "Starting $INSTANZ Server"
cd $BPDIR
nohup ./loas.sh &> /dev/null &
echo $! > $Pidfile
fi
if [ -f $Pidfile2 ] ; then
if test `ps -e | grep -c $Pid2 &&` = 1; then
echo "Not starting $INSTANZ2 - BEC already running with PID: $Pid"
else
terminal -e
echo "Starting $INSTANZ2 BEC"
cd $BPDIR
nohup ./loas.sh &> /dev/null &
echo $! > $Pidfile2
fi
else
terminal -e
echo "Starting $INSTANZ BEC"
cd $BPDIR
nohup ./loas.sh &> /dev/null &
echo $! > $Pidfile2
fi
;;
'stop')
if [ -f $Pidfile ] ; then
echo "Stopping $INSTANZ"
kill -15 $Pid
else
echo "Cannot stop $INSTANZ - no Pidfile found!"
fi
if [ -f $Pidfile2 ] ; then
echo "Stopping $INSTANZ2"
kill -15 $Pid2
else
echo "Cannot stop $INSTANZ2 - no Pidfile found!"
fi
;;
'restart')
$0 stop
sleep 5
$0 start
;;
'status')
if [ -f $Pidfile ] ; then
if test `ps -e | grep -c $Pid` = 0; then
echo "$INSTANZ Server not running"
else
echo "$INSTANZ Server running with PID: [$Pid]"
fi
else
echo "$Pidfile does not exist! Cannot process $INSTANZ Server status!"
exit 1
fi
if [ -f $Pidfile2 ] ; then
if test `ps -e | grep -c $Pid2` = 0; then
echo "$INSTANZ2 BEC not running"
else
echo "$INSTANZ2 BEC running with PID: [$Pid]"
fi
else
echo "$Pidfile2 does not exist! Cannot process $INSTANZ2 BEC status!"
exit 1
fi
;;
*)
echo "usage: $0 { start | stop | restart | status }"
;;
esac
exit 0