diff --git a/usr/local/share/bastille/bootstrap.sh b/usr/local/share/bastille/bootstrap.sh index ae72854f..2acc16bb 100644 --- a/usr/local/share/bastille/bootstrap.sh +++ b/usr/local/share/bastille/bootstrap.sh @@ -69,7 +69,6 @@ fi validate_release_url() { ## check upstream url, else switch to alternate url if [ -n "${NAME_VERIFY}" ]; then - RELEASE="${NAME_VERIFY}" if ! fetch -qo /dev/null "${UPSTREAM_URL}/MANIFEST" 2>/dev/null; then ## try an alternate url UPSTREAM_URL="${UPSTREAM_ALT}" @@ -425,14 +424,14 @@ case "${1}" in *-RELEASE|*-release|*-RC1|*-rc1|*-RC2|*-rc2) ## check for FreeBSD releases name NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-2])$' | tr '[:lower:]' '[:upper:]') - UPSTREAM_URL="${bastille_url_freebsd}${HW_MACHINE}/${HW_MACHINE_ARCH}/${RELEASE}" - UPSTREAM_ALT="ftp://ftp.freebsd.org/pub/FreeBSD/releases/${HW_MACHINE}/${HW_MACHINE_ARCH}/${RELEASE}" + UPSTREAM_URL="${bastille_url_freebsd}${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_VERIFY}" + UPSTREAM_ALT="ftp://ftp.freebsd.org/pub/FreeBSD/releases/${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_VERIFY}" validate_release_url ;; *-stable-LAST|*-STABLE-last|*-stable-last|*-STABLE-LAST) ## check for HardenedBSD releases name(previous infrastructure, keep for reference) NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})(-stable-LAST|-STABLE-last|-stable-last|-STABLE-LAST)$' | sed 's/STABLE/stable/g' | sed 's/last/LAST/g') - UPSTREAM_URL="${bastille_url_hardenedbsd}${HW_MACHINE}/${HW_MACHINE_ARCH}/hardenedbsd-${RELEASE}" + UPSTREAM_URL="${bastille_url_hardenedbsd}${HW_MACHINE}/${HW_MACHINE_ARCH}/hardenedbsd-${NAME_VERIFY}" UPSTREAM_ALT="http://ftp.freebsd.org/pub/FreeBSD/releases/" validate_release_url ;; diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 2f3dd4e1..bf170c52 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -32,7 +32,7 @@ . /usr/local/etc/bastille/bastille.conf usage() { - echo -e "${COLOR_RED}Usage: bastille destroy [container|release]${COLOR_RESET}" + echo -e "${COLOR_RED}Usage: bastille destroy [option] | [container|release]${COLOR_RESET}" exit 1 } @@ -41,9 +41,13 @@ destroy_jail() { bastille_jail_log="${bastille_logsdir}/${TARGET}_console.log" ## file if [ "$(jls name | awk "/^${TARGET}$/")" ]; then - echo -e "${COLOR_RED}Jail running.${COLOR_RESET}" - echo -e "${COLOR_RED}See 'bastille stop ${TARGET}'.${COLOR_RESET}" - exit 1 + if [ "${FORCE_STOP}" = "1" ]; then + bastille stop ${TARGET} + else + echo -e "${COLOR_RED}Jail running.${COLOR_RESET}" + echo -e "${COLOR_RED}See 'bastille stop ${TARGET}'.${COLOR_RESET}" + exit 1 + fi fi if [ ! -d "${bastille_jail_base}" ]; then @@ -136,11 +140,28 @@ help|-h|--help) ;; esac -if [ $# -gt 1 ] || [ $# -lt 1 ]; then - usage -fi +OPTION="${1}" +TARGET="${2}" -TARGET="$1" +## handle additional options +case "${OPTION}" in +-f|--forcestop) + if [ $# -gt 2 ] || [ $# -lt 2 ]; then + usage + fi + FORCE_STOP="1" + ;; +-*) + echo -e "${COLOR_RED}Unknown Option.${COLOR_RESET}" + usage + ;; +*) + if [ $# -gt 1 ] || [ $# -lt 1 ]; then + usage + fi + TARGET="${1}" + ;; +esac ## check what should we clean case "${TARGET}" in