29 lines
597 B
Bash
Executable File
29 lines
597 B
Bash
Executable File
#!/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} "$@"
|