From 38ae0ed4a6a8f36b1a947b3650ebff4e699e3f0a Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 28 Jan 2020 18:57:51 -0400 Subject: [PATCH] Update list command and config --- usr/local/etc/bastille/bastille.conf | 49 +++++++++++++++------------- usr/local/share/bastille/import.sh | 21 ++++-------- usr/local/share/bastille/list.sh | 4 +++ 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/usr/local/etc/bastille/bastille.conf b/usr/local/etc/bastille/bastille.conf index 408faf57..1eec0c9d 100644 --- a/usr/local/etc/bastille/bastille.conf +++ b/usr/local/etc/bastille/bastille.conf @@ -3,40 +3,43 @@ ##################### ## default paths -bastille_prefix=/usr/local/bastille ## default: "/usr/local/bastille" -bastille_backupsdir=${bastille_prefix}/backups ## default: ${bastille_prefix}/backups -bastille_cachedir=${bastille_prefix}/cache ## default: ${bastille_prefix}/cache -bastille_jailsdir=${bastille_prefix}/jails ## default: ${bastille_prefix}/jails -bastille_logsdir=${bastille_prefix}/logs ## default: ${bastille_prefix}/logs -bastille_releasesdir=${bastille_prefix}/releases ## default: ${bastille_prefix}/releases -bastille_templatesdir=${bastille_prefix}/templates ## default: ${bastille_prefix}/templates +bastille_prefix=/usr/local/bastille ## default: "/usr/local/bastille" +bastille_backupsdir=${bastille_prefix}/backups ## default: ${bastille_prefix}/backups +bastille_cachedir=${bastille_prefix}/cache ## default: ${bastille_prefix}/cache +bastille_jailsdir=${bastille_prefix}/jails ## default: ${bastille_prefix}/jails +bastille_logsdir=${bastille_prefix}/logs ## default: ${bastille_prefix}/logs +bastille_releasesdir=${bastille_prefix}/releases ## default: ${bastille_prefix}/releases +bastille_templatesdir=${bastille_prefix}/templates ## default: ${bastille_prefix}/templates ## bastille scripts directory (assumed by bastille pkg) -bastille_sharedir=/usr/local/share/bastille ## default: "/usr/local/share/bastille" +bastille_sharedir=/usr/local/share/bastille ## default: "/usr/local/share/bastille" ## bootstrap archives (base, lib32, ports, src, test) -bastille_bootstrap_archives="base" ## default: "base" +bastille_bootstrap_archives="base" ## default: "base" ## default timezone -bastille_tzdata="etc/UTC" ## default: "etc/UTC" +bastille_tzdata="etc/UTC" ## default: "etc/UTC" ## default jail resolv.conf -bastille_resolv_conf="/etc/resolv.conf" ## default: "/etc/resolv.conf" +bastille_resolv_conf="/etc/resolv.conf" ## default: "/etc/resolv.conf" + +## bootstrap urls +bastille_url_freebsd="http://ftp.freebsd.org/pub/FreeBSD/releases/" ## default: "http://ftp.freebsd.org/pub/FreeBSD/releases/" +bastille_url_hardenedbsd="https://installer.hardenedbsd.org/pub/HardenedBSD/releases/" ## default: "https://installer.hardenedbsd.org/pub/HardenedBSD/releases/" ## ZFS options -bastille_zfs_enable="" ## default: "" -bastille_zfs_zpool="" ## default: "" -bastille_zfs_prefix="bastille" ## default: "${bastille_zfs_zpool}/bastille" -bastille_zfs_mountpoint=${bastille_prefix} ## default: "${bastille_prefix}" -bastille_zfs_options="-o compress=lz4 -o atime=off" ## default: "-o compress=lz4 -o atime=off" +bastille_zfs_enable="" ## default: "" +bastille_zfs_zpool="" ## default: "" +bastille_zfs_prefix="bastille" ## default: "${bastille_zfs_zpool}/bastille" +bastille_zfs_options="-o compress=lz4 -o atime=off" ## default: "-o compress=lz4 -o atime=off" ## Export/Import options -bastille_compress_xz_options="-0 -v" ## default "-0 -v" -bastille_decompress_xz_options="-c -d -v" ## default "-c -d -v" +bastille_compress_xz_options="-0 -v" ## default "-0 -v" +bastille_decompress_xz_options="-c -d -v" ## default "-c -d -v" ## Networking -bastille_jail_loopback="lo1" ## default: "lo1" -bastille_jail_interface="bastille0" ## default: "bastille0" -bastille_jail_external="" ## default: "" -bastille_jail_addr="10.17.89.10" ## default: "10.17.89.10" -bastille_jail_gateway="" ## default: "" +bastille_jail_loopback="lo1" ## default: "lo1" +bastille_jail_interface="bastille0" ## default: "bastille0" +bastille_jail_external="" ## default: "" +bastille_jail_addr="10.17.89.10" ## default: "10.17.89.10" +bastille_jail_gateway="" ## default: "" diff --git a/usr/local/share/bastille/import.sh b/usr/local/share/bastille/import.sh index 6208ea53..f4d730aa 100644 --- a/usr/local/share/bastille/import.sh +++ b/usr/local/share/bastille/import.sh @@ -181,21 +181,12 @@ if [ ! -d "${bastille_backupsdir}" ]; then error_notify "${COLOR_RED}Backups directory/dataset does not exist, See 'bastille bootstrap'.${COLOR_RESET}" fi -# Handle additional options -case "${TARGET}" in -list) - ls "${bastille_backupsdir}" | grep -Ev "*.sha256" - exit 0 - ;; -*) - # Check if archive exist then trim archive name - if [ "$(ls "${bastille_backupsdir}" | awk "/^${TARGET}$/")" ]; then - TARGET_TRIM=$(echo ${TARGET} | sed "s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*:[0-9]*:[0-9]*.[txz]\{2,3\}//") - else - error_notify "${COLOR_RED}Archive '${TARGET}' not found.${COLOR_RESET}" - fi - ;; -esac +# Check if archive exist then trim archive name +if [ "$(ls "${bastille_backupsdir}" | awk "/^${TARGET}$/")" ]; then + TARGET_TRIM=$(echo ${TARGET} | sed "s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*:[0-9]*:[0-9]*.[txz]\{2,3\}//") +else + error_notify "${COLOR_RED}Archive '${TARGET}' not found.${COLOR_RESET}" +fi # Check if a running jail matches name or already exist if [ -n "$(jls name | awk "/^${TARGET_TRIM}$/")" ]; then diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index 42218a0f..d40a9aa8 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -80,6 +80,10 @@ if [ $# -gt 0 ]; then limit|limits) rctl -h jail: ;; + import|imports|export|exports|backup|backups) + ls "${bastille_backupsdir}" | grep -Ev "*.sha256" + exit 0 + ;; *) usage ;;