CONFIGURATION : service n'indique aucune sortie sur terminal

Bonjour, il y a quelques temps, j’utilisait quotidiennement la commande service affin de démarrer ou d’arrêter des services custom tel que des serveurs de jeux ou serveurs vocaux.

Je suis actuellement sur Debian Sid (pas d’environnement de bureau), hébergé chez OVH.

Le probleme principal et qui est vraiment frustrant c’est que quoi que je fasse, il ne me fait aucune sortie sur le terminal m’indiquant le status du service quand je fait une commande comme :

Sur un autre serveur sur Ubuntu Trusty, j’ai au contraire une sortie m’indiquant que le service s’est bien arrété et démarré (ou qu’il n’a pas pus se démarrer)

Enfin j’ai fini par remarquer que sur mes 2 ordinateurs personnel (l’un sur Debian Sid avec lxde et l’autre sur Crunchbang Waldorf) que cela réagissait de la même manière, ils ne font aucune sortie lors de ces commandes.

Y a t’il un moyen de configurer systemd (il me semble que c’est lui qui a la charge de gérer les services) affin qu’il fasse une sortie sur le terminal.

[moderation]Merci de lire les “Règles d’usage …” en ce qui concerne la présentation du titre[/moderation]

apache2 n’est pas installé sur ma machine, mais le principe est le même pour les autres services

root@debG53SW:~# service exim4 Usage: /etc/init.d/exim4 {start|stop|restart|reload|status|what|force-stop} root@debG53SW:~# /etc/init.d/exim4 status [ ok ] checking separate queue runner daemon...done (not running). [ ok ] checking combined SMTP listener and queue runner daemon...done (running). root@debG53SW:~# Donc, en fonction des fonctions définies dans le script [mono]/etc/init.d/apache2[/mono], la commande recherchée est peut-être :

ou peut être aussi:

[quote=“MicP”]apache2 n’est pas installé sur ma machine, mais le principe est le même pour les autres services

root@debG53SW:~# service exim4 Usage: /etc/init.d/exim4 {start|stop|restart|reload|status|what|force-stop} root@debG53SW:~# /etc/init.d/exim4 status [ ok ] checking separate queue runner daemon...done (not running). [ ok ] checking combined SMTP listener and queue runner daemon...done (running). root@debG53SW:~# Donc, en fonction des fonctions définies dans le script [mono]/etc/init.d/apache2[/mono], la commande recherchée est peut-être :

Je sait parfaitement que l’on peut utiliser /etc/init.d/apache2 status, mais je demande a savoir si l’on peut plutot configurer la commande service affin qu’elle donne une sortie sur terminal car je trouve cela plus propre.

Désolé, je n’ai visiblement pas compris la question. :blush:

De plus, j’utilise wheezy, et comme je crois que les services ne sont pas lancés de la même manière…

Salut!
Peux-tu donner le résultat de la commande

Merci.

[quote=“ben_raven”]Salut!
Peux-tu donner le résultat de la commande

Merci.[/quote]

Merci pour ta réponse, je pense que c’est celle qui me donne l’une des meilleures piste, je vait voir les différences qu’il y a entre le /usr/sbin/service d’ubuntu et celui de debian, voir tout d’abord si je peut configurer la moindre chose et par la suite si je peut finalement le modifier (tout en gardant une copie par securité) affin qu’il afin une sortie. Toutefois ce n’est pas encore fini.

En tout cas il y a une chose dont je suis sur, j’utilise systemd.

Je met quand même le contenu de /usr/sbin/service :

[code]#!/bin/sh

###########################################################################

/usr/bin/service

A convenient wrapper for the /etc/init.d init scripts.

This script is a modified version of the /sbin/service utility found on

Red Hat/Fedora systems (licensed GPLv2+).

Copyright © 2006 Red Hat, Inc. All rights reserved.

Copyright © 2008 Canonical Ltd.

* August 2008 - Dustin Kirkland kirkland@canonical.com

Copyright © 2013 Michael Stapelberg stapelberg@debian.org

