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.

27 lines
365 B

#!/usr/bin/env bash
# CONSTANTS
BASEDIR=$(dirname "$0")
CONTAINER_NAME=$1
USER=${2:-root}
# FUNCTIONS
function usage {
echo "$(basename "$0") <CONTAINER_NAME> [USER=root]"
}
function login {
if vmid=$($BASEDIR/pct-lookup $CONTAINER_NAME); then
pct exec $vmid -- su - $USER
else
exit 10
fi
}
# MAIN
set -Eue
[[ "$#" -lt 1 ]] && usage && exit 1
login