diff options
Diffstat (limited to 'lib/container/start')
-rwxr-xr-x | lib/container/start | 70 |
1 files changed, 63 insertions, 7 deletions
diff --git a/lib/container/start b/lib/container/start index a4dc033..5191ae2 100755 --- a/lib/container/start +++ b/lib/container/start @@ -28,8 +28,8 @@ SYSTEMCTL="true" Parameters () { - LONG_OPTIONS="name:,nspawn,start," - OPTIONS="n:," + LONG_OPTIONS="name:,force,nspawn,start," + OPTIONS="n:f," PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})" @@ -49,6 +49,11 @@ Parameters () shift 2 ;; + -f|--force) + FORCE="true" + shift 1 + ;; + --nspawn) # internal option SYSTEMCTL="false" @@ -77,7 +82,7 @@ Parameters () Usage () { - echo "Usage: container ${COMMAND} -n|--name NAME" >&2 + echo "Usage: container ${COMMAND} -n|--name NAME [-f|--force]" >&2 exit 1 } @@ -107,6 +112,20 @@ case "${START}" in ;; esac +if [ -e "${MACHINES}/.#${NAME}.lck" ] +then + case "${FORCE}" in + true) + rm -f "${MACHINES}/.#${NAME}.lck" + ;; + + *) + echo "'${NAME}': container is locked" >&2 + exit 1 + ;; + esac +fi + HOST_ARCHITECTURE="$(dpkg --print-architecture)" MACHINE_ARCHITECTURE="$(chroot ${MACHINES}/${NAME} dpkg --print-architecture)" @@ -139,6 +158,31 @@ esac # config if [ -e "${CONFIG}/${NAME}.conf" ] then + CNT_OVERLAY="$(awk -F= '/^cnt.overlay=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + if [ -n "${CNT_OVERLAY}" ] + then + CNT_OVERLAYS="$(echo ${CNT_OVERLAY} | sed -e 's|;| |g')" + + for CNT_OVERLAY in ${CNT_OVERLAYS} + do + DIRECTORY_LOWER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $1 }')" + DIRECTORY_UPPER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $2 }')" + DIRECTORY_WORK="$(echo ${CNT_OVERLAY} | awk -F: '{ print $3 }')" + DIRECTORY_MERGED="$(echo ${CNT_OVERLAY} | awk -F: '{ print $4 }')" + + for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" + do + mkdir -p "${DIRECTORY}" + done + + if ! findmnt -n -o SOURCE "${DIRECTORY_MERGED}" | grep -qs '^cnt.overlay-' + then + mount cnt.overlay-${NAME} -t overlay -olowerdir="${DIRECTORY_LOWER}",upperdir="${DIRECTORY_UPPER}",workdir="${DIRECTORY_WORK}",default_permissions "${DIRECTORY_MERGED}" + fi + done + fi + BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)" if [ -n "${BIND}" ] @@ -199,6 +243,18 @@ then ;; esac + LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)" + + case "${LINK_JOURNAL}" in + yes) + LINK_JOURNAL="--link-journal=yes" + ;; + + *) + LINK_JOURNAL="--link-journal=no" + ;; + esac + MACHINE="--machine=${NAME}" NETWORK_VETH_EXTRA_CONF="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)" @@ -256,15 +312,15 @@ EOF ;; esac - LINK_JOURNAL="$(awk -F= '/^link-journal=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)" + PRIVATE_USERS="$(awk -F= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)" - case "${LINK_JOURNAL}" in + case "${PRIVATE_USERS}" in yes) - LINK_JOURNAL="--link-journal=yes" + PRIVATE_USERS="--private-users=yes" ;; *) - LINK_JOURNAL="--link-journal=no" + PRIVATE_USERS="--private-users=no" ;; esac |