This program is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

On Debian GNU/Linux systems, the complete text of the GNU General

Public License can be found in `/usr/share/common-licenses/GPL-2’.

###########################################################################

is_ignored_file() {
case “$1” in
skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
return 0
;;
esac
return 1
}

VERSION="basename $0 ver. 0.91-ubuntu1"
USAGE="Usage: basename $0 < option > | --status-all |
[ service_name [ command | --full-restart ] ]“
SERVICE=
ACTION=
SERVICEDIR=”/etc/init.d"
OPTIONS=
is_systemd=

if [ $# -eq 0 ]; then
echo “${USAGE}” >&2
exit 1
fi

if [ -d /run/systemd/system ]; then
is_systemd=1
fi

cd /
while [ $# -gt 0 ]; do
case “${1}” in
–help | -h | --h* )
echo “${USAGE}” >&2
exit 0
;;
–version | -V )
echo “${VERSION}” >&2
exit 0
;;
*)
if [ -z “${SERVICE}” -a $# -eq 1 -a “${1}” = “–status-all” ]; then
cd ${SERVICEDIR}
for SERVICE in * ; do
case “${SERVICE}” in
functions | halt | killall | single| linuxconf| kudzu)
;;
*)
if ! is_ignored_file “${SERVICE}”
&& [ -x “${SERVICEDIR}/${SERVICE}” ]; then
out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” status 2>&1)
retval=$?
if echo “$out” | egrep -iq “usage:”; then
#printf " %s %-60s %s\n" “[?]” “$SERVICE:” “unknown” 1>&2
echo " [ ? ] $SERVICE" 1>&2
continue
else
if [ “$retval” = “0” -a -n “$out” ]; then
#printf " %s %-60s %s\n" “[+]” “$SERVICE:” “running"
echo " [ + ] $SERVICE"
continue
else
#printf " %s %-60s %s\n” “[-]” “$SERVICE:” “NOT running"
echo " [ - ] $SERVICE"
continue
fi
fi
#env -i LANG=”$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” status
fi
;;
esac
done
exit 0
elif [ $# -eq 2 -a “${2}” = “–full-restart” ]; then
SERVICE="${1}"
# On systems using systemd, we just perform a normal restart:
# A restart with systemd is already a full restart.
if [ -n “$is_systemd” ]; then
ACTION=“restart"
else
if [ -x “${SERVICEDIR}/${SERVICE}” ]; then
env -i LANG=”$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” stop
env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” start
exit $?
fi
fi
elif [ -z “${SERVICE}” ]; then
SERVICE="${1}“
elif [ -z “${ACTION}” ]; then
ACTION=”${1}“
else
OPTIONS=”${OPTIONS} ${1}"
fi
shift
;;
esac
done

if [ -r “/etc/init/${SERVICE}.conf” ] && which initctl >/dev/null
&& initctl version 2>/dev/null | grep -q upstart
then

Upstart configuration exists for this job and we’re running on upstart

case “${ACTION}” in
start|stop|status|reload)
# Action is a valid upstart action
exec ${ACTION} ${SERVICE} ${OPTIONS}
;;
restart)
# Map restart to the usual sysvinit behavior.
stop ${SERVICE} ${OPTIONS} || :
exec start ${SERVICE} ${OPTIONS}
;;
force-reload)
# Upstart just uses reload for force-reload
exec reload ${SERVICE} ${OPTIONS}
;;
esac
fi

run_via_sysvinit() {

Otherwise, use the traditional sysvinit

if [ -x “${SERVICEDIR}/${SERVICE}” ]; then
exec env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” ${ACTION} ${OPTIONS}
else
echo “${SERVICE}: unrecognized service” >&2
exit 1
fi
}

update_openrc_started_symlinks() {

maintain the symlinks of /run/openrc/started so that

rc-status works with the service command as well

if [ -d /run/openrc/started ] ; then
case “${ACTION}” in
start)
if [ ! -h /run/openrc/started/$SERVICE ] ; then
ln -s $SERVICEDIR/$SERVICE /run/openrc/started/$SERVICE || true
fi
;;
stop)
rm /run/openrc/started/$SERVICE || true
;;
esac
fi
}

When this machine is running systemd, standard service calls are turned into

systemctl calls.

if [ -n “$is_systemd” ]
then
UNIT="${SERVICE%.sh}.service"
case “${ACTION}” in
restart|status)
exec systemctl ${ACTION} ${UNIT}
;;
start|stop)
# Follow the principle of least surprise for SysV people:
# When running “service foo stop” and foo happens to be a service that
# has one or more .socket files, we also stop the .socket units.
# Users who need more control will use systemctl directly.
for unit in $(systemctl list-unit-files --full --type=socket 2>/dev/null | sed -ne ‘s/.socket\s*[a-z]\s$/.socket/p’); do
if [ “$(systemctl -p Triggers show $unit)” = “Triggers=${UNIT}” ]; then
systemctl ${ACTION} $unit
fi
done
exec systemctl ${ACTION} ${UNIT}
;;
reload)
_canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
if [ “$_canreload” = “CanReload=no” ]; then
# The reload action falls back to the sysv init script just in case
# the systemd service file does not (yet) support reload for a
# specific service.
run_via_sysvinit
else
exec systemctl reload "${UNIT}“
fi
;;
force-stop)
exec systemctl --signal=KILL kill “${UNIT}”
;;
force-reload)
_canreload=”$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
if [ “$_canreload” = “CanReload=no” ]; then
exec systemctl restart "${UNIT}"
else
exec systemctl reload "${UNIT}"
fi
;;
*)
# We try to run non-standard actions by running
# the init script directly.
run_via_sysvinit
;;
esac
fi

update_openrc_started_symlinks
run_via_sysvinit
[/code]

Bonjour,

Dans ce cas, on utilise [mono]systemctl[/mono]. Je suis quasiment sur que le service seul d’Ubuntu est en fait lié à [mono]systemctl status[/mono]. Exemple:

$ systemctl status ldm
● ldm.service - lightweight device mounter
   Loaded: loaded (/usr/local/lib/systemd/system/ldm.service; enabled)
   Active: active (running) since lun. 2014-09-22 04:51:27 BST; 30min ago
 Main PID: 1079 (ldm)
       CGroup: /system.slice/ldm.service
           └─1079 /usr/local/bin/ldm -u 1000 -g 1000 -p /media

Le point en couleur c’est nouveau tient :033 :030

@MicP: “service status|restart|reload|etc”, marche tout de meme avec systemd sous sid SAUF enable/disable, qui sont les equivalents de update-rc.d, qui sont eux propre à systemd, et sûrement d’autres. Perso service j’ai oublié, ça m’évite de me tromper et je n’utilise plus que systemctl.

[size=50](je remercie l’OP qui m’a fait voir que j’ai changé l’heure dans le bios mais pas remis le fuseau horaire exact XD)[/size]

bonjour,
une petite lecture:

wiki.archlinux.fr/Systemd
A+
JB1
:033 :030

[quote=“Y.Petremann”][quote=“ben_raven”]Salut!
Peux-tu donner le résultat de la commande

Merci.[/quote]

Merci pour ta réponse, je pense que c’est celle qui me donne l’une des meilleures piste, je vait voir les différences qu’il y a entre le /usr/sbin/service d’ubuntu et celui de debian, voir tout d’abord si je peut configurer la moindre chose et par la suite si je peut finalement le modifier (tout en gardant une copie par securité) affin qu’il afin une sortie. Toutefois ce n’est pas encore fini.

En tout cas il y a une chose dont je suis sur, j’utilise systemd.

Je met quand même le contenu de /usr/sbin/service :

[code]#!/bin/sh

###########################################################################

/usr/bin/service

A convenient wrapper for the /etc/init.d init scripts.

This script is a modified version of the /sbin/service utility found on

Red Hat/Fedora systems (licensed GPLv2+).

Copyright © 2006 Red Hat, Inc. All rights reserved.

Copyright © 2008 Canonical Ltd.

* August 2008 - Dustin Kirkland kirkland@canonical.com

Copyright © 2013 Michael Stapelberg stapelberg@debian.org

This program is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

On Debian GNU/Linux systems, the complete text of the GNU General

Public License can be found in `/usr/share/common-licenses/GPL-2’.

