From 67a9c659126c6d23b8000496d82f00c8e806e7d8 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 15 Oct 2020 16:20:25 -0400 Subject: [PATCH 1/3] Option to create standard backups on ZFS setups --- usr/local/share/bastille/export.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/usr/local/share/bastille/export.sh b/usr/local/share/bastille/export.sh index 65863f97..a9cb0365 100644 --- a/usr/local/share/bastille/export.sh +++ b/usr/local/share/bastille/export.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_exit "Usage: bastille export TARGET" + error_exit "Usage: bastille export TARGET [option]" } # Handle special-case commands first @@ -42,10 +42,25 @@ help|-h|--help) ;; esac -if [ $# -ne 0 ]; then +if [ $# -gt 1 ] || [ $# -lt 0 ]; then usage fi +OPTION="${1}" + +# Handle some options +if [ -n "${OPTION}" ]; then + if [ "${OPTION}" = "-t" -o "${OPTION}" = "--txz" ]; then + if [ "${bastille_zfs_enable}" = "YES" ]; then + # Temporarily disable ZFS so we can create a standard backup archive + bastille_zfs_enable="NO" + fi + else + error_notify "Invalid option!" + usage + fi +fi + jail_export() { # Attempt to export the container From bc07ff23892831198aa2eaf6b7a387af5bf2f49c Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 16 Oct 2020 14:48:36 -0400 Subject: [PATCH 2/3] Export command bug fixes and enhancements --- usr/local/share/bastille/export.sh | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/usr/local/share/bastille/export.sh b/usr/local/share/bastille/export.sh index a9cb0365..09256b12 100644 --- a/usr/local/share/bastille/export.sh +++ b/usr/local/share/bastille/export.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_exit "Usage: bastille export TARGET [option]" + error_exit "Usage: bastille export TARGET [option] | PATH" } # Handle special-case commands first @@ -42,11 +42,17 @@ help|-h|--help) ;; esac -if [ $# -gt 1 ] || [ $# -lt 0 ]; then +# Check for unsupported actions +if [ "${TARGET}" = "ALL" ]; then + error_exit "Batch export is unsupported." +fi + +if [ $# -gt 2 ] || [ $# -lt 0 ]; then usage fi OPTION="${1}" +EXPATH="${2}" # Handle some options if [ -n "${OPTION}" ]; then @@ -55,12 +61,28 @@ if [ -n "${OPTION}" ]; then # Temporarily disable ZFS so we can create a standard backup archive bastille_zfs_enable="NO" fi + elif echo "${OPTION}" | grep -q "\/"; then + if [ -d "${OPTION}" ]; then + EXPATH="${OPTION}" + else + error_exit "Error: Path not found." + fi else error_notify "Invalid option!" usage fi fi +# Export directory check +if [ -n "${EXPATH}" ]; then + if [ -d "${EXPATH}" ]; then + # Set the user defined export directory + bastille_backupsdir="${EXPATH}" + else + error_exit "Error: Path not found." + fi +fi + jail_export() { # Attempt to export the container @@ -97,13 +119,6 @@ jail_export() fi } -# Check for user specified file location -if echo "${TARGET}" | grep -q '\/'; then - GETDIR="${TARGET}" - TARGET=$(echo ${TARGET} | awk -F '\/' '{print $NF}') - bastille_backupsdir=$(echo ${GETDIR} | sed "s/${TARGET}//") -fi - # Check if backups directory/dataset exist if [ ! -d "${bastille_backupsdir}" ]; then error_exit "Backups directory/dataset does not exist. See 'bastille bootstrap'." From 855dcf3eae244138263b301ede7922690d01071a Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 17 Oct 2020 17:34:25 -0400 Subject: [PATCH 3/3] Fix to use SYNCDHCP by default while cloning jails --- usr/local/share/bastille/clone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/clone.sh b/usr/local/share/bastille/clone.sh index ec824141..e3badf25 100644 --- a/usr/local/share/bastille/clone.sh +++ b/usr/local/share/bastille/clone.sh @@ -120,7 +120,7 @@ update_jailconf_vnet() { # If 0.0.0.0 set DHCP, else set static IP address if [ "${IP}" == "0.0.0.0" ]; then - sysrc -f "${bastille_jail_rc_conf}" ifconfig_vnet0="DHCP" + sysrc -f "${bastille_jail_rc_conf}" ifconfig_vnet0="SYNCDHCP" else sysrc -f "${bastille_jail_rc_conf}" ifconfig_vnet0="inet ${IP}" fi