server-scripts/lxc-log

29 lines
597 B
Plaintext
Raw Normal View History

2014-10-19 15:27:33 +00:00
#!/bin/bash
set -eu
die() { echo $1 1>&2; exit 1; }
usage() { echo "USAGE: $SCRIPT NAME SERVICE [JOURNALCTL_OPTIONS...]"; exit 0; }
SCRIPT=${0##*/}
[ $# -lt 2 ] && usage
case "$1" in
--help|-h)
usage
;;
*)
CONTAINER=$1; shift
SERVICE=$1; shift
;;
esac
CONTAINER_PATH="/data/containers/$CONTAINER"
[ $EUID -eq 0 ] || die "Needs root permission"
[ -d "$CONTAINER_PATH" ] || die "No such container found: $CONTAINER"
SYSTEMD_CGROUP="/system.slice/system-lxc.slice/lxc@${CONTAINER}.service/system.slice/${SERVICE}.service"
journalctl _SYSTEMD_CGROUP=${SYSTEMD_CGROUP} "$@"