You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
931 B

#!/usr/bin/env bash
set -eu
synopsis() {
cat << EOF
Usage : `basename $0` [-h] system
EOF
}
help() {
cat << EOF
`basename $0` retourne 0 si le système est en fonctionnement, 1 sinon.
`synopsis`
-h : affiche cette aide.
EOF
}
usage() {
synopsis
exit 1
}
args() {
local opt
while getopts "h" opt; do
case $opt in
h) help; exit 0;;
?) usage;;
esac
done
shift $(($OPTIND - 1))
[ $# -ne 1 ] && usage
GUEST_NAME="$1"
if echo $GUEST_NAME | grep -q '/'; then
error "$GUEST_NAME est un nom de système invalide"
fi
}
alive() {
local r
set +e
#ps u | grep -E $GUEST_NAME[-]$USER-pid
#ps auwx | grep qemu
#ps -w -w -u $USER -eo cmd | grep -Eq $GUEST_NAME[-]$USER-pid
ps -w -w -eo user:14,cmd | grep $USER | grep -Eq $GUEST_NAME[-]$USER-pid
r=$?
set -e
return $r
}
# Programme principal
GUEST_OWNER=$USER
VDN_PATH=$(readlink -f $(dirname $0)/..); . $VDN_PATH/bin/functions.sh
args "$@"
alive