Merge pull request #89 from JRGTH/master

Minor changes, fix notify if container not started
This commit is contained in:
Christer Edwards
2020-01-08 13:31:34 -07:00
committed by GitHub
3 changed files with 16 additions and 12 deletions
+10 -6
View File
@@ -37,7 +37,13 @@ usage() {
} }
running_jail() { running_jail() {
jls name | grep -w "${NAME}" if [ -n "$(jls name | awk "/^${NAME}$/")" ]; then
echo -e "${COLOR_RED}A running jail matches name.${COLOR_RESET}"
exit 1
elif [ -d "${bastille_jailsdir}/${NAME}" ]; then
echo -e "${COLOR_RED}Jail: ${NAME} already created.${COLOR_RESET}"
exit 1
fi
} }
validate_ip() { validate_ip() {
@@ -366,11 +372,9 @@ if [ ! -d "${bastille_releasesdir}/${RELEASE}" ]; then
exit 1 exit 1
fi fi
## check if a running jail matches name ## check if a running jail matches name or already exist
if running_jail ${NAME}; then if [ -n "${NAME}" ]; then
echo -e "${COLOR_RED}A running jail matches name.${COLOR_RESET}" running_jail
echo -e "${COLOR_RED}Jails must be stopped before they are destroyed.${COLOR_RESET}"
exit 1
fi fi
## check if ip address is valid ## check if ip address is valid
+1 -1
View File
@@ -40,7 +40,7 @@ destroy_jail() {
bastille_jail_base="${bastille_jailsdir}/${NAME}" ## dir bastille_jail_base="${bastille_jailsdir}/${NAME}" ## dir
bastille_jail_log="${bastille_logsdir}/${NAME}_console.log" ## file bastille_jail_log="${bastille_logsdir}/${NAME}_console.log" ## file
if [ $(jls name | grep -w "${NAME}") ]; then if [ "$(jls name | awk "/^${NAME}$/")" ]; then
echo -e "${COLOR_RED}Jail running.${COLOR_RESET}" echo -e "${COLOR_RED}Jail running.${COLOR_RESET}"
echo -e "${COLOR_RED}See 'bastille stop ${NAME}'.${COLOR_RESET}" echo -e "${COLOR_RED}See 'bastille stop ${NAME}'.${COLOR_RESET}"
exit 1 exit 1
+5 -5
View File
@@ -55,15 +55,15 @@ if [ "${TARGET}" = 'ALL' ]; then
fi fi
if [ "${TARGET}" != 'ALL' ]; then if [ "${TARGET}" != 'ALL' ]; then
JAILS=$(jls name | awk "/^${TARGET}$/") JAILS=$(jls name | awk "/^${TARGET}$/")
## test if not running
if [ ! "$(jls name | awk "/^${TARGET}$/")" ]; then
echo -e "${COLOR_RED}[${TARGET}]: Not started.${COLOR_RESET}"
fi
fi fi
for _jail in ${JAILS}; do for _jail in ${JAILS}; do
## test if not running
if [ ! "$(jls name | awk "/^${_jail}$/")" ]; then
echo -e "${COLOR_RED}[${_jail}]: Not started.${COLOR_RESET}"
## test if running ## test if running
elif [ "$(jls name | awk "/^${_jail}$/")" ]; then if [ "$(jls name | awk "/^${_jail}$/")" ]; then
## remove ip4.addr from firewall table:jails ## remove ip4.addr from firewall table:jails
if [ ! -z "${bastille_jail_loopback}" ]; then if [ ! -z "${bastille_jail_loopback}" ]; then
pfctl -q -t jails -T delete $(jls -j ${_jail} ip4.addr) pfctl -q -t jails -T delete $(jls -j ${_jail} ip4.addr)