mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-19 16:51:00 +01:00
Code review/cleanup routine
This commit is contained in:
@@ -436,10 +436,10 @@ ubuntu_bionic|bionic|ubuntu-bionic)
|
||||
warn "linprocfs_load, linsysfs_load, tmpfs_load not enabled in /boot/loader.conf or linux_enable not active. Should I do that for you? (N|y)"
|
||||
read answer
|
||||
case $answer in
|
||||
no|No|n|N|"")
|
||||
[Nn][Oo]|[Nn]|"")
|
||||
error_exit "Exiting."
|
||||
;;
|
||||
yes|Yes|y|Y)
|
||||
[Yy][Ee][Ss]|[Yy])
|
||||
info "Loading modules"
|
||||
kldload linux linux64 linprocfs linsysfs tmpfs
|
||||
info "Persisting modules"
|
||||
@@ -456,10 +456,10 @@ ubuntu_bionic|bionic|ubuntu-bionic)
|
||||
warn "Debootstrap not found. Should it be installed? (N|y)"
|
||||
read answer
|
||||
case $answer in
|
||||
no|No|n|N|"")
|
||||
[Nn][Oo]|[Nn]|"")
|
||||
error_exit "Exiting. You need to install debootstap before boostrapping a Linux jail."
|
||||
;;
|
||||
yes|Yes|y|Y)
|
||||
[Yy][Ee][Ss]|[Yy])
|
||||
pkg install -y debootstrap
|
||||
debootstrap --foreign --arch=amd64 --no-check-gpg bionic "${bastille_releasesdir}"/Ubuntu_1804
|
||||
;;
|
||||
@@ -474,10 +474,10 @@ ubuntu_focal|focal|ubuntu-focal)
|
||||
warn "linprocfs_load, linsysfs_load, tmpfs_load not enabled in /boot/loader.conf or linux_enable not active. Should I do that for you? (N|y)"
|
||||
read answer
|
||||
case $answer in
|
||||
no|No|n|N|"")
|
||||
[Nn][Oo]|[Nn]|"")
|
||||
error_exit "Exiting."
|
||||
;;
|
||||
yes|Yes|y|Y)
|
||||
[Yy][Ee][Ss]|[Yy])
|
||||
info "Loading modules"
|
||||
kldload linux linux64 linprocfs linsysfs tmpfs
|
||||
info "Persisting modules"
|
||||
@@ -494,10 +494,10 @@ ubuntu_focal|focal|ubuntu-focal)
|
||||
warn "Debootstrap not found. Should it be installed? (N|y)"
|
||||
read answer
|
||||
case $answer in
|
||||
no|No|n|N|"")
|
||||
[Nn][Oo]|[Nn]|"")
|
||||
error_exit "Exiting. You need to install debootstap before boostrapping a Linux jail."
|
||||
;;
|
||||
yes|Yes|y|Y)
|
||||
[Yy][Ee][Ss]|[Yy])
|
||||
pkg install -y debootstrap
|
||||
debootstrap --foreign --arch=amd64 --no-check-gpg focal "${bastille_releasesdir}"/Ubuntu_2004
|
||||
;;
|
||||
|
||||
@@ -76,7 +76,7 @@ for _jail in ${JAILS}; do
|
||||
MATCH_FOUND=$?
|
||||
|
||||
if [ "${ACTION}" = 'get' ]; then
|
||||
if [ $MATCH_FOUND -ne 0 ]; then
|
||||
if [ "${MATCH_FOUND}" -ne 0 ]; then
|
||||
warn "not set"
|
||||
elif ! echo "${MATCH_LINE}" | grep '=' > /dev/null 2>&1; then
|
||||
echo "enabled"
|
||||
@@ -99,7 +99,7 @@ for _jail in ${JAILS}; do
|
||||
LINE=" ${PROPERTY};"
|
||||
fi
|
||||
|
||||
if [ $MATCH_FOUND -ne 0 ]; then # No match, so insert the property at the end. -- cwells
|
||||
if [ "${MATCH_FOUND}" -ne 0 ]; then # No match, so insert the property at the end. -- cwells
|
||||
echo "$(awk -v line="${LINE}" '$0 == "}" { print line; } 1 { print $0; }' "${FILE}")" > "${FILE}"
|
||||
else # Replace the existing value. -- cwells
|
||||
sed -i '' -E "s/ *${ESCAPED_PROPERTY}[ =;].*/${LINE}/" "${FILE}"
|
||||
|
||||
@@ -358,8 +358,7 @@ create_jail() {
|
||||
FILE_LIST=".cshrc .profile COPYRIGHT dev etc media mnt net proc root tmp var usr/obj usr/tests"
|
||||
for files in ${FILE_LIST}; do
|
||||
if [ -f "${bastille_releasesdir}/${RELEASE}/${files}" ] || [ -d "${bastille_releasesdir}/${RELEASE}/${files}" ]; then
|
||||
cp -a "${bastille_releasesdir}/${RELEASE}/${files}" "${bastille_jail_path}/${files}"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
if ! cp -a "${bastille_releasesdir}/${RELEASE}/${files}" "${bastille_jail_path}/${files}"; then
|
||||
## notify and clean stale files/directories
|
||||
bastille destroy "${NAME}"
|
||||
error_exit "Failed to copy release files. Please retry create!"
|
||||
|
||||
@@ -47,7 +47,7 @@ fi
|
||||
|
||||
for _jail in ${JAILS}; do
|
||||
info "[${_jail}]:"
|
||||
if [ -f /usr/sbin/pkg ]; then
|
||||
if [ -f "/usr/sbin/pkg" ]; then
|
||||
jexec -l "${_jail}" /usr/sbin/pkg "$@"
|
||||
else
|
||||
jexec -l "${_jail}" /usr/sbin/mport "$@"
|
||||
|
||||
@@ -64,7 +64,7 @@ if [ "${TARGET}" = "ALL" ]; then
|
||||
error_exit "Batch upgrade is unsupported."
|
||||
fi
|
||||
|
||||
if [ -f /bin/midnightbsd-version ]; then
|
||||
if [ -f "/bin/midnightbsd-version" ]; then
|
||||
echo -e "${COLOR_RED}Not yet supported on MidnightBSD.${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -55,7 +55,7 @@ if [ "${TARGET}" = "ALL" ]; then
|
||||
error_exit "Batch upgrade is unsupported."
|
||||
fi
|
||||
|
||||
if [ -f /bin/midnightbsd-version ]; then
|
||||
if [ -f "/bin/midnightbsd-version" ]; then
|
||||
echo -e "${COLOR_RED}Not yet supported on MidnightBSD.${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -36,7 +36,7 @@ bastille_usage() {
|
||||
}
|
||||
|
||||
verify_release() {
|
||||
if [ -f /bin/midnightbsd-version ]; then
|
||||
if [ -f "/bin/midnightbsd-version" ]; then
|
||||
echo -e "${COLOR_RED}Not yet supported on MidnightBSD.${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
@@ -69,7 +69,7 @@ verify_template() {
|
||||
echo
|
||||
error_exit "Template validation failed."
|
||||
## if INCLUDE; recursive verify
|
||||
elif [ ${_hook} = 'INCLUDE' ]; then
|
||||
elif [ "${_hook}" = 'INCLUDE' ]; then
|
||||
info "[${_hook}]:"
|
||||
cat "${_path}"
|
||||
echo
|
||||
@@ -92,13 +92,13 @@ verify_template() {
|
||||
done < "${_path}"
|
||||
|
||||
## if tree; tree -a bastille_template/_dir
|
||||
elif [ ${_hook} = 'OVERLAY' ]; then
|
||||
elif [ "${_hook}" = 'OVERLAY' ]; then
|
||||
info "[${_hook}]:"
|
||||
cat "${_path}"
|
||||
echo
|
||||
while read _dir; do
|
||||
info "[${_hook}]:[${_dir}]:"
|
||||
if [ -x /usr/local/bin/tree ]; then
|
||||
if [ -x "/usr/local/bin/tree" ]; then
|
||||
/usr/local/bin/tree -a "${_template_path}/${_dir}"
|
||||
else
|
||||
find "${_template_path}/${_dir}" -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'
|
||||
@@ -114,7 +114,7 @@ verify_template() {
|
||||
done
|
||||
|
||||
## remove bad templates
|
||||
if [ ${_hook_validate} -lt 1 ]; then
|
||||
if [ "${_hook_validate}" -lt 1 ]; then
|
||||
error_notify "No valid template hooks found."
|
||||
error_notify "Template discarded."
|
||||
rm -rf "${bastille_template}"
|
||||
@@ -122,7 +122,7 @@ verify_template() {
|
||||
fi
|
||||
|
||||
## if validated; ready to use
|
||||
if [ ${_hook_validate} -gt 0 ]; then
|
||||
if [ "${_hook_validate}" -gt 0 ]; then
|
||||
info "Template ready to use."
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user