summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/container/info26
-rwxr-xr-xlibexec/container/restart37
2 files changed, 49 insertions, 14 deletions
diff --git a/libexec/container/info b/libexec/container/info
index 699a253..b713e7a 100755
--- a/libexec/container/info
+++ b/libexec/container/info
@@ -143,30 +143,34 @@ esac
VERSION_BASH="$(chroot ${MACHINES}/${NAME} apt-cache policy bash | awk '/Installed: / { print $2 }')"
case "${VERSION_BASH}" in
- 4.1*)
+ 4.1-*|4.1.[0-9]*)
OS="Debian 6 (squeeze)"
;;
- 4.2*)
+ 4.2-*|4.2.[0-9]*)
OS="Debian 7 (wheezy)"
;;
- 4.3*)
+ 4.3-*|4.3.[0-9]*)
OS="Debian 8 (jessie)"
;;
- 4.4*)
+ 4.4-*|4.4.[0-9]*)
OS="Debian 9 (stretch)"
;;
- 5.0*)
+ 5.0-*|5.0.[0-9]*)
OS="Debian 10 (buster)"
;;
- 5.1*)
+ 5.1-*|5.1.[0-9]*)
OS="Debian 11 (bullseye)"
;;
+ 5.2-*|5.2.[0-9]*)
+ OS="Debian 12 (bookworm)"
+ ;;
+
*)
OS="n/a"
;;
@@ -174,16 +178,16 @@ esac
case "${STATUS}" in
started)
- IP="$(cnt run -n ${NAME} -- hostname -I | awk '{ print $1 }')"
+ IP="$(cnt run -n ${NAME} -- hostname -I)"
;;
*)
- if ls "${MACHINES}/${CONTAINER}/etc/systemd/network"/*.network > /dev/null 2>&1
+ if ls "${MACHINES}/${NAME}/etc/systemd/network"/*.network > /dev/null 2>&1
then
- IP="$(awk -FAddress= '/^Address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/systemd/network/*.network | head -n1)"
- elif [ -e "${MACHINES}/${CONTAINER}/etc/network/interfaces" ]
+ IP="$(awk -FAddress= '/^Address/ { printf "%s ", $2 }' ${MACHINES}/${NAME}/etc/systemd/network/*.network)"
+ elif [ -e "${MACHINES}/${NAME}/etc/network/interfaces" ]
then
- IP="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces | head -n1)"
+ IP="$(awk '/address/ { printf "%s ", $2 }' ${MACHINES}/${NAME}/etc/network/interfaces)"
fi
IP="${IP:-n/a}"
diff --git a/libexec/container/restart b/libexec/container/restart
index fcb28b8..0eb753c 100755
--- a/libexec/container/restart
+++ b/libexec/container/restart
@@ -31,8 +31,8 @@ Parameters ()
{
OPTIONS_ALL=""
- GETOPT_LONGOPTIONS="name:,verbose,"
- GETOPT_OPTIONS="n:,v,"
+ GETOPT_LONGOPTIONS="name:,force,interactive,verbose,"
+ GETOPT_OPTIONS="n:,f,i,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -52,6 +52,20 @@ Parameters ()
shift 2
;;
+ -f|--force)
+ FORCE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
+ ;;
+
+ -i|--interactive)
+ INTERACTIVE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --interactive"
+ ;;
+
-v|--verbose)
VERBOSE="true"
shift 1
@@ -74,7 +88,7 @@ Parameters ()
Usage ()
{
- echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [-v|--verbose]" >&2
+ echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [-f|--force] [-i|--interactive] [-v|--verbose]" >&2
echo
echo "See ${COMMAND}(1), ${PROGRAM}(1) and ${PROJECT}(7) for more information."
@@ -107,6 +121,23 @@ then
exit 1
fi
+if [ "${FORCE}" != "true" ] || [ "${INTERACTIVE}" = "true" ]
+then
+ echo -n "'${NAME}': restart container '${NAME}' [y|N]? "
+ read STOP
+
+ STOP="$(echo ${STOP} | tr '[A-Z]' '[a-z]')"
+
+ case "${STOP}" in
+ y|yes)
+ ;;
+
+ *)
+ exit 1
+ ;;
+ esac
+fi
+
# Pre hooks
for FILE in "${HOOKS}/pre-${COMMAND}".* "${HOOKS}/${NAME}.pre-${COMMAND}"
do