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"
|
|
|
|
|
2015-01-10 07:40:55 +00:00
|
|
|
CGROUP="/system.slice/system-lxc.slice/lxc@${CONTAINER}.service/system.slice/${SERVICE}.service"
|
|
|
|
UNIT=lxc@${CONTAINER}.service
|
2015-09-08 22:40:33 +00:00
|
|
|
journalctl --system _SYSTEMD_CGROUP=${CGROUP} + SYSLOG_IDENTIFIER=${SERVICE} _SYSTEMD_UNIT=${UNIT} "$@"
|