###########################################################################

is_ignored_file() {
case “$1” in
skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
return 0
;;
esac
return 1
}

VERSION="basename $0 ver. 0.91-ubuntu1"
USAGE="Usage: basename $0 < option > | --status-all |
[ service_name [ command | --full-restart ] ]“
SERVICE=
ACTION=
SERVICEDIR=”/etc/init.d"
OPTIONS=
is_systemd=

if [ $# -eq 0 ]; then
echo “${USAGE}” >&2
exit 1
fi

if [ -d /run/systemd/system ]; then
is_systemd=1
fi

cd /
while [ $# -gt 0 ]; do
case “${1}” in
–help | -h | --h* )
echo “${USAGE}” >&2
exit 0
;;
–version | -V )
echo “${VERSION}” >&2
exit 0
;;
*)
if [ -z “${SERVICE}” -a $# -eq 1 -a “${1}” = “–status-all” ]; then
cd ${SERVICEDIR}
for SERVICE in * ; do
case “${SERVICE}” in
functions | halt | killall | single| linuxconf| kudzu)
;;
*)
if ! is_ignored_file “${SERVICE}”
&& [ -x “${SERVICEDIR}/${SERVICE}” ]; then
out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” status 2>&1)
retval=$?
if echo “$out” | egrep -iq “usage:”; then
#printf " %s %-60s %s\n" “[?]” “$SERVICE:” “unknown” 1>&2
echo " [ ? ] $SERVICE" 1>&2
continue
else
if [ “$retval” = “0” -a -n “$out” ]; then
#printf " %s %-60s %s\n" “[+]” “$SERVICE:” “running"
echo " [ + ] $SERVICE"
continue
else
#printf " %s %-60s %s\n” “[-]” “$SERVICE:” “NOT running"
echo " [ - ] $SERVICE"
continue
fi
fi
#env -i LANG=”$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” status
fi
;;
esac
done
exit 0
elif [ $# -eq 2 -a “${2}” = “–full-restart” ]; then
SERVICE="${1}"
# On systems using systemd, we just perform a normal restart:
# A restart with systemd is already a full restart.
if [ -n “$is_systemd” ]; then
ACTION=“restart"
else
if [ -x “${SERVICEDIR}/${SERVICE}” ]; then
env -i LANG=”$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” stop
env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” start
exit $?
fi
fi
elif [ -z “${SERVICE}” ]; then
SERVICE="${1}“
elif [ -z “${ACTION}” ]; then
ACTION=”${1}“
else
OPTIONS=”${OPTIONS} ${1}"
fi
shift
;;
esac
done

if [ -r “/etc/init/${SERVICE}.conf” ] && which initctl >/dev/null
&& initctl version 2>/dev/null | grep -q upstart
then

Upstart configuration exists for this job and we’re running on upstart

case “${ACTION}” in
start|stop|status|reload)
# Action is a valid upstart action
exec ${ACTION} ${SERVICE} ${OPTIONS}
;;
restart)
# Map restart to the usual sysvinit behavior.
stop ${SERVICE} ${OPTIONS} || :
exec start ${SERVICE} ${OPTIONS}
;;
force-reload)
# Upstart just uses reload for force-reload
exec reload ${SERVICE} ${OPTIONS}
;;
esac
fi

