Fix for properly identify the jail type

This commit is contained in:
Jose
2020-08-17 09:49:36 -04:00
parent c2b74495d9
commit d1afecf699
4 changed files with 9 additions and 8 deletions
+1
View File
@@ -3,6 +3,7 @@
====================== ======================
Version Description Version Description
1.0.67......Fix for properly identify the jail type, thanks to mvdhoeven.
1.0.66......Update extension and bastille config files at once. 1.0.66......Update extension and bastille config files at once.
1.0.65......Add ability to create empty containers, minor improvements. 1.0.65......Add ability to create empty containers, minor improvements.
1.0.64......Switch back to official bastille repository, simplify initial help banner. 1.0.64......Switch back to official bastille repository, simplify initial help banner.
+6 -6
View File
@@ -560,7 +560,7 @@ jail_update()
fi fi
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
# Update a thick container. # Update a thick container.
@@ -622,15 +622,15 @@ thinjail_upgrade()
if [ -f "${bastille_releasesdir}/${NEWRELEASE}/COPYRIGHT" ]; then if [ -f "${bastille_releasesdir}/${NEWRELEASE}/COPYRIGHT" ]; then
if [ -f "${bastille_jailsdir}/${TARGET}/fstab" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/fstab" ]; then
# Check if is a thin container. # Check if is a thin container.
if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${RELEASE}" | grep -q ".bastille"; then if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${RELEASE}" | grep -qw "/.*/.bastille"; then
# If the previous conditions meets, proceed with the container base upgrade. # If the previous conditions meets, proceed with the container base upgrade.
sed -i '' "s/${RELEASE}/${NEWRELEASE}/g" ${bastille_jailsdir}/${TARGET}/fstab sed -i '' "s/${RELEASE}/${NEWRELEASE}/g" ${bastille_jailsdir}/${TARGET}/fstab
echo "${TARGET} release changed to ${NEWRELEASE}." echo "${TARGET} release changed to ${NEWRELEASE}."
elif cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${NEWRELEASE}" | grep -q ".bastille"; then elif cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${NEWRELEASE}" | grep -qw "/.*/.bastille"; then
echo "${TARGET} already using ${NEWRELEASE}." echo "${TARGET} already using ${NEWRELEASE}."
exit 0 exit 0
else else
if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep -q ".bastille"; then if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep -qw "/.*/.bastille"; then
echo "${TARGET} container does not use ${RELEASE}."; exit 1 echo "${TARGET} container does not use ${RELEASE}."; exit 1
else else
echo "${TARGET} is not a thin container."; exit 1 echo "${TARGET} is not a thin container."; exit 1
@@ -681,7 +681,7 @@ thickjail_upgrade()
# Verify for user input and handle some errors. # Verify for user input and handle some errors.
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
# Upgrade a thick container. # Upgrade a thick container.
@@ -729,7 +729,7 @@ thickjail_install()
fi fi
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
# Finish installing upgrade on a thick container. # Finish installing upgrade on a thick container.
+1 -1
View File
@@ -436,7 +436,7 @@ $document->render();
#$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null"); #$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null");
unset($disable_base_change); unset($disable_base_change);
$current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$pconfig['jailname']}/fstab | awk '{print $1}' | grep -o '[^/]*$'"); $current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$pconfig['jailname']}/fstab | awk '{print $1}' | grep -o '[^/]*$'");
$is_thickjail = exec("/usr/bin/grep '.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab"); $is_thickjail = exec("/usr/bin/grep -qw '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab");
if (!$current_release): if (!$current_release):
$current_release = exec("/usr/bin/grep 'releng' {$jail_dir}/{$pconfig['jailname']}/root/COPYRIGHT | cut -d '/' -f2"); $current_release = exec("/usr/bin/grep 'releng' {$jail_dir}/{$pconfig['jailname']}/root/COPYRIGHT | cut -d '/' -f2");
$disable_base_change = "1"; $disable_base_change = "1";
+1 -1
View File
@@ -1 +1 @@
1.0.66 1.0.67