mirror of
https://github.com/JRGTH/xigmanas-bastille-extension.git
synced 2025-12-11 01:10:57 +01:00
Re-add release change and code improvements
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
======================
|
======================
|
||||||
Version Description
|
Version Description
|
||||||
|
|
||||||
|
1.1.52......Re-add Thin jail release change and code improvements.
|
||||||
1.1.51......Code update/improvements, update jail config/util pages and bastille-init.
|
1.1.51......Code update/improvements, update jail config/util pages and bastille-init.
|
||||||
1.1.50......Disable linux_compat due incompatibility with later releases.
|
1.1.50......Disable linux_compat due incompatibility with later releases.
|
||||||
1.1.49......Disable basic interface to comply with bastille new syntax.
|
1.1.49......Disable basic interface to comply with bastille new syntax.
|
||||||
|
|||||||
@@ -727,10 +727,15 @@ release_upgrade()
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
# Upgrade a release base.
|
# Upgrade a release base.
|
||||||
|
if [ -n "${_forceopt}" ]; then
|
||||||
|
echo "Performing a forced release upgrade..."
|
||||||
|
else
|
||||||
|
echo "Performing a release upgrade..."
|
||||||
|
fi
|
||||||
echo "=> Run the command below several times when asked to finish installing updates."
|
echo "=> Run the command below several times when asked to finish installing updates."
|
||||||
echo "bastille-init install ${TARGET}"
|
echo "bastille-init install ${TARGET}"
|
||||||
echo
|
echo
|
||||||
env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \
|
env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update ${_forceopt} --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \
|
||||||
-d ${CWDIR}/freebsd-update -b "${bastille_releasesdir}/${TARGET}" --currently-running "${TARGET}" -r ${RELEASE} upgrade
|
-d ${CWDIR}/freebsd-update -b "${bastille_releasesdir}/${TARGET}" --currently-running "${TARGET}" -r ${RELEASE} upgrade
|
||||||
echo
|
echo
|
||||||
echo "=> Please run: 'bastille-init install ${TARGET}' to finish installing updates."
|
echo "=> Please run: 'bastille-init install ${TARGET}' to finish installing updates."
|
||||||
@@ -847,11 +852,16 @@ thickjail_upgrade()
|
|||||||
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.
|
||||||
|
if [ -n "${_forceopt}" ]; then
|
||||||
|
echo "Performing a forced jail upgrade..."
|
||||||
|
else
|
||||||
|
echo "Performing a jail upgrade..."
|
||||||
|
fi
|
||||||
echo "=> Run the command below several times when asked to finish installing updates."
|
echo "=> Run the command below several times when asked to finish installing updates."
|
||||||
echo "bastille-init install ${TARGET}"
|
echo "bastille-init install ${TARGET}"
|
||||||
echo
|
echo
|
||||||
CURRENT_VERSION=$(jexec -l ${TARGET} freebsd-version)
|
CURRENT_VERSION=$(jexec -l ${TARGET} freebsd-version)
|
||||||
env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \
|
env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update ${_forceopt} --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \
|
||||||
-d ${CWDIR}/freebsd-update -b "${bastille_jailsdir}/${TARGET}/root" --currently-running "${CURRENT_VERSION}" -r ${RELEASE} upgrade
|
-d ${CWDIR}/freebsd-update -b "${bastille_jailsdir}/${TARGET}/root" --currently-running "${CURRENT_VERSION}" -r ${RELEASE} upgrade
|
||||||
echo
|
echo
|
||||||
echo "=> Please run: 'bastille-init install ${TARGET}' to finish installing updates."
|
echo "=> Please run: 'bastille-init install ${TARGET}' to finish installing updates."
|
||||||
@@ -1441,6 +1451,24 @@ upgrade|--upgrade)
|
|||||||
fi
|
fi
|
||||||
release_change
|
release_change
|
||||||
fi
|
fi
|
||||||
|
_forceopt=
|
||||||
|
;;
|
||||||
|
upgrade_force|--upgrade-force)
|
||||||
|
# Check container type to upgrade
|
||||||
|
if [ -z "${NEWRELEASE}" ]; then
|
||||||
|
if [ $# -gt 3 ] || [ $# -lt 3 ]; then
|
||||||
|
echo "Usage: ${SCRIPTNAME} [upgrade_force|--upgrade-force] [container|release] [release]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
thickjail_upgrade
|
||||||
|
else
|
||||||
|
if [ $# -gt 4 ] || [ $# -lt 4 ]; then
|
||||||
|
echo "Usage: ${SCRIPTNAME} [upgrade_force|--upgrade-force] [container] [release] [newrelease]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
release_change
|
||||||
|
fi
|
||||||
|
_forceopt="-F"
|
||||||
;;
|
;;
|
||||||
update|--update)
|
update|--update)
|
||||||
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
||||||
@@ -1494,11 +1522,12 @@ while getopts ":ospruxUvgtZh" option; do
|
|||||||
echo
|
echo
|
||||||
echo "Advanced Usage: ${SCRIPTNAME} [option] [container] [release] | [newrelease]"
|
echo "Advanced Usage: ${SCRIPTNAME} [option] [container] [release] | [newrelease]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " update|--update Update a container/release to base -pX release."
|
echo " update|--update Update a container/release to base -pX release."
|
||||||
echo " update_force|--update-force Update a container/release to base -pX release forcefully."
|
echo " update_force|--update-force Update a container/release to base -pX release forcefully."
|
||||||
echo " upgrade|--upgrade Upgrade a container/release to X.Y-RELEASE."
|
echo " upgrade|--upgrade Upgrade a container/release to X.Y-RELEASE."
|
||||||
echo " install|--install Finish installing pending updates on container/release."
|
echo " upgrade_force|--upgrade-force Upgrade a container/release to X.Y-RELEASE. forcefully"
|
||||||
echo " clean|--clean Cleanup the FreeBSD update/upgrade cached files/folders."
|
echo " install|--install Finish installing pending updates on container/release."
|
||||||
|
echo " clean|--clean Cleanup the FreeBSD update/upgrade cached files/folders."
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Experimental:"
|
echo "Experimental:"
|
||||||
|
|||||||
@@ -258,6 +258,35 @@ if($_POST):
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'base':
|
||||||
|
// Input validation not required
|
||||||
|
if(empty($input_errors)):
|
||||||
|
$container = [];
|
||||||
|
$container['uuid'] = $_POST['uuid'];
|
||||||
|
$container['jailname'] = $_POST['jailname'];
|
||||||
|
$item = $container['jailname'];
|
||||||
|
$current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$item}/fstab | awk '{print $1}' | grep -o '[^/]*$'");
|
||||||
|
$new_release = $pconfig['release'];
|
||||||
|
|
||||||
|
if(!$current_release):
|
||||||
|
$savemsg .= gtext("This is a thick container and should be interactively upgraded through the command line.");
|
||||||
|
else:
|
||||||
|
$cmd = ("/usr/local/sbin/bastille-init --upgrade {$item} {$current_release} {$new_release}");
|
||||||
|
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
|
if($retval == 0):
|
||||||
|
$savemsg .= sprintf(gtext("Container base release changed to %s successfully."),$new_release);
|
||||||
|
exec("/usr/local/bin/bastille config {$item} set osrelease $new_release");
|
||||||
|
exec("echo '{$date}: {$application}: Container base release changed to {$new_release} on {$item} successfully' >> {$logfile}");
|
||||||
|
//header('Location: bastille_manager_gui.php');
|
||||||
|
//exit;
|
||||||
|
else:
|
||||||
|
$input_errors[] = sprintf(gtext("Failed to change container base release to %s, either it is running or is not a thin container."),$new_release);
|
||||||
|
exec("echo '{$date}: {$application}: Failed to change container base release to {$new_release} on {$item}' >> {$logfile}");
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'autoboot':
|
case 'autoboot':
|
||||||
// Input validation not required
|
// Input validation not required
|
||||||
if(empty($input_errors)):
|
if(empty($input_errors)):
|
||||||
@@ -444,6 +473,8 @@ function action_change() {
|
|||||||
showElementById('readonly_tr', 'hide');
|
showElementById('readonly_tr', 'hide');
|
||||||
showElementById('createdir_tr', 'hide');
|
showElementById('createdir_tr', 'hide');
|
||||||
showElementById('automount_tr', 'hide');
|
showElementById('automount_tr', 'hide');
|
||||||
|
showElementById('jail_release_tr', 'hide');
|
||||||
|
showElementById('release_tr','hide');
|
||||||
showElementById('update_base_tr','hide');
|
showElementById('update_base_tr','hide');
|
||||||
showElementById('update_jail_tr','hide');
|
showElementById('update_jail_tr','hide');
|
||||||
showElementById('update_base_force_tr', 'hide');
|
showElementById('update_base_force_tr', 'hide');
|
||||||
@@ -475,6 +506,10 @@ function action_change() {
|
|||||||
showElementById('update_base_force_tr', 'show');
|
showElementById('update_base_force_tr', 'show');
|
||||||
showElementById('update_jail_force_tr', 'show');
|
showElementById('update_jail_force_tr', 'show');
|
||||||
break;
|
break;
|
||||||
|
case "base":
|
||||||
|
showElementById('jail_release_tr', 'show');
|
||||||
|
showElementById('release_tr','show');
|
||||||
|
break;
|
||||||
case "autoboot":
|
case "autoboot":
|
||||||
showElementById('auto_boot_tr', 'show');
|
showElementById('auto_boot_tr', 'show');
|
||||||
break;
|
break;
|
||||||
@@ -545,7 +580,23 @@ $document->render();
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$b_action = $l_release;
|
||||||
|
#$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null");
|
||||||
|
$current_release = "";
|
||||||
|
$disable_base_change = "no";
|
||||||
|
$current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$pconfig['jailname']}/fstab | awk '{print $1}' | grep -o '[^/]*$'");
|
||||||
$is_thinjail = exec("/usr/bin/grep -w '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab");
|
$is_thinjail = exec("/usr/bin/grep -w '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab");
|
||||||
|
if (!$current_release):
|
||||||
|
$current_release = exec("/usr/bin/grep 'releng' {$jail_dir}/{$pconfig['jailname']}/root/COPYRIGHT | cut -d '/' -f2");
|
||||||
|
if(!$current_release):
|
||||||
|
//Assume is a running thickjail.
|
||||||
|
$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null");
|
||||||
|
endif;
|
||||||
|
$disable_base_change = "yes";
|
||||||
|
if (!$current_release):
|
||||||
|
$current_release = "-";
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
$pconfig['source_path'] = "";
|
$pconfig['source_path'] = "";
|
||||||
$pconfig['target_path'] = "{$rootfolder}/jails/{$pconfig['jailname']}/root/mnt/";
|
$pconfig['target_path'] = "{$rootfolder}/jails/{$pconfig['jailname']}/root/mnt/";
|
||||||
html_text2('jailname',gettext('Container name:'),htmlspecialchars($pconfig['jailname']));
|
html_text2('jailname',gettext('Container name:'),htmlspecialchars($pconfig['jailname']));
|
||||||
@@ -553,6 +604,7 @@ $document->render();
|
|||||||
'backup' => gettext('Backup'),
|
'backup' => gettext('Backup'),
|
||||||
'clone' => gettext('Clone'),
|
'clone' => gettext('Clone'),
|
||||||
'update' => gettext('Update'),
|
'update' => gettext('Update'),
|
||||||
|
'base' => gettext('Release'),
|
||||||
'autoboot' => gettext('Autoboot'),
|
'autoboot' => gettext('Autoboot'),
|
||||||
'noauto' => gettext('Noauto'),
|
'noauto' => gettext('Noauto'),
|
||||||
'priority' => gettext('Priority'),
|
'priority' => gettext('Priority'),
|
||||||
@@ -603,9 +655,14 @@ $document->render();
|
|||||||
html_checkbox2('update_jail',gettext('Container update confirm:'),!empty($pconfig['update_jail']) ? true : false,gettext('This is a thick container, therefore the update will be performed within its root, current containers are not affected.'),'',true);
|
html_checkbox2('update_jail',gettext('Container update confirm:'),!empty($pconfig['update_jail']) ? true : false,gettext('This is a thick container, therefore the update will be performed within its root, current containers are not affected.'),'',true);
|
||||||
html_checkbox2('update_jail_force',gettext('Container update force confirm:'),!empty($pconfig['update_jail']) ? true : false,gettext('This will perform a forced jail update, current containers are not affected.'),'',true);
|
html_checkbox2('update_jail_force',gettext('Container update force confirm:'),!empty($pconfig['update_jail']) ? true : false,gettext('This will perform a forced jail update, current containers are not affected.'),'',true);
|
||||||
endif;
|
endif;
|
||||||
|
html_text2('jail_release',gettext('Current base release:'),htmlspecialchars($current_release));
|
||||||
html_text2('auto_boot',gettext('Enable container auto-startup'),htmlspecialchars("This will cause the container to automatically start each time the system restart."));
|
html_text2('auto_boot',gettext('Enable container auto-startup'),htmlspecialchars("This will cause the container to automatically start each time the system restart."));
|
||||||
html_text2('no_autoboot',gettext('Disable container auto-startup'),htmlspecialchars("This will disable the container automatic startup."));
|
html_text2('no_autoboot',gettext('Disable container auto-startup'),htmlspecialchars("This will disable the container automatic startup."));
|
||||||
html_text2('backup',gettext('Export container'),htmlspecialchars("This will export a container to a compressed file/image, please execute `bastille export` for more info in regards exporting formats, Default is .XZ on ZFS setups or .TXZ otherwise, For faster compressed backups consider .GZ/.TGZ."));
|
html_text2('backup',gettext('Export container'),htmlspecialchars("This will export a container to a compressed file/image, please execute `bastille export` for more info in regards exporting formats, Default is .XZ on ZFS setups or .TXZ otherwise, For faster compressed backups consider .GZ/.TGZ."));
|
||||||
|
|
||||||
|
if ($disable_base_change == "no"):
|
||||||
|
html_combobox2('release',gettext('New base release'),!empty($pconfig['release']),$b_action,gettext("Warning: This will change current shared base to the selected base on the thin container only, the user is responsible for package updates and/or general incompatibilities issues, or use the command line for native upgrade."),true,false,);
|
||||||
|
endif;
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user