Add initial ZFS activation guided support
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
======================
|
======================
|
||||||
Version Description
|
Version Description
|
||||||
|
|
||||||
|
1.0.53......Add initial ZFS activation guided support.
|
||||||
1.0.52......Switch repository for early updates and bug fixes.
|
1.0.52......Switch repository for early updates and bug fixes.
|
||||||
1.0.51......Jail rename to last position, prevent for null autoboot variables.
|
1.0.51......Jail rename to last position, prevent for null autoboot variables.
|
||||||
1.0.50......Cosmetic changes, add misc configuration row to jail quick config.
|
1.0.50......Cosmetic changes, add misc configuration row to jail quick config.
|
||||||
|
|||||||
+81
-64
@@ -9,7 +9,7 @@
|
|||||||
# Debug script
|
# Debug script
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
# Copyright (c) 2019, José Rivera (joserprg@gmail.com).
|
# Copyright (c) 2019-2020, José Rivera (joserprg@gmail.com).
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,6 +43,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
|||||||
CWDIR=$(dirname $(realpath $0))
|
CWDIR=$(dirname $(realpath $0))
|
||||||
|
|
||||||
# Global variables.
|
# Global variables.
|
||||||
|
CWDIR_TRIM=""
|
||||||
PLATFORM=$(uname -m)
|
PLATFORM=$(uname -m)
|
||||||
PRODUCT=$(uname -i)
|
PRODUCT=$(uname -i)
|
||||||
PRDVERSION=$(uname -r | cut -d '-' -f1 | tr -d '.')
|
PRDVERSION=$(uname -r | cut -d '-' -f1 | tr -d '.')
|
||||||
@@ -76,9 +77,13 @@ GITURL="https://github.com/JRGTH/xigmanas-${APPNAME}-extension/archive/${BRANCH}
|
|||||||
VERFILE="https://raw.githubusercontent.com/JRGTH/xigmanas-${APPNAME}-extension/${BRANCH}/version"
|
VERFILE="https://raw.githubusercontent.com/JRGTH/xigmanas-${APPNAME}-extension/${BRANCH}/version"
|
||||||
OPT="${1}"
|
OPT="${1}"
|
||||||
|
|
||||||
# Required
|
# Bastille required
|
||||||
if [ -f "${BASTILLECONF}" ]; then
|
if [ -f "${BASTILLECONF}" ]; then
|
||||||
. /${BASTILLECONF}
|
. /${BASTILLECONF}
|
||||||
|
# Always enforce ZFS activation below "/mnt/" from the extension.
|
||||||
|
if echo "${CWDIR}" | grep -q '/mnt/'; then
|
||||||
|
CWDIR_TRIM=$(echo "${CWDIR}" | sed "s|/mnt/||;s|/${bastille_zfs_prefix}||")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
error_notify()
|
error_notify()
|
||||||
@@ -102,13 +107,13 @@ runtime_config()
|
|||||||
if [ ! -d ${CWDIR}/backups ]; then
|
if [ ! -d ${CWDIR}/backups ]; then
|
||||||
mkdir -p ${CWDIR}/backups
|
mkdir -p ${CWDIR}/backups
|
||||||
fi
|
fi
|
||||||
if [ ! -d ${CWDIR}/conf ]; then
|
if [ ! -d "${CWDIR}/conf" ]; then
|
||||||
mkdir -p ${CWDIR}/conf
|
mkdir -p ${CWDIR}/conf
|
||||||
fi
|
fi
|
||||||
if [ ! -d ${CWDIR}/log ]; then
|
if [ ! -d "${CWDIR}/log" ]; then
|
||||||
mkdir -p ${CWDIR}/log
|
mkdir -p ${CWDIR}/log
|
||||||
fi
|
fi
|
||||||
if [ ! -d ${CWDIR}/locale-bastille ]; then
|
if [ ! -d "${CWDIR}/locale-bastille" ]; then
|
||||||
mkdir -p ${CWDIR}/locale-bastille
|
mkdir -p ${CWDIR}/locale-bastille
|
||||||
fi
|
fi
|
||||||
if [ ! -d "${CWDIR}/freebsd-update" ]; then
|
if [ ! -d "${CWDIR}/freebsd-update" ]; then
|
||||||
@@ -116,10 +121,12 @@ runtime_config()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for permissions.
|
# Check for permissions.
|
||||||
FREEBSD_UPDATE_PERMS=$(stat -f "%Op" ${FREEBSD_UPDATE}/freebsd-update)
|
if [ -f "${FREEBSD_UPDATE}/freebsd-update" ]; then
|
||||||
if [ "${FREEBSD_UPDATE_PERMS}" != 100555 ]; then
|
FREEBSD_UPDATE_PERMS=$(stat -f "%Op" ${FREEBSD_UPDATE}/freebsd-update)
|
||||||
chmod 0555 ${FREEBSD_UPDATE}/freebsd-update
|
if [ "${FREEBSD_UPDATE_PERMS}" != 100555 ]; then
|
||||||
fi
|
chmod 0555 ${FREEBSD_UPDATE}/freebsd-update
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bastille_initial_download()
|
bastille_initial_download()
|
||||||
@@ -699,69 +706,75 @@ thickjail_install()
|
|||||||
zfs_activate()
|
zfs_activate()
|
||||||
{
|
{
|
||||||
# Check if ZFS is already configured.
|
# Check if ZFS is already configured.
|
||||||
BASTILLE_DIR=$(echo ${CWDIR} | grep -o '[^/]*$')
|
# Always enforce ZFS activation below "/mnt/" from the extension.
|
||||||
if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
if echo "${bastille_zfs_zpool}" | grep -qw "${CWDIR_TRIM}$"; then
|
||||||
echo "Bastille ZFS is already configured."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
BASTILLE_DIRS="cache jails logs releases templates"
|
|
||||||
for dir in ${BASTILLE_DIRS}; do
|
|
||||||
if [ -d "${CWDIR}/${dir}" ]; then
|
|
||||||
# Stop if any of the listed dirs already exist.
|
|
||||||
echo "Bastille has been bootstrapped already, aborting."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Enabling ZFS on ${PRDNAME} Extension..."
|
BASTILLE_DIR=$(echo "${CWDIR}" | grep -o '[^/]*$')
|
||||||
# Confirm before conversion.
|
if [ "${bastille_zfs_prefix}" != "${BASTILLE_DIR}" ]; then
|
||||||
while :
|
error_notify "Invalid ZFS configuration."
|
||||||
do
|
fi
|
||||||
read -p "Do you really wish to enable ZFS for ${PRDNAME} Extension? [y/N]:" yn
|
if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
||||||
case ${yn} in
|
echo "Bastille ZFS is already configured."
|
||||||
[Yy]) break;;
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_ACTIVATED="YES" >/dev/null 2>&1
|
||||||
[Nn]) exit 0;;
|
exit 0
|
||||||
esac
|
else
|
||||||
done
|
BASTILLE_DIRS="cache jails logs releases templates"
|
||||||
echo "Proceeding..."
|
for dir in ${BASTILLE_DIRS}; do
|
||||||
|
if [ -d "${CWDIR}/${dir}" ]; then
|
||||||
|
# Stop if any of the listed dirs already exist.
|
||||||
|
error_notify "Bastille has been bootstrapped already, aborting."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${bastille_zfs_enable}" = "YES" ]; then
|
echo "Enabling ZFS on ${PRDNAME} Extension..."
|
||||||
if [ ! -z "${bastille_zfs_zpool}" ]; then
|
# Confirm before conversion.
|
||||||
if zfs list "${bastille_zfs_zpool}" > /dev/null 2>&1; then
|
while :
|
||||||
if ! zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
do
|
||||||
echo "Renaming existing '${BASTILLE_DIR}' directory"
|
read -p "Do you really wish to enable ZFS for ${PRDNAME} Extension? [y/N]:" yn
|
||||||
mv ${CWDIR} ${CWDIR}.old
|
case ${yn} in
|
||||||
echo "Creating a new ZFS dataset for '${BASTILLE_DIR}'"
|
[Yy]) break;;
|
||||||
zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}
|
[Nn]) exit 0;;
|
||||||
if [ $? -ne 0 ]; then
|
esac
|
||||||
MSG="Failed to enable ZFS, reverting changes."
|
done
|
||||||
echo "${MSG}"
|
echo "Proceeding..."
|
||||||
zfs destroy ${bastille_zfs_zpool}/${bastille_zfs_prefix}
|
|
||||||
mv ${CWDIR}.old ${CWDIR}
|
if [ "${bastille_zfs_enable}" = "YES" ]; then
|
||||||
logger -t "${SCRIPTNAME}" "${MSG}"
|
if [ ! -z "${bastille_zfs_zpool}" ]; then
|
||||||
else
|
if zfs list "${bastille_zfs_zpool}" > /dev/null 2>&1; then
|
||||||
echo "Synchronizing '${BASTILLE_DIR}' data on new dataset"
|
if ! zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
||||||
rsync -a ${CWDIR}.old/ ${CWDIR}/
|
echo "Renaming existing '${BASTILLE_DIR}' directory"
|
||||||
|
mv ${CWDIR} ${CWDIR}.old
|
||||||
|
echo "Creating a new ZFS dataset for '${BASTILLE_DIR}'"
|
||||||
|
zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
MSG="Failed to enable ZFS, reverting changes."
|
||||||
|
echo "${MSG}"
|
||||||
|
mv ${CWDIR}.old ${CWDIR}
|
||||||
|
logger -t "${SCRIPTNAME}" "${MSG}"
|
||||||
|
error_notify "${MSG}"
|
||||||
|
else
|
||||||
|
echo "Synchronizing '${BASTILLE_DIR}' data on new dataset"
|
||||||
|
rsync -a ${CWDIR}.old/ ${CWDIR}/
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Bastille ZFS is already configured."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
error_notify "ERROR: ${bastille_zfs_zpool} is not a ZFS pool/dataset."
|
||||||
echo "Bastille ZFS is already configured."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
error_notify "ERROR: ${bastille_zfs_zpool}/${BASTILLE_DIR} is not a ZFS pool/dataset."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
error_notify "ERROR: ${bastille_zfs_zpool} is not a ZFS pool/dataset."
|
error_notify "Bastille ZPOOL is not set."
|
||||||
fi
|
fi
|
||||||
|
echo "ZFS Enabled for ${PRDNAME} Extension successfully."
|
||||||
else
|
else
|
||||||
error_notify "Bastille ZPOOL is not set."
|
error_notify "Bastille ZFS option is not set."
|
||||||
fi
|
fi
|
||||||
echo "ZFS Enabled for ${PRDNAME} Extension successfully."
|
|
||||||
else
|
else
|
||||||
error_notify "Bastille ZFS option is not set."
|
error_notify "Invalid ZFS configuration."
|
||||||
fi
|
fi
|
||||||
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_ACTIVATED="YES" >/dev/null 2>&1
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_upgrade()
|
pkg_upgrade()
|
||||||
@@ -944,19 +957,23 @@ rc_params()
|
|||||||
|
|
||||||
# Check if sane ZFS is enabled in this setup.
|
# Check if sane ZFS is enabled in this setup.
|
||||||
if [ "${bastille_zfs_enable}" = "YES" ]; then
|
if [ "${bastille_zfs_enable}" = "YES" ]; then
|
||||||
if [ ! -z "${bastille_zfs_zpool}" ]; then
|
if [ -n "${bastille_zfs_zpool}" ]; then
|
||||||
if zfs list "${bastille_zfs_zpool}" > /dev/null 2>&1; then
|
if zfs list "${bastille_zfs_zpool}" > /dev/null 2>&1; then
|
||||||
BASTILLE_DIR=$(echo ${CWDIR} | grep -o '[^/]*$')
|
BASTILLE_DIR=$(echo ${CWDIR} | grep -o '[^/]*$')
|
||||||
if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then
|
||||||
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="YES" >/dev/null 2>&1
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="YES" >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="AVA" >/dev/null 2>&1
|
if echo "${bastille_zfs_zpool}" | grep -qw "${CWDIR_TRIM}$"; then
|
||||||
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="AVA" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="ERR" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="ERR" >/dev/null 2>&1
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="ERR" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="NO" >/dev/null 2>&1
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="ERR" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="NO" >/dev/null 2>&1
|
sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="NO" >/dev/null 2>&1
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
bastille_manager-lib.inc
|
bastille_manager-lib.inc
|
||||||
|
|
||||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
Copyright (c) 2019-2020 José Rivera (joserprg@gmail.com).
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,22 +43,24 @@ require_once 'system.inc';
|
|||||||
$application = "Bastille Manager";
|
$application = "Bastille Manager";
|
||||||
$restore_name = "restore";
|
$restore_name = "restore";
|
||||||
$confdir = "/var/etc/bastille_conf";
|
$confdir = "/var/etc/bastille_conf";
|
||||||
$cwdir = exec("/usr/bin/grep 'INSTALL_DIR=' {$confdir}/conf/bastille_config | /usr/bin/cut -d'\"' -f2");
|
$cwdir = exec("/usr/bin/grep 'INSTALL_DIR=' $confdir/conf/bastille_config | /usr/bin/cut -d'\"' -f2");
|
||||||
$rootfolder = $cwdir;
|
$rootfolder = $cwdir;
|
||||||
$configfile = "{$rootfolder}/conf/bastille_config";
|
$configfile = "$rootfolder/conf/bastille_config";
|
||||||
$versionfile = "{$rootfolder}/version";
|
$versionfile = "$rootfolder/version";
|
||||||
$date = strftime('%c');
|
$date = strftime('%c');
|
||||||
$logfile = "{$rootfolder}/log/bastille_ext.log";
|
$logfile = "$rootfolder/log/bastille_ext.log";
|
||||||
$logevent = "{$rootfolder}/log/bastille_last_event.log";
|
$logevent = "$rootfolder/log/bastille_last_event.log";
|
||||||
$backup_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR=' | /usr/bin/cut -d'\"' -f2");
|
$backup_path = exec("/usr/bin/grep 'BACKUP_DIR=' $configfile | /usr/bin/cut -d'\"' -f2");
|
||||||
$bastille_config = "{$rootfolder}/conf/bastille_config";
|
$bastille_config = "$rootfolder/conf/bastille_config";
|
||||||
$config_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BASTILLE_CONFIG=' | /usr/bin/cut -d'\"' -f2");
|
$config_path = exec("/usr/bin/grep 'BASTILLE_CONFIG=' $configfile | /usr/bin/cut -d'\"' -f2");
|
||||||
$default_distfiles = exec("/bin/cat {$config_path} | /usr/bin/grep 'bastille_bootstrap_archives=' | /usr/bin/cut -d'\"' -f2");
|
$default_distfiles = exec("/usr/bin/grep 'bastille_bootstrap_archives=' $config_path | /usr/bin/cut -d'\"' -f2");
|
||||||
$jail_dir = "{$rootfolder}/jails";
|
$jail_dir = "{$rootfolder}/jails";
|
||||||
$image_dir = "ext/bastille/images";
|
$image_dir = "ext/bastille/images";
|
||||||
$options_support = exec("/usr/local/bin/bastille create | grep -wo '\[option\]'");
|
$options_support = exec("/usr/local/bin/bastille create | grep -wo '\[option\]'");
|
||||||
$reldir = "{$rootfolder}/releases";
|
$reldir = "{$rootfolder}/releases";
|
||||||
$zfs_support = exec("/bin/cat {$configfile} | /usr/bin/grep 'ZFS_SUPPORT=' | /usr/bin/cut -d'\"' -f2");
|
//$zfs_already = exec("/sbin/zfs list | /usr/bin/grep -w $rootfolder/bastille");
|
||||||
|
$zfs_support = exec("/usr/bin/grep 'ZFS_SUPPORT=' $configfile | /usr/bin/cut -d'\"' -f2");
|
||||||
|
$zfs_activated = exec("/usr/bin/grep 'ZFS_ACTIVATED=' $configfile | /usr/bin/cut -d'\"' -f2");
|
||||||
|
|
||||||
// Ensure the root directory is configured.
|
// Ensure the root directory is configured.
|
||||||
if ($rootfolder == "")
|
if ($rootfolder == "")
|
||||||
@@ -78,6 +80,32 @@ function is_dir_empty($reldir) {
|
|||||||
return (count(scandir($reldir)) == 2);
|
return (count(scandir($reldir)) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initial install banner
|
||||||
|
function initial_install_banner() {
|
||||||
|
// Never display this if bastille is already bootstraped/activated.
|
||||||
|
global $rootfolder;
|
||||||
|
global $zfs_activated;
|
||||||
|
$is_activated = "";
|
||||||
|
$is_bootstrapped = "";
|
||||||
|
|
||||||
|
// Check activation
|
||||||
|
if ($zfs_activated == "YES"):
|
||||||
|
return $is_activated = "YES";
|
||||||
|
elseif ($zfs_activated == "NO"):
|
||||||
|
return $is_activated = "NO";
|
||||||
|
else:
|
||||||
|
// Check for bootstrap directories.
|
||||||
|
exec("/bin/echo ' cache jails logs releases templates ' | /usr/bin/tr -s ' ' '\n'", $bastille_dirs);
|
||||||
|
array_shift($bastille_dirs);
|
||||||
|
foreach($bastille_dirs as $dir):
|
||||||
|
if(is_dir("$rootfolder/$dir")):
|
||||||
|
return $is_bootstrapped = "YES";
|
||||||
|
break;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for sane ZFS settings.
|
// Check for sane ZFS settings.
|
||||||
function get_state_zfs() {
|
function get_state_zfs() {
|
||||||
global $zfs_support;
|
global $zfs_support;
|
||||||
|
|||||||
@@ -48,7 +48,21 @@ $pgtitle = array(gtext("Extensions"), gtext("Bastille"), gtext("Configuration"))
|
|||||||
|
|
||||||
$wSpace = " ";
|
$wSpace = " ";
|
||||||
$wSpaceEqual = " = ";
|
$wSpaceEqual = " = ";
|
||||||
$paramNameSize = 30; //length of parameter name input field, default for parameter value input field is '80'
|
$paramNameSize = 30; //length of parameter name input field, default for parameter value input field is '80'
|
||||||
|
|
||||||
|
if(!initial_install_banner()):
|
||||||
|
$errormsg = gtext('Bastille Initial Configuration.')
|
||||||
|
. ' '
|
||||||
|
. '</br>'
|
||||||
|
. gtext('Please check and configure the following ZFS options: BASTILLE_ZFS_ENABLE and BASTILLE_ZFS_ZPOOL.')
|
||||||
|
.'</br>'
|
||||||
|
. gtext('Where BASTILLE_ZFS_ENABLE can be set to "YES", and BASTILLE_ZFS_ZPOOL can be set to "tank" or even "tank/dataset1/dataset2" accordingly.')
|
||||||
|
.'</br>'
|
||||||
|
. '<a href="' . 'bastille_manager_maintenance.php' . '">'
|
||||||
|
. gtext('After either configuring or skip this ZFS option, please visit this link to Enable/Disable ZFS Support on Bastille.')
|
||||||
|
. '</a>';
|
||||||
|
$prerequisites_ok = false;
|
||||||
|
endif;
|
||||||
|
|
||||||
function htmlInput($name, $title, $value="", $size=80) {
|
function htmlInput($name, $title, $value="", $size=80) {
|
||||||
$result = "<input name='{$name}' size='{$size}' title='{$title}' placeholder='{$title}' value='{$value}' />";
|
$result = "<input name='{$name}' size='{$size}' title='{$title}' placeholder='{$title}' value='{$value}' />";
|
||||||
@@ -145,6 +159,7 @@ bindtextdomain("xigmanas", $textdomain_bastille);
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="tabcont">
|
<tr><td class="tabcont">
|
||||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||||
|
<?php if(!empty($errormsg)): print_error_box($errormsg); endif; ?>
|
||||||
<?php // create table from configuration
|
<?php // create table from configuration
|
||||||
echo "<tr><td colspan='2' style='padding-left:0px; padding-right:0px;'>";
|
echo "<tr><td colspan='2' style='padding-left:0px; padding-right:0px;'>";
|
||||||
if (!empty($input_errors)) print_input_errors($input_errors);
|
if (!empty($input_errors)) print_input_errors($input_errors);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
bastille_manager_gui.php
|
bastille_manager_gui.php
|
||||||
|
|
||||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
Copyright (c) 2019-2020 José Rivera (joserprg@gmail.com).
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||||
@@ -75,6 +75,15 @@ $img_path = [
|
|||||||
$jls_list = get_jail_infos();
|
$jls_list = get_jail_infos();
|
||||||
$sphere_array = $jls_list;
|
$sphere_array = $jls_list;
|
||||||
|
|
||||||
|
if(!initial_install_banner()):
|
||||||
|
$errormsg = gtext('Bastille Initial Configuration.')
|
||||||
|
. ' '
|
||||||
|
. '<a href="' . 'bastille_manager_config.php' . '">'
|
||||||
|
. gtext('Please check and configure ZFS support option first.')
|
||||||
|
. '</a>';
|
||||||
|
$prerequisites_ok = false;
|
||||||
|
endif;
|
||||||
|
|
||||||
if($_POST):
|
if($_POST):
|
||||||
if(isset($_POST['apply']) && $_POST['apply']):
|
if(isset($_POST['apply']) && $_POST['apply']):
|
||||||
$ret = array('output' => [], 'retval' => 0);
|
$ret = array('output' => [], 'retval' => 0);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
bastille_manager_maintenance.php
|
bastille_manager_maintenance.php
|
||||||
|
|
||||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
Copyright (c) 2019-2020 José Rivera (joserprg@gmail.com).
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Copyright (c) 2016 Andreas Schmidhuber
|
Copyright (c) 2016 Andreas Schmidhuber
|
||||||
@@ -43,6 +43,17 @@ require_once("bastille_manager-lib.inc");
|
|||||||
|
|
||||||
$pgtitle = array(gtext("Extensions"), "Bastille", "Maintenance");
|
$pgtitle = array(gtext("Extensions"), "Bastille", "Maintenance");
|
||||||
|
|
||||||
|
if(!initial_install_banner()):
|
||||||
|
$errormsg = gtext('Bastille Initial Configuration.')
|
||||||
|
. ' '
|
||||||
|
. '<a href="' . 'bastille_manager_config.php' . '">'
|
||||||
|
. gtext('Please check and configure ZFS support option first.')
|
||||||
|
. '</a>'
|
||||||
|
. '</br>'
|
||||||
|
. gtext('Or click Activate to save current configuration regardless.');
|
||||||
|
$prerequisites_ok = false;
|
||||||
|
endif;
|
||||||
|
|
||||||
// For legacy product versions.
|
// For legacy product versions.
|
||||||
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
|
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
|
||||||
if ($return_val == 0) {
|
if ($return_val == 0) {
|
||||||
@@ -61,6 +72,7 @@ $prdname = "bastille";
|
|||||||
$tarballversion = "/usr/local/bin/bastille";
|
$tarballversion = "/usr/local/bin/bastille";
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
|
global $zfs_activated;
|
||||||
if(isset($_POST['upgrade']) && $_POST['upgrade']):
|
if(isset($_POST['upgrade']) && $_POST['upgrade']):
|
||||||
$cmd = sprintf('%1$s/bastille-init -u > %2$s',$rootfolder,$logevent);
|
$cmd = sprintf('%1$s/bastille-init -u > %2$s',$rootfolder,$logevent);
|
||||||
$return_val = 0;
|
$return_val = 0;
|
||||||
@@ -147,6 +159,44 @@ if ($_POST) {
|
|||||||
$input_errors[] = gtext("Failed to save extension settings.");
|
$input_errors[] = gtext("Failed to save extension settings.");
|
||||||
exec("echo '{$date}: {$application}: Failed to save extension settings' >> {$logfile}");
|
exec("echo '{$date}: {$application}: Failed to save extension settings' >> {$logfile}");
|
||||||
}
|
}
|
||||||
|
// ZFS activation support.
|
||||||
|
if ($_POST['zfs_activate']):
|
||||||
|
$zfs_status = get_state_zfs();
|
||||||
|
if($zfs_status == "Available but not enabled" || $zfs_status == "Enabled"):
|
||||||
|
if(!$zfs_activated):
|
||||||
|
$cmd = sprintf('/bin/echo Y | %1$s/bastille-init -Z > %2$s',$rootfolder,$logevent);
|
||||||
|
$return_val = 0;
|
||||||
|
$output = [];
|
||||||
|
exec($cmd,$output,$return_val);
|
||||||
|
if($return_val == 0):
|
||||||
|
ob_start();
|
||||||
|
include("{$logevent}");
|
||||||
|
$ausgabe = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
$savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />";
|
||||||
|
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\"");
|
||||||
|
else:
|
||||||
|
$input_errors[] = gtext('An error has occurred during ZFS activation process.');
|
||||||
|
$cmd = sprintf('echo %s: %s An error has occurred during ZFS activation process. >> %s',$date,$application,$logfile);
|
||||||
|
exec($cmd);
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
else:
|
||||||
|
$input_errors[] = gtext("Cannot activate ZFS with either invalid or disabled configurations.");
|
||||||
|
endif;
|
||||||
|
else:
|
||||||
|
$zfs_status = get_state_zfs();
|
||||||
|
if($zfs_status == "Invalid ZFS configuration"):
|
||||||
|
$input_errors[] = gtext("Cannot skip ZFS activation with an invalid configuration.");
|
||||||
|
elseif($zfs_status == "Enabled"):
|
||||||
|
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\"");
|
||||||
|
elseif(!$zfs_activated):
|
||||||
|
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"NO\"");
|
||||||
|
$savemsg .= gtext("ZFS activation option has been skipped.");
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
# Run bastille-init to update config.
|
||||||
|
exec("bastille-init");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['restore']) && $_POST['restore']) {
|
if (isset($_POST['restore']) && $_POST['restore']) {
|
||||||
@@ -231,20 +281,6 @@ $(document).ready(function(){
|
|||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
<form action="bastille_manager_maintenance.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
<form action="bastille_manager_maintenance.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
||||||
<?php
|
|
||||||
if(!empty($errormsg)):
|
|
||||||
print_error_box($errormsg);
|
|
||||||
endif;
|
|
||||||
if(!empty($savemsg)):
|
|
||||||
print_info_box($savemsg);
|
|
||||||
endif;
|
|
||||||
if(!empty($input_errors)):
|
|
||||||
print_input_errors($input_errors);
|
|
||||||
endif;
|
|
||||||
if(file_exists($d_sysrebootreqd_path)):
|
|
||||||
print_info_box(get_std_save_message(0));
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||||
<tr><td class="tabnavtbl">
|
<tr><td class="tabnavtbl">
|
||||||
<ul id="tabnav">
|
<ul id="tabnav">
|
||||||
@@ -261,6 +297,12 @@ $(document).ready(function(){
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="tabcont">
|
<tr><td class="tabcont">
|
||||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||||
|
<?php
|
||||||
|
if(!empty($errormsg)): print_error_box($errormsg); endif;
|
||||||
|
if(!empty($savemsg)): print_info_box($savemsg); endif;
|
||||||
|
if(!empty($input_errors)): print_input_errors($input_errors); endif;
|
||||||
|
if(file_exists($d_sysrebootreqd_path)): print_info_box(get_std_save_message(0)); endif;
|
||||||
|
?>
|
||||||
<?php html_titleline(gtext("Bastille"));?>
|
<?php html_titleline(gtext("Bastille"));?>
|
||||||
<?php html_text("installation_directory", gtext("Installation directory"), sprintf(gtext("The extension is installed in %s"), $rootfolder));?>
|
<?php html_text("installation_directory", gtext("Installation directory"), sprintf(gtext("The extension is installed in %s"), $rootfolder));?>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -275,6 +317,11 @@ $(document).ready(function(){
|
|||||||
<td class="vncellt"><?=gtext("ZFS support");?></td>
|
<td class="vncellt"><?=gtext("ZFS support");?></td>
|
||||||
<td class="vtable"><span name="getinfo_zfs" id="getinfo_zfs"><?=get_state_zfs()?></span></td>
|
<td class="vtable"><span name="getinfo_zfs" id="getinfo_zfs"><?=get_state_zfs()?></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
if(!initial_install_banner()):
|
||||||
|
html_checkbox2('zfs_activate',gtext('ZFS support activation'),'' ? true : false,gtext('Check this to activate ZFS support or leave unchecked to dismiss, this is a one time option and this row will disappear after clicking Save button.'),'',false);
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
<?php html_filechooser("backup_path", gtext("Backup directory"), $backup_path, gtext("Directory to store containers backup archives, use as file chooser for restoring from file."), $backup_path, true, 60);?>
|
<?php html_filechooser("backup_path", gtext("Backup directory"), $backup_path, gtext("Directory to store containers backup archives, use as file chooser for restoring from file."), $backup_path, true, 60);?>
|
||||||
</table>
|
</table>
|
||||||
<div id="submit">
|
<div id="submit">
|
||||||
@@ -284,7 +331,7 @@ $(document).ready(function(){
|
|||||||
</div>
|
</div>
|
||||||
<div id="remarks">
|
<div id="remarks">
|
||||||
<?php html_remark("note", gtext("Info"), sprintf(gtext("For general information visit the following link(s):")));?>
|
<?php html_remark("note", gtext("Info"), sprintf(gtext("For general information visit the following link(s):")));?>
|
||||||
<div id="enumeration"><ul><li><a href="http://bastillebsd.org/" target="_blank" > Bastille helps you quickly create and manage FreeBSD Jails.</a></li></ul></div>
|
<div id="enumeration"><ul><li><a href="http://bastillebsd.org/" target="_blank" ><?=gtext("Bastille helps you quickly create and manage FreeBSD Jails.")?></a></li></ul></div>
|
||||||
</div>
|
</div>
|
||||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||||
<?php html_separator();?>
|
<?php html_separator();?>
|
||||||
|
|||||||
Reference in New Issue
Block a user