run_via_sysvinit() {

Otherwise, use the traditional sysvinit

if [ -x “${SERVICEDIR}/${SERVICE}” ]; then
exec env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" “$SERVICEDIR/$SERVICE” ${ACTION} ${OPTIONS}
else
echo “${SERVICE}: unrecognized service” >&2
exit 1
fi
}

update_openrc_started_symlinks() {

maintain the symlinks of /run/openrc/started so that

rc-status works with the service command as well

if [ -d /run/openrc/started ] ; then
case “${ACTION}” in
start)
if [ ! -h /run/openrc/started/$SERVICE ] ; then
ln -s $SERVICEDIR/$SERVICE /run/openrc/started/$SERVICE || true
fi
;;
stop)
rm /run/openrc/started/$SERVICE || true
;;
esac
fi
}

When this machine is running systemd, standard service calls are turned into

systemctl calls.

if [ -n “$is_systemd” ]
then
UNIT="${SERVICE%.sh}.service"
case “${ACTION}” in
restart|status)
exec systemctl ${ACTION} ${UNIT}
;;
start|stop)
# Follow the principle of least surprise for SysV people:
# When running “service foo stop” and foo happens to be a service that
# has one or more .socket files, we also stop the .socket units.
# Users who need more control will use systemctl directly.
for unit in $(systemctl list-unit-files --full --type=socket 2>/dev/null | sed -ne ‘s/.socket\s*[a-z]\s$/.socket/p’); do
if [ “$(systemctl -p Triggers show $unit)” = “Triggers=${UNIT}” ]; then
systemctl ${ACTION} $unit
fi
done
exec systemctl ${ACTION} ${UNIT}
;;
reload)
_canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
if [ “$_canreload” = “CanReload=no” ]; then
# The reload action falls back to the sysv init script just in case
# the systemd service file does not (yet) support reload for a
# specific service.
run_via_sysvinit
else
exec systemctl reload "${UNIT}“
fi
;;
force-stop)
exec systemctl --signal=KILL kill “${UNIT}”
;;
force-reload)
_canreload=”$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
if [ “$_canreload” = “CanReload=no” ]; then
exec systemctl restart "${UNIT}"
else
exec systemctl reload "${UNIT}"
fi
;;
*)
# We try to run non-standard actions by running
# the init script directly.
run_via_sysvinit
;;
esac
fi

