linux:script_pout_transformer_un_programme_en_service
#!/bin/sh
# le nom du service
SERVICE_NAME=Liferay
# le répertoire où se trouvent les exécutables du service
SERVICE_DIRECTORY=/opt/Portal/bin
# le nom du script de démarrage du service
SERVICE_STARTUP_SCRIPT=startup.sh
# le nom du script d'arrêt du service
SERVICE_SHUTDOWN_SCRIPT=shutdown.sh
usage()
{
echo "-----------------------"
echo "Usage: $0 (stop|start|restart)"
echo "-----------------------"
}
if [ -z $1 ]; then
usage
fi
service_start()
{
echo "Starting service '${SERVICE_NAME}'..."
OWD=`pwd`
cd ${SERVICE_DIRECTORY} && ./${SERVICE_STARTUP_SCRIPT}
cd $OWD
echo "Service '${SERVICE_NAME}' started successfully"
}
service_stop()
{
echo "Stopping service '${SERVICE_NAME}'..."
OWD=`pwd`
cd ${SERVICE_DIRECTORY} && ./${SERVICE_SHUTDOWN_SCRIPT}
cd $OWD
echo "Service '${SERVICE_NAME}' stopped"
}
case $1 in
stop)
service_stop
;;
start)
service_start
;;
restart)
service_stop
service_start
;;
*)
usage
esac
exit 0
linux/script_pout_transformer_un_programme_en_service.txt · Dernière modification: 2019/01/25 15:56 (modification externe)