29 lines
668 B
Bash
Executable File
29 lines
668 B
Bash
Executable File
#!/usr/bin/env 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="/lxc/$CONTAINER"
|
|
|
|
[ $EUID -eq 0 ] || die "Needs root permission"
|
|
[ -d "$CONTAINER_PATH" ] || die "No such container found: $CONTAINER"
|
|
|
|
CGROUP="/system.slice/system-lxc.slice/lxc@${CONTAINER}.service/system.slice/${SERVICE}.service"
|
|
UNIT=lxc@${CONTAINER}.service
|
|
journalctl --system _SYSTEMD_CGROUP=${CGROUP} + SYSLOG_IDENTIFIER=${SERVICE} _SYSTEMD_UNIT=${UNIT} "$@"
|