summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/container/auto7
-rwxr-xr-xlib/container/console5
-rwxr-xr-xlib/container/create16
-rwxr-xr-xlib/container/enter5
-rwxr-xr-xlib/container/key5
-rwxr-xr-xlib/container/limit5
-rwxr-xr-xlib/container/list17
-rwxr-xr-xlib/container/log143
-rwxr-xr-xlib/container/move7
-rwxr-xr-xlib/container/remove13
-rwxr-xr-xlib/container/restart11
-rwxr-xr-xlib/container/start13
-rwxr-xr-xlib/container/status5
-rwxr-xr-xlib/container/stop13
-rwxr-xr-xlib/container/top3
-rwxr-xr-xlib/container/version7
16 files changed, 214 insertions, 61 deletions
diff --git a/lib/container/auto b/lib/container/auto
index 8477915..5e192da 100755
--- a/lib/container/auto
+++ b/lib/container/auto
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
Parameters ()
{
diff --git a/lib/container/console b/lib/container/console
index dfc9b5c..2b579c8 100755
--- a/lib/container/console
+++ b/lib/container/console
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,7 +21,7 @@ set -e
COMMAND="$(basename ${0})"
-HOOKS="/etc/container-tools/hooks"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
diff --git a/lib/container/create b/lib/container/create
index 561584c..73c5493 100755
--- a/lib/container/create
+++ b/lib/container/create
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,10 +21,11 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
-SCRIPTS="/usr/share/container-tools/scripts"
+SCRIPTS="/usr/share/compute-tools/container/scripts"
+CONFIG_TEMPLATE="/usr/share/compute-tools/container/config/container.conf.in"
Parameters ()
{
@@ -141,8 +141,8 @@ then
TARGET="$(basename $(readlink ${SCRIPTS}/default))"
case "${TARGET}" in
- container-tools_script)
- TARGET="$(basename $(readlink /etc/alternatives/container-tools_script))"
+ container_script)
+ TARGET="$(basename $(readlink /etc/alternatives/container_script))"
;;
esac
@@ -251,7 +251,7 @@ sed -e "s|@CNT_AUTO@|${CNT_AUTO}|g" \
-e "s|@NETWORK_VETH_EXTRA@|${NETWORK_VETH_EXTRA}|g" \
-e "s|@PRIVATE_USERS@|no|g" \
-e "s|@REGISTER@|yes|g" \
-/usr/share/container-tools/config/container.conf.in > "${CONFIG}/${NAME}.conf"
+"${CONFIG_TEMPLATE}" > "${CONFIG}/${NAME}.conf"
# Run
"${SCRIPTS}/${SCRIPT}" $(echo "${@}" | sed -e 's| -- | |')
diff --git a/lib/container/enter b/lib/container/enter
index 72b3b1c..a96c399 100755
--- a/lib/container/enter
+++ b/lib/container/enter
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,7 +21,7 @@ set -e
COMMAND="$(basename ${0})"
-HOOKS="/etc/container-tools/hooks"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
diff --git a/lib/container/key b/lib/container/key
index 3f0f57b..c2c31f1 100755
--- a/lib/container/key
+++ b/lib/container/key
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,7 +21,7 @@ set -e
COMMAND="$(basename ${0})"
-KEYS="/etc/container-tools/keys"
+KEYS="/etc/compute-tools/container/keys"
Parameters ()
{
diff --git a/lib/container/limit b/lib/container/limit
index f2d6bfa..68eb732 100755
--- a/lib/container/limit
+++ b/lib/container/limit
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,7 +21,7 @@ set -e
COMMAND="$(basename ${0})"
-HOOKS="/etc/container-tools/hooks"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
diff --git a/lib/container/list b/lib/container/list
index 816d521..c32203a 100755
--- a/lib/container/list
+++ b/lib/container/list
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
VERSION="$(container version)"
@@ -233,7 +232,7 @@ EOF
csv)
cat << EOF
-# container-tools version ${VERSION}
+# compute-tools version ${VERSION}
Host${CSV_SEPARATOR}Container${CSV_SEPARATOR}Status${CSV_SEPARATOR}IPv4-Address
EOF
@@ -243,7 +242,7 @@ EOF
cat << EOF
{
- "container-tools": {
+ "compute-tools": {
"version": "${VERSION}",
},
"host": {
@@ -258,7 +257,7 @@ EOF
NETWORK="$(echo ${HOST} | sed -e 's|\.|_|g')"
cat << EOF
-# container-tools ${VERSION}
+# compute-tools ${VERSION}
nwdiag {
external_connector = none;
network ${NETWORK} {
@@ -308,9 +307,9 @@ EOF
xml)
cat << EOF
-<container-tools>
+<compute-tools>
<version>${VERSION}</version>
-</container-tools>
+</compute-tools>
<host>
<name>${HOST}</name>
</host>
diff --git a/lib/container/log b/lib/container/log
new file mode 100755
index 0000000..c39c58a
--- /dev/null
+++ b/lib/container/log
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+COMMAND="$(basename ${0})"
+
+LOG="/var/log/compute-tools/container.log"
+
+Parameters ()
+{
+ GETOPT_LONGOPTIONS="name:,date:,"
+ GETOPT_OPTIONS="n:,d:,"
+
+ PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
+
+ if [ "${?}" != "0" ]
+ then
+ echo "'${COMMAND}': getopt exit" >&2
+ exit 1
+ fi
+
+ eval set -- "${PARAMETERS}"
+
+ while true
+ do
+ case "${1}" in
+ -d|--date)
+ DATE="${2}"
+ shift 2
+ ;;
+
+ -n|--name)
+ NAME="${2}"
+ shift 2
+ ;;
+
+ -u|--user)
+ USER="${2}"
+ shift 2
+ ;;
+
+ --)
+ shift 1
+ break
+ ;;
+
+ *)
+ echo "'${COMMAND}': getopt error" >&2
+ exit 1
+ ;;
+ esac
+ done
+}
+
+Usage ()
+{
+ echo "Usage: container ${COMMAND} [-n|--name NAME] [-d|--date DATE|today|today-N|yesterday] [-u|--user USER]" >&2
+ exit 1
+}
+
+Parameters "${@}"
+
+case "${DATE}" in
+ today-*)
+ DAYS="$(echo ${DATE} | awk -F- '{ print $2 }')"
+
+ START="$(date -d "${DAYS} day ago" '+%Y-%m-%d')"
+ END="$(date +%Y-%m-%d)"
+
+ DATE="(${START}"
+
+ while true
+ do
+ DATE="${DATE}|${START}"
+
+ if [ "${START}" = "${END}" ]
+ then
+ break
+ fi
+
+ START="$(date +%Y-%m-%d --date "${START} +1 day")"
+ done
+
+ DATE="${DATE})"
+ ;;
+
+ today)
+ DATE="$(date +%Y-%m-%d)"
+ ;;
+
+ yesterday)
+ DATE="$(date -d '1 day ago' '+%Y-%m-%d')"
+ ;;
+esac
+
+if ls "${LOG}"-*.gz > /dev/null 2>&1
+then
+ LOGS="$(ls ${LOG}-*.gz) ${LOG}"
+else
+ LOGS="${LOG}"
+fi
+
+# FIXME: user
+
+for LOG in ${LOGS}
+do
+ case "${LOG}" in
+ *.gz)
+ GREP="zgrep"
+ ;;
+
+ *)
+ GREP="grep"
+ ;;
+ esac
+
+ case "${NAME}" in
+ "")
+ ${GREP} -E "^${DATE}" "${LOG}" || true
+ ;;
+
+ *)
+ ${GREP} -E "^${DATE}" "${LOG}" | grep " ${NAME}" || true
+ ;;
+ esac
+done
diff --git a/lib/container/move b/lib/container/move
index e533b0e..6e12fa0 100755
--- a/lib/container/move
+++ b/lib/container/move
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
diff --git a/lib/container/remove b/lib/container/remove
index 275c867..7e9d871 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
@@ -125,6 +124,12 @@ case "${NAME}" in
for NAME in ${NAMES}
do
+ case "${VERBOSE}" in
+ true)
+ echo "Removing container ${NAME}..."
+ ;;
+ esac
+
container remove --name ${NAME} ${OPTIONS_ALL} || true
done
diff --git a/lib/container/restart b/lib/container/restart
index a22b970..7d2e31b 100755
--- a/lib/container/restart
+++ b/lib/container/restart
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,7 +21,7 @@ set -e
COMMAND="$(basename ${0})"
-HOOKS="/etc/container-tools/hooks"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
@@ -82,6 +81,12 @@ case "${NAME}" in
for NAME in ${NAMES}
do
+ case "${VERBOSE}" in
+ true)
+ echo "Restarting container ${NAME}..."
+ ;;
+ esac
+
container restart --name ${NAME} || true
done
diff --git a/lib/container/start b/lib/container/start
index ac0275e..8c8db44 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
START="false"
@@ -106,6 +105,12 @@ case "${NAME}" in
for NAME in ${NAMES}
do
+ case "${VERBOSE}" in
+ true)
+ echo "Starting container ${NAME}..."
+ ;;
+ esac
+
container start --name ${NAME} ${OPTIONS_ALL} || true
done
diff --git a/lib/container/status b/lib/container/status
index 9c5ab20..6e4dd01 100755
--- a/lib/container/status
+++ b/lib/container/status
@@ -1,6 +1,5 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
# Copyright (C) 2016 Simon Spöehel <simon.spoehel@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
Parameters ()
diff --git a/lib/container/stop b/lib/container/stop
index d996282..44977fd 100755
--- a/lib/container/stop
+++ b/lib/container/stop
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-CONFIG="/etc/container-tools/config"
-HOOKS="/etc/container-tools/hooks"
+CONFIG="/etc/compute-tools/container/config"
+HOOKS="/etc/compute-tools/container/hooks"
MACHINES="/var/lib/machines"
CLEAN="false"
@@ -121,6 +120,12 @@ case "${NAME}" in
for NAME in ${NAMES}
do
+ case "${VERBOSE}" in
+ true)
+ echo "Stopping container ${NAME}..."
+ ;;
+ esac
+
container stop --name ${NAME} ${OPTIONS_ALL} || true
done
diff --git a/lib/container/top b/lib/container/top
index 31ec005..674112e 100755
--- a/lib/container/top
+++ b/lib/container/top
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
diff --git a/lib/container/version b/lib/container/version
index 543d6dc..75b57ce 100755
--- a/lib/container/version
+++ b/lib/container/version
@@ -1,7 +1,6 @@
#!/bin/sh
-# container-tools - Manage systemd-nspawn containers
-# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -22,8 +21,8 @@ set -e
COMMAND="$(basename ${0})"
-HOOKS="/etc/container-tools/hooks"
-SHARE="/usr/share/container-tools"
+HOOKS="/etc/compute-tools/container/hooks"
+SHARE="/usr/share/compute-tools/container"
# Pre hooks
for FILE in "${HOOKS}/pre-${COMMAND}".* "${HOOKS}/${NAME}.pre-${COMMAND}"