mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-25 23:10:33 +01:00
Merge pull request #82 from bsdlme/master
Add "" around variables in test(1) cases to prevent errors when a variable is empty
This commit is contained in:
@@ -69,14 +69,14 @@ fi
|
||||
bootstrap_network_interfaces() {
|
||||
|
||||
## test for both options empty
|
||||
if [ -z ${bastille_jail_loopback} ] && [ -z ${bastille_jail_external} ]; then
|
||||
if [ -z "${bastille_jail_loopback}" ] && [ -z "${bastille_jail_external}" ]; then
|
||||
echo -e "${COLOR_RED}Please set preferred loopback or external interface.${COLOR_RESET}"
|
||||
echo -e "${COLOR_RED}See bastille.conf.${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## test for required variables -- external
|
||||
if [ -z ${bastille_jail_loopback} ] && [ ! -z ${bastille_jail_external} ]; then
|
||||
if [ -z "${bastille_jail_loopback}" ] && [ ! -z "${bastille_jail_external}" ]; then
|
||||
|
||||
## test for existing interface
|
||||
ifconfig ${bastille_jail_external} 2>&1 >/dev/null
|
||||
@@ -101,8 +101,8 @@ bootstrap_network_interfaces() {
|
||||
fi
|
||||
|
||||
## test for required variables -- loopback
|
||||
if [ -z ${bastille_jail_external} ] && [ ! -z ${bastille_jail_loopback} ] && \
|
||||
[ ! -z ${bastille_jail_addr} ]; then
|
||||
if [ -z "${bastille_jail_external}" ] && [ ! -z "${bastille_jail_loopback}" ] && \
|
||||
[ ! -z "${bastille_jail_addr}" ]; then
|
||||
|
||||
echo -e "${COLOR_GREEN}Detecting...${COLOR_RESET}"
|
||||
## test for existing interface
|
||||
@@ -360,11 +360,11 @@ bootstrap_template() {
|
||||
_template=${bastille_templatesdir}/${_user}/${_repo}
|
||||
|
||||
## support for non-git
|
||||
if [ ! -x $(which git) ]; then
|
||||
if [ ! -x "$(which git)" ]; then
|
||||
echo -e "${COLOR_RED}Git not found.${COLOR_RESET}"
|
||||
echo -e "${COLOR_RED}Not yet implemented.${COLOR_RESET}"
|
||||
exit 1
|
||||
elif [ -x $(which git) ]; then
|
||||
elif [ -x "$(which git)" ]; then
|
||||
if [ ! -d "${_template}/.git" ]; then
|
||||
$(which git) clone "${_url}" "${_template}" ||\
|
||||
echo -e "${COLOR_RED}Clone unsuccessful.${COLOR_RESET}"
|
||||
|
||||
@@ -140,10 +140,10 @@ create_jail() {
|
||||
fi
|
||||
|
||||
if [ ! -f "${bastille_jail_conf}" ]; then
|
||||
if [ -z ${bastille_jail_loopback} ] && [ ! -z ${bastille_jail_external} ]; then
|
||||
if [ -z "${bastille_jail_loopback}" ] && [ ! -z "${bastille_jail_external}" ]; then
|
||||
local bastille_jail_conf_interface=${bastille_jail_external}
|
||||
fi
|
||||
if [ ! -z ${bastille_jail_loopback} ] && [ -z ${bastille_jail_external} ]; then
|
||||
if [ ! -z "${bastille_jail_loopback}" ] && [ -z "${bastille_jail_external}" ]; then
|
||||
local bastille_jail_conf_interface=${bastille_jail_interface}
|
||||
fi
|
||||
if [ ! -z ${INTERFACE} ]; then
|
||||
@@ -374,7 +374,7 @@ if running_jail ${NAME}; then
|
||||
fi
|
||||
|
||||
## check if ip address is valid
|
||||
if [ ! -z ${IP} ]; then
|
||||
if [ ! -z "${IP}" ]; then
|
||||
validate_ip
|
||||
else
|
||||
usage
|
||||
|
||||
@@ -68,7 +68,7 @@ for _jail in ${JAILS}; do
|
||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
||||
|
||||
## add ip4.addr to firewall table:jails
|
||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||
if [ ! -z "${bastille_jail_loopback}" ]; then
|
||||
pfctl -q -t jails -T add $(jls -j ${_jail} ip4.addr)
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -65,7 +65,7 @@ for _jail in ${JAILS}; do
|
||||
## test if running
|
||||
elif [ $(jls name | grep -w "${_jail}") ]; then
|
||||
## 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)
|
||||
fi
|
||||
|
||||
|
||||
@@ -65,6 +65,11 @@ if [ ! -d "${bastille_templatesdir}/${TEMPLATE}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${JAILS}" ]; then
|
||||
echo -e "${COLOR_RED}Container ${TARGET} is not running.${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## global variables
|
||||
bastille_template=${bastille_templatesdir}/${TEMPLATE}
|
||||
for _jail in ${JAILS}; do
|
||||
|
||||
@@ -56,7 +56,7 @@ verify_template() {
|
||||
|
||||
for _hook in TARGET INCLUDE PRE OVERLAY FSTAB PF PKG SYSRC SERVICE CMD; do
|
||||
_path=${_template_path}/${_hook}
|
||||
if [ -s ${_path} ]; then
|
||||
if [ -s "${_path}" ]; then
|
||||
_hook_validate=$((_hook_validate+1))
|
||||
echo -e "${COLOR_GREEN}Detected ${_hook} hook.${COLOR_RESET}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user