summaryrefslogtreecommitdiffstats
path: root/bin/container
diff options
context:
space:
mode:
Diffstat (limited to 'bin/container')
-rwxr-xr-xbin/container19
1 files changed, 9 insertions, 10 deletions
diff --git a/bin/container b/bin/container
index 849bbec..ac8feff 100755
--- a/bin/container
+++ b/bin/container
@@ -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+
#
@@ -20,10 +19,10 @@
set -e
-SOFTWARE="container-tools"
+PROJECT="open-infrastructure"
PROGRAM="container"
-HOOKS="/etc/${SOFTWARE}/hooks"
+HOOKS="/etc/${PROJECT}/${PROGRAM}/hooks"
# Parameter
PARAMETER="${1}"
@@ -44,7 +43,7 @@ OPTIONS="${@}"
for COMMAND in $(echo ${COMMANDS} | sed -e 's|,| |g')
do
- if [ ! -e "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" ]
+ if [ ! -e "/usr/lib/${PROJECT}/${PROGRAM}/${COMMAND}" ]
then
echo "'${COMMAND}': no such ${PROGRAM} command" >&2
exit 1
@@ -68,15 +67,15 @@ do
create|remove|rm|restart|start|stop)
USER="${SUDO_USER:-${USER}}"
DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
- HOST="$(hostname -f)"
+ HOST="$(hostname -f 2> /dev/null || hostname)"
# logfile
- echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
+ echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${PROJECT}/${PROGRAM}.log"
# irc
- if [ -e /usr/bin/irk ] && [ -e "/etc/default/${SOFTWARE}" ]
+ if [ -e /usr/bin/irk ] && [ -e "/etc/${PROJECT}/${PROGRAM}.conf" ]
then
- . /etc/default/${SOFTWARE}
+ . "/etc/${PROJECT}/${PROGRAM}.conf"
if [ -n "${IRK_TARGETS}" ]
then
@@ -91,7 +90,7 @@ do
fi
# Run
- "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}"
+ "/usr/lib/${PROJECT}/${PROGRAM}/${COMMAND}" "${OPTIONS}"
# Post hooks
for FILE in "${HOOKS}/post-${PROGRAM}".* "${HOOKS}/${NAME}.post-${PROGRAM}"