From 53e7856d28d39f85fd6407440871610f7a20072e Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 14 Feb 2020 19:01:08 -0400 Subject: [PATCH 1/2] Ignore IPv4 check if there is no entry at all --- usr/local/share/bastille/start.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 7b0fd9a8..8e457c05 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -68,11 +68,13 @@ for _jail in ${JAILS}; do ## test if not running elif [ ! "$(jls name | awk "/^${_jail}$/")" ]; then - ## warn if matching configured (but not online) ip4.addr + ## warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry ip=$(grep 'ip4.addr' "${bastille_jailsdir}/${_jail}/jail.conf" | awk '{print $3}' | sed 's/\;//g') - if ifconfig | grep -w "${ip}" >/dev/null; then - echo -e "${COLOR_RED}Error: IP address (${ip}) already in use.${COLOR_RESET}" - exit 1 + if [ -n "${ip}" ]; then + if ifconfig | grep -w "${ip}" >/dev/null; then + echo -e "${COLOR_RED}Error: IP address (${ip}) already in use.${COLOR_RESET}" + exit 1 + fi fi ## start the container From 015558c4bc2e05f53be0ab14f51605240cb773ae Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 15 Feb 2020 07:57:33 -0400 Subject: [PATCH 2/2] Don't set jail ZFS dataset mountpoint, let be inherited from the system --- usr/local/share/bastille/create.sh | 4 ++-- usr/local/share/bastille/import.sh | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index ba502f9e..f16f78ab 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -122,10 +122,10 @@ create_jail() { if [ ! -d "${bastille_jailsdir}/${NAME}" ]; then if [ "${bastille_zfs_enable}" = "YES" ]; then if [ ! -z "${bastille_zfs_zpool}" ]; then - ## create required zfs datasets + ## create required zfs datasets, mountpoint inherited from system zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME} if [ -z "${THICK_JAIL}" ]; then - zfs create ${bastille_zfs_options} -o mountpoint=${bastille_jailsdir}/${NAME}/root ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME}/root + zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME}/root fi fi else diff --git a/usr/local/share/bastille/import.sh b/usr/local/share/bastille/import.sh index 0c1c34a4..e81f8e3e 100644 --- a/usr/local/share/bastille/import.sh +++ b/usr/local/share/bastille/import.sh @@ -78,6 +78,14 @@ update_zfsmount() { echo -e "${COLOR_GREEN}Updating zfs mountpoint...${COLOR_RESET}" zfs set mountpoint=${bastille_jailsdir}/${TARGET_TRIM}/root ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}/root fi + + # Mount new container ZFS datasets + if ! zfs mount | grep "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}"; then + zfs mount ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM} + fi + if ! zfs mount | grep "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}/root"; then + zfs mount ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}/root + fi } update_jailconf() { @@ -128,9 +136,6 @@ jail_import() { # This is required on foreign imports only update_zfsmount - # Mount new container ZFS datasets - zfs mount ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM} - zfs mount ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}/root elif [ "${FILE_EXT}" = "txz" ]; then # Prepare the ZFS environment and restore from existing tar.xz file echo -e "${COLOR_GREEN}Importing '${TARGET_TRIM}' form .${FILE_EXT} archive.${COLOR_RESET}"