update_openrc_started_symlinks
run_via_sysvinit
[/code][/quote]

Ton fichier est bien différent du mien.
Tu as quelle version de Debian ?
( cat /etc/debian-version )

[quote=“ben_raven”]
Ton fichier est bien différent du mien.
Tu as quelle version de Debian ?
( cat /etc/debian-version )[/quote]
Je suis en version Sid (Jessie), affin de comparer, est-ce qu’il y a moyen de voir le tien ? J’ai toutefois examiné un peu et je pense que ce n’est pas la qu’est indiqué ce que l’on cherche, à savoir ce qui rend la commande service muet, du fait que c’est systemd qui est en charge de gérer les services, je me suis demandé s’il y avait moyen d’ajouter un argument ou de modifier une options dans un fichier de configuration, j’ai essayé un peu a pif la ou j’ai pensé que cela changerait quelque chose, sans résultat. je ne me souvient plus des fichiers et des options en question, j’ai remis a zéro depuis.

EDIT : Je pensais qu’il y avait une erreur dans [mono]/usr/sbin/service[/mono] qui pouvait en être la cause, Bein NON en fait,
le script est le même que celui donné par Y.Petremann, et je viens d’installer une machine virtuelle pour tester [mono]jessie[/mono] :

[code]root@debjessie:~# service apache2 status
apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Active: active (running) since mar. 2014-09-23 21:29:01 CEST; 26s ago
Process: 3103 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/apache2.service
├─3124 /usr/sbin/apache2 -k start
├─3127 /usr/sbin/apache2 -k start
└─3128 /usr/sbin/apache2 -k start

sept. 23 21:29:01 debjessie apache2[3103]: Starting web server: apache2.
sept. 23 21:29:01 debjessie systemd[1]: Started LSB: Apache2 web server.
root@debjessie:~#
[/code]

======
Je vais voir ce que ça donne en la clonant et en passant une des deux en [mono]Sid[/mono]