mirror of
https://github.com/JRGTH/xigmanas-bastille-extension.git
synced 2025-12-10 17:00:18 +01:00
Added WebGUI feature set
This commit is contained in:
6
CHANGELOG
Normal file
6
CHANGELOG
Normal file
@@ -0,0 +1,6 @@
|
||||
======================
|
||||
= Extension Bastille =
|
||||
======================
|
||||
Version Description
|
||||
|
||||
1.0.0......First Public Release.
|
||||
28
LICENSE
Normal file
28
LICENSE
Normal file
@@ -0,0 +1,28 @@
|
||||
---------------------------------------------------------
|
||||
Copyright (c) 2019, José Rivera
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
---------------------------------------------------------
|
||||
271
bastille-init
271
bastille-init
@@ -1,33 +1,40 @@
|
||||
#!/bin/sh
|
||||
# bastille-init
|
||||
# Bastille Extension for XigmaNAS x64 11.x and later.
|
||||
# Bastille Extension Forum: https://www.xigmanas.com/forums/viewtopic.php?f=71&t=14848
|
||||
# Bastille Extension GitHub: https://github.com/JRGTH/xigmanas-bastille-extension
|
||||
# Bastille Homepage: http://bastillebsd.org/
|
||||
# Bastille GitHub: https://github.com/BastilleBSD/bastille
|
||||
#
|
||||
# ***(For Preview/Testing)***
|
||||
# Debug script
|
||||
#set -x
|
||||
|
||||
# Copyright (c) 2019 José Rivera (JoseMR)
|
||||
# Copyright (c) 2019, José Rivera (joserprg@gmail.com).
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that following conditions are met:
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS 'AS IS' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# 3. Neither the name of the developer nor the names of contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
# Set environment.
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
||||
@@ -45,8 +52,7 @@ CONFIG="/cf/conf/config.xml"
|
||||
PRDNAME="Bastille"
|
||||
APPNAME="bastille"
|
||||
EXTLOGFILE="${CWDIR}/log/bastille_ext.log"
|
||||
FULLAPPNAME="${APPNAME}-addon"
|
||||
PKGCONF="/etc/pkg/FreeBSD.conf"
|
||||
FULLAPPNAME="${APPNAME}-main"
|
||||
WWWPATH="/usr/local/www"
|
||||
PKGCACHE="/var/cache/pkg"
|
||||
USRLOCAL="/usr/local"
|
||||
@@ -56,11 +62,12 @@ EXTCONFLINK="/var/etc/${APPNAME}_conf"
|
||||
BASTILLERCD="/usr/local/etc/rc.d/${APPNAME}"
|
||||
BASTILLEPATH="${USRLOCAL}/bin"
|
||||
BASTILLECONF="${USRLOCAL}/etc/${APPNAME}/${APPNAME}.conf"
|
||||
BASTILLECONFLINK="/var/etc/bastilleconf"
|
||||
BASTILLECONFLINK="/var/etc/bastille_conf"
|
||||
BASTILLECONF_EXT="${CWDIR}/conf/bastille.conf.ext"
|
||||
INSTALLPATH="${CWDIR}/${FULLAPPNAME}"
|
||||
BRANCH="master"
|
||||
#BATSILLE_URL="https://github.com/BastilleBSD/${APPNAME}/archive/${BRANCH}.zip" # Official Bastille repository(Pending some updates/fixes)
|
||||
BATSILLE_URL="https://github.com/JRGTH/${APPNAME}/archive/${BRANCH}.zip" # Alternate Bastille repository(Updated, supports 11.3-RELEASE base)
|
||||
BATSILLE_URL="https://github.com/BastilleBSD/${APPNAME}/archive/${BRANCH}.zip" # Official Bastille Repository)
|
||||
#BATSILLE_URL="https://github.com/JRGTH/${APPNAME}/archive/${BRANCH}.zip" # Alternate Bastille Repository)
|
||||
BASTILE_VERSION="https://raw.githubusercontent.com/BastilleBSD/${APPNAME}/${BRANCH}/usr/local/bin/${APPNAME}"
|
||||
GITURL="https://github.com/JRGTH/xigmanas-${APPNAME}-extension/archive/${BRANCH}.zip"
|
||||
VERFILE="https://raw.githubusercontent.com/JRGTH/xigmanas-${APPNAME}-extension/${BRANCH}/version"
|
||||
@@ -81,6 +88,9 @@ runtime_config()
|
||||
sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_prefix="${CWDIR}" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ ! -d ${CWDIR}/backups ]; then
|
||||
mkdir -p ${CWDIR}/backups
|
||||
fi
|
||||
if [ ! -d ${CWDIR}/conf ]; then
|
||||
mkdir -p ${CWDIR}/conf
|
||||
fi
|
||||
@@ -110,9 +120,10 @@ bastille_pkg_extract()
|
||||
if [ -f ${CWDIR}/${BRANCH}.zip ]; then
|
||||
if [ ! -f ${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME} ]; then
|
||||
echo "Extracting ${APPNAME}..."
|
||||
tar -xf ${CWDIR}/${BRANCH}.zip --exclude='.git*' --strip-components 1 -C ${CWDIR}/${FULLAPPNAME} || \
|
||||
tar -xf ${CWDIR}/${BRANCH}.zip --exclude='.git*' --exclude='docs' --exclude='bastille.conf' --strip-components 1 -C ${CWDIR}/${FULLAPPNAME} || \
|
||||
error_notify "Error: A problem has occurred while extractig ${APPNAME} files."
|
||||
chmod 555 ${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME}
|
||||
chmod 555 ${CWDIR}/${FULLAPPNAME}${BASTILLERCD}
|
||||
rm -f ${CWDIR}/${BRANCH}.zip
|
||||
echo "Done!"
|
||||
fi
|
||||
@@ -123,7 +134,7 @@ bastille_upgrade()
|
||||
{
|
||||
# Perform an online bastille upgrade.
|
||||
DATE=$(date +"%a %b %d %T %Y")
|
||||
echo "Looking for new ${APPNAME} package!"
|
||||
echo "Looking for new ${PRDNAME} package!"
|
||||
mkdir -p ${CWDIR}/update
|
||||
fetch -ao ${CWDIR}/update --no-verify-peer --timeout=30 ${BASTILE_VERSION} || \
|
||||
error_notify "Error: A problem has occurred while fetching version file."
|
||||
@@ -136,10 +147,11 @@ bastille_upgrade()
|
||||
echo "New ${APPNAME} package found, performing upgrade..."
|
||||
fetch -ao ${CWDIR}/update --no-verify-peer --timeout=30 ${BATSILLE_URL} || \
|
||||
error_notify "Error: A problem has occurred while fetching ${APPNAME} package."
|
||||
tar -xf ${CWDIR}/update/${BRANCH}.zip --exclude='.git*' --strip-components 1 -C ${CWDIR}/update
|
||||
tar -xf ${CWDIR}/update/${BRANCH}.zip --exclude='.git*' --exclude='docs' --exclude='bastille.conf' --strip-components 1 -C ${CWDIR}/update
|
||||
rm -f ${CWDIR}/update/${BRANCH}.zip
|
||||
rm -f ${CWDIR}/update/${APPNAME}
|
||||
chmod 555 ${CWDIR}/update/${BASTILLEPATH}/${APPNAME}
|
||||
chmod 555 ${CWDIR}/${FULLAPPNAME}${BASTILLERCD}
|
||||
cp -Rf ${CWDIR}/update/* ${CWDIR}/${FULLAPPNAME}/
|
||||
rm -R ${CWDIR}/update
|
||||
|
||||
@@ -209,10 +221,13 @@ extension_upgrade()
|
||||
|
||||
create_addon_env()
|
||||
{
|
||||
# Set bastile dir proper permissions.
|
||||
# Set bastille dir required permissions.
|
||||
chmod 0750 ${CWDIR}
|
||||
|
||||
# Create required directories.
|
||||
if [ ! -d "${CWDIR}/backups" ]; then
|
||||
mkdir -p ${CWDIR}/backups
|
||||
fi
|
||||
if [ ! -d "${CWDIR}/log" ]; then
|
||||
mkdir -p ${CWDIR}/log
|
||||
fi
|
||||
@@ -252,7 +267,7 @@ bin_symlinks()
|
||||
cd ${INSTALLPATH}/${BASTILLEPATH}
|
||||
for file in *
|
||||
do
|
||||
ln -Ffhs ${INSTALLPATH}/${BASTILLEPATH}/${file} ${USRLOCAL}/bin/${file}
|
||||
ln -fhs ${INSTALLPATH}/${BASTILLEPATH}/${file} ${USRLOCAL}/bin/${file}
|
||||
done
|
||||
fi
|
||||
}
|
||||
@@ -262,26 +277,26 @@ sys_symlinkdir()
|
||||
# Check and create/relink required symlinks/dirs for bastille.
|
||||
# This environment will be checked each time the script is started for consistency.
|
||||
|
||||
# Link required binaries.
|
||||
bin_symlinks
|
||||
|
||||
# Required directories for bastille.
|
||||
if [ ! -d "${USRLOCAL}/share/licenses" ]; then
|
||||
mkdir -p ${USRLOCAL}/share/licenses
|
||||
fi
|
||||
|
||||
# Link required binaries.
|
||||
bin_symlinks
|
||||
|
||||
# Required symlinks for bastille.
|
||||
if [ -d "${INSTALLPATH}/${USRLOCAL}/share/licenses" ]; then
|
||||
cd ${INSTALLPATH}/${USRLOCAL}/share/licenses
|
||||
for file in *
|
||||
do
|
||||
ln -Ffhs ${INSTALLPATH}/${USRLOCAL}/share/licenses/${file} ${USRLOCAL}/share/licenses/${file}
|
||||
ln -fhs ${INSTALLPATH}/${USRLOCAL}/share/licenses/${file} ${USRLOCAL}/share/licenses/${file}
|
||||
done
|
||||
fi
|
||||
|
||||
# Link bastile config file directory.
|
||||
if [ -d "${INSTALLPATH}/${USRLOCAL}/etc/${APPNAME}" ]; then
|
||||
ln -Ffhs ${INSTALLPATH}/${USRLOCAL}/etc/${APPNAME} ${USRLOCAL}/etc/${APPNAME}
|
||||
ln -fhs ${INSTALLPATH}/${USRLOCAL}/etc/${APPNAME} ${USRLOCAL}/etc/${APPNAME}
|
||||
fi
|
||||
|
||||
# Link bastile config file.
|
||||
@@ -290,11 +305,15 @@ sys_symlinkdir()
|
||||
if [ ! -f "${APPNAME}.conf" ]; then
|
||||
cp ${APPNAME}.conf.sample ${APPNAME}.conf
|
||||
fi
|
||||
else
|
||||
if [ -f "${BASTILLECONF_EXT}" ]; then
|
||||
cp ${BASTILLECONF_EXT} ${INSTALLPATH}/${USRLOCAL}/etc/${APPNAME}/${APPNAME}.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy bastille shared.
|
||||
if [ -d "${INSTALLPATH}/${USRLOCAL}/share/${APPNAME}" ]; then
|
||||
ln -Ffhs ${INSTALLPATH}/${USRLOCAL}/share/${APPNAME} ${USRLOCAL}/share/${APPNAME}
|
||||
ln -fhs ${INSTALLPATH}/${USRLOCAL}/share/${APPNAME} ${USRLOCAL}/share/${APPNAME}
|
||||
fi
|
||||
|
||||
# Copy bastille rc.
|
||||
@@ -309,8 +328,8 @@ postinit_cmd()
|
||||
if ! grep -qw ${CWDIR}/${SCRIPTNAME} ${CONFIG}; then
|
||||
touch ${CWDIR}/postinit || error_notify "Error: A problem has occurred while creating the postinit file."
|
||||
chmod +x ${CWDIR}/postinit
|
||||
if [ ! "${PRDVERSION}" -ge "110" ]; then
|
||||
# Generate php script for NAS4Free 10.3 versions.
|
||||
if [ ! "${PRDVERSION}" -ge "112" ]; then
|
||||
# Generate php script for previous product versions.
|
||||
cat << EOF > ${CWDIR}/postinit
|
||||
<?php
|
||||
require_once("config.inc");
|
||||
@@ -323,19 +342,29 @@ require_once("functions.inc");
|
||||
}
|
||||
\$config['rc']['postinit']['cmd'][\$i] = \$config['cmd']."\$cmd";
|
||||
write_config();
|
||||
|
||||
\$i =0;
|
||||
if ( is_array(\$config['rc']['shutdown'] ) && is_array( \$config['rc']['shutdown']['cmd'] ) ) {
|
||||
for (\$i; \$i < count(\$config['rc']['shutdown']['cmd']);) {
|
||||
if (preg_match('/${SCRIPTNAME}/', \$config['rc']['shutdown']['cmd'][\$i])) break; ++\$i; }
|
||||
}
|
||||
\$config['rc']['shutdown']['cmd'][\$i] = \$config['cmd']."\$cmd";
|
||||
write_config();
|
||||
?>
|
||||
EOF
|
||||
else
|
||||
# Generate php script for NAS4Free/XigmaNAS 11.x versions.
|
||||
# Generate php script for later product versions.
|
||||
cat << EOF > ${CWDIR}/postinit
|
||||
<?php
|
||||
require_once("config.inc");
|
||||
require_once("functions.inc");
|
||||
\$cmd = dirname(__FILE__)."/${SCRIPTNAME}";
|
||||
\$cmd2 = dirname(__FILE__)."/${SCRIPTNAME} -p";
|
||||
\$name = "${PRDNAME} Extension";
|
||||
\$comment = "Start ${PRDNAME} jail manager";
|
||||
\$comment = "Start ${PRDNAME} Container Manager";
|
||||
\$comment2 = "Stop ${PRDNAME} Container Manager";
|
||||
\$rc = &array_make_branch(\$config,'rc','param');
|
||||
if(false === array_search_ex(\$name,\$rc,'name')):
|
||||
if(false === array_search_ex(\$cmd,\$rc,'cmd')):
|
||||
\$rc_param = [];
|
||||
\$rc_param['uuid'] = uuid();
|
||||
\$rc_param['name'] = \$name;
|
||||
@@ -347,6 +376,20 @@ if(false === array_search_ex(\$name,\$rc,'name')):
|
||||
write_config();
|
||||
endif;
|
||||
unset(\$rc);
|
||||
|
||||
\$rc = &array_make_branch(\$config,'rc','param');
|
||||
if(false === array_search_ex(\$cmd2,\$rc,'cmd2')):
|
||||
\$rc_param = [];
|
||||
\$rc_param['uuid'] = uuid();
|
||||
\$rc_param['name'] = \$name;
|
||||
\$rc_param['value'] = \$cmd2;
|
||||
\$rc_param['comment2'] = \$comment2;
|
||||
\$rc_param['typeid'] = '3';
|
||||
\$rc_param['enable'] = true;
|
||||
\$rc[] = \$rc_param;
|
||||
write_config();
|
||||
endif;
|
||||
unset(\$rc);
|
||||
?>
|
||||
EOF
|
||||
fi
|
||||
@@ -359,7 +402,7 @@ EOF
|
||||
echo "Done!"
|
||||
fi
|
||||
|
||||
# Set extension to disable by default.
|
||||
# Set extension to enable by default.
|
||||
sysrc -f ${CWDIR}${EXTCONF} GUI_ENABLE=YES INSTALL_DIR=${CWDIR} >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
@@ -382,21 +425,31 @@ gui_start()
|
||||
sysrc -f ${CWDIR}${EXTCONF} INSTALL_DIR=${CWDIR} >/dev/null 2>&1
|
||||
fi
|
||||
mkdir -p ${BASTILLECONFLINK}
|
||||
ln -Ffhs ${CWDIR}/conf ${BASTILLECONFLINK}/conf
|
||||
# Copy the gui files.
|
||||
cp -R ${CWDIR}/gui/* ${WWWPATH}/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
ln -fhs ${CWDIR}/conf ${BASTILLECONFLINK}/conf
|
||||
# Link the gui files.
|
||||
if [ ! -d "${WWWPATH}/ext" ]; then
|
||||
mkdir -p ${WWWPATH}/ext
|
||||
fi
|
||||
ln -fhs ${CWDIR}/gui/ext/bastille ${WWWPATH}/ext/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
ln -fhs ${CWDIR}/gui/images ${WWWPATH}/ext/bastille/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
ln -fhs ${CWDIR}/gui/bastille_manager_*.php ${WWWPATH}/ || error_notify "Error: A problem has occurred while linking extension gui files."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
gui_enable()
|
||||
{
|
||||
# Relink conf and copy the gui files.
|
||||
# Relink conf and gui files.
|
||||
if [ -d "${CWDIR}/gui" ]; then
|
||||
mkdir -p ${BASTILLECONFLINK}
|
||||
ln -Ffhs ${CWDIR}/conf ${BASTILLECONFLINK}/conf
|
||||
ln -fhs ${CWDIR}/conf ${BASTILLECONFLINK}/conf
|
||||
sysrc -f ${CWDIR}${EXTCONF} GUI_ENABLE=YES >/dev/null 2>&1
|
||||
cp -R ${CWDIR}/gui/* ${WWWPATH}/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
if [ ! -d "${WWWPATH}/ext" ]; then
|
||||
mkdir -p ${WWWPATH}/ext
|
||||
fi
|
||||
ln -fhs ${CWDIR}/gui/ext/bastille ${WWWPATH}/ext/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
ln -fhs ${CWDIR}/gui/images ${WWWPATH}/ext/bastille/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
ln -fhs ${CWDIR}/gui/bastille_manager_*.php ${WWWPATH}/ || error_notify "Error: A problem has occurred while copying extension gui files."
|
||||
exit 0
|
||||
else
|
||||
error_notify "Error: Extension gui files not found."
|
||||
@@ -407,10 +460,11 @@ gui_disable()
|
||||
{
|
||||
# Disable gui if -t option specified.
|
||||
if [ -d "${CWDIR}/gui" ]; then
|
||||
rm -f ${WWWPATH}bastille-gui.php
|
||||
rm -Rf ${WWWPATH}/ext/bastille-gui
|
||||
rm -f ${WWWPATH}bastille_manager_*.php
|
||||
rm -rf ${WWWPATH}/ext/bastille
|
||||
rm -rf ${WWWPATH}/ext/bastille/images
|
||||
rm -f ${LOCALSHAREPATH}/locale-bastille
|
||||
rm -Rf ${BASTILLECONFLINK}
|
||||
rm -rf ${BASTILLECONFLINK}
|
||||
sysrc -f ${CWDIR}${EXTCONF} GUI_ENABLE=NO >/dev/null 2>&1 || error_notify "Error: A problem while removing extension gui files."
|
||||
exit 0
|
||||
else
|
||||
@@ -420,7 +474,7 @@ gui_disable()
|
||||
# Remove empty ext folder to prevent empty "Extensions" tab.
|
||||
if [ -d "${WWWPATH}/ext" ]; then
|
||||
if [ ! "$(ls -A ${WWWPATH}/ext)" ]; then
|
||||
rm -R ${WWWPATH}/ext
|
||||
rm -r ${WWWPATH}/ext
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -442,8 +496,8 @@ reset_install()
|
||||
{
|
||||
# Reset the extension environment.
|
||||
echo "Removing extension files..."
|
||||
if [ -d ${CWDIR}/conf ]; then
|
||||
rm -rf ${CWDIR}/conf
|
||||
if [ -f ${CWDIR}/conf/bastille_config ]; then
|
||||
rm -rf ${CWDIR}/conf/bastille_config
|
||||
fi
|
||||
if [ -d ${CWDIR}/${FULLAPPNAME} ]; then
|
||||
rm -rf ${CWDIR}/${FULLAPPNAME}
|
||||
@@ -470,11 +524,11 @@ remove_addon()
|
||||
echo "Proceeding..."
|
||||
|
||||
# Check for working platform and remove symlinks.
|
||||
if [ "${PRDPLATFORM}" = "x64-embedded" ]; then
|
||||
if [ "${PRDPLATFORM}" = "x64-embedded" ] || [ "${PRDPLATFORM}" = "x64-full" ]; then
|
||||
if [ -d "${USRLOCAL}/share/licenses/${APPNAME}-*" ]; then
|
||||
rm -rf ${USRLOCAL}/share/licenses/${APPNAME}-*
|
||||
fi
|
||||
if [ -d ${USRLOCAL}/share/locale-bastille ]; then
|
||||
if [ -d $"{USRLOCAL}/share/locale-bastille" ]; then
|
||||
rm -rf ${USRLOCAL}/share/locale-bastille
|
||||
fi
|
||||
if [ -f "${USRLOCAL}/etc/rc.d/${APPNAME}" ]; then
|
||||
@@ -489,21 +543,19 @@ remove_addon()
|
||||
if [ -d "${VARLOG}/${APPNAME}" ]; then
|
||||
rm -rf ${VARLOG}/${APPNAME}
|
||||
fi
|
||||
elif [ "${PRDPLATFORM}" = "x64-full" ]; then
|
||||
pkg delete -y ${APPNAME}
|
||||
fi
|
||||
|
||||
# Remove extension and GUI components.
|
||||
if [ -f "${WWWPATH}/${APPNAME}-gui.php" ]; then
|
||||
rm -f ${WWWPATH}/${APPNAME}-gui.php
|
||||
if [ -f "${WWWPATH}/bastille_manager_gui.php" ]; then
|
||||
rm -f ${WWWPATH}/bastille_manager_*.php
|
||||
fi
|
||||
if [ -d "${WWWPATH}/ext/bastille-gui" ]; then
|
||||
rm -rf ${WWWPATH}/ext/bastille-gui
|
||||
if [ -d "${WWWPATH}/ext/bastille" ]; then
|
||||
rm -rf ${WWWPATH}/ext/bastille
|
||||
fi
|
||||
if [ -f ${USRLOCAL}/bin/${APPNAME} ]; then
|
||||
if [ -f "${USRLOCAL}/bin/${APPNAME}" ]; then
|
||||
rm -rf ${USRLOCAL}/bin/${APPNAME}
|
||||
fi
|
||||
if [ -d ${VARLOG}/${APPNAME} ]; then
|
||||
if [ -d "${VARLOG}/${APPNAME}" ]; then
|
||||
rm -rf ${VARLOG}/${APPNAME}
|
||||
fi
|
||||
|
||||
@@ -515,11 +567,12 @@ remove_addon()
|
||||
fi
|
||||
|
||||
# Remove addon related files and folders only-
|
||||
# to protect any user-created custom files.
|
||||
FILES="conf download gui locale-bastille log bastille-addon README.md postinit release_notes version bastille-init"
|
||||
for file in ${FILES}; do
|
||||
if [ -f ${CWDIR}/${file} ] || [ -d ${CWDIR}/${file} ]; then
|
||||
rm -rf ${CWDIR}/${file}
|
||||
# to protect any user-created custom files-
|
||||
# as well as for the containers dirs/files.
|
||||
FILES="conf download gui locale-bastille log bastille-main LICENSE README.md postinit release_notes version bastille-init"
|
||||
for FILE in ${FILES}; do
|
||||
if [ -f "${CWDIR}/${file}" ] || [ -d "${CWDIR}/${file}" ]; then
|
||||
rm -rf ${CWDIR}/${FILE}
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -530,7 +583,7 @@ remove_addon()
|
||||
|
||||
get_versions()
|
||||
{
|
||||
# Get bastille-addon extension version.
|
||||
# Get product versions.
|
||||
if [ -f "${CWDIR}/version" ]; then
|
||||
APPVERSION=$(cat ${CWDIR}/version)
|
||||
else
|
||||
@@ -540,7 +593,6 @@ get_versions()
|
||||
# Display product versions.
|
||||
BASTILLEVER=$(${USRLOCAL}/bin/bastille --version)
|
||||
echo "Bastille version: ${BASTILLEVER}"
|
||||
|
||||
echo "Extension version: ${APPVERSION}"
|
||||
exit 0
|
||||
}
|
||||
@@ -548,15 +600,15 @@ get_versions()
|
||||
ext_start()
|
||||
{
|
||||
# Start bastille jails.
|
||||
if [ "${PRDPLATFORM}" = "x64-embedded" ]; then
|
||||
if [ -d "${CWDIR}/jails" ]; then
|
||||
if [ "$(ls -A ${CWDIR}/jails)" ]; then
|
||||
JAIL_AUTO_START=$(sysrc -qn bastille_enable)
|
||||
if [ "${JAIL_AUTO_START}" = "YES" ]; then
|
||||
service bastille start
|
||||
fi
|
||||
JAIL_LIST=$(bastille list jail)
|
||||
for jail in ${JAIL_LIST}; do
|
||||
if sysrc -f ${CWDIR}${EXTCONF} -qn ${jail}_AUTO_START | grep -w "YES" >/dev/null; then
|
||||
if ! jls | sed "1 d" | awk '{print $3}' | grep -qw ${jail}; then
|
||||
bastille start ${jail}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
@@ -572,27 +624,70 @@ ext_start()
|
||||
|
||||
rc_params()
|
||||
{
|
||||
# Bastille rc parameters.
|
||||
# Bastille required parameters.
|
||||
|
||||
# Set bastille prefix.
|
||||
if ! sysrc -f ${BASTILLECONF} -qn bastille_prefix | grep -q "${CWDIR}"; then
|
||||
sysrc -f ${BASTILLECONF} bastille_prefix="${CWDIR}" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Default network interface.
|
||||
ACTIVE_NETIF=$(ifconfig | grep "UP,BROADCAST" | awk -F":" '{print $1}')
|
||||
if ! sysrc -f ${BASTILLECONF} -qn bastille_jail_external >/dev/null 2>&1; then
|
||||
echo "" >> ${BASTILLECONF} && echo "## default network interface" >> ${BASTILLECONF}
|
||||
# Set bastille.conf location.
|
||||
if ! sysrc -f ${CWDIR}${EXTCONF} -n BASTILLE_CONFIG 2>/dev/null | grep -q "${CWDIR}/${FULLAPPNAME}${BASTILLECONF}"; then
|
||||
sysrc -f ${CWDIR}${EXTCONF} BASTILLE_CONFIG="${CWDIR}/${FULLAPPNAME}${BASTILLECONF}" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Default first network interface.
|
||||
ACTIVE_NETIF=$(ifconfig | grep "UP,BROADCAST" | awk -F":" '{print $1}' | sed 1q)
|
||||
if ! sysrc -f ${BASTILLECONF} -qn bastille_jail_external | grep -q "${ACTIVE_NETIF}" >/dev/null 2>&1; then
|
||||
#echo "" >> ${BASTILLECONF} && echo "## default network interface" >> ${BASTILLECONF}
|
||||
sysrc -f ${BASTILLECONF} bastille_jail_external="${ACTIVE_NETIF}" >/dev/null 2>&1
|
||||
else
|
||||
BLANK_NETIF=$(sysrc -f ${BASTILLECONF} -qn bastille_jail_external)
|
||||
if [ -z "${BLANK_NETIF}" ]; then
|
||||
echo "" >> ${BASTILLECONF} && echo "## default network interface" >> ${BASTILLECONF}
|
||||
EXT_NETIF=$(sysrc -f ${BASTILLECONF} -qn bastille_jail_external)
|
||||
if [ -z "${EXT_NETIF}" ]; then
|
||||
#echo "" >> ${BASTILLECONF} && echo "## default network interface" >> ${BASTILLECONF}
|
||||
sysrc -f ${BASTILLECONF} bastille_jail_external="${ACTIVE_NETIF}" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start all jails by default.
|
||||
# Do't start containers by default.
|
||||
if ! sysrc -qn bastille_enable >/dev/null 2>&1; then
|
||||
sysrc bastille_enable="YES" >/dev/null 2>&1
|
||||
sysrc bastille_enable="NO" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
bastille_start()
|
||||
{
|
||||
# Start all bastille containers.
|
||||
echo "${PRDNAME} Extension: Starting all containers..."
|
||||
bastille start ALL
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
bastille_stop()
|
||||
{
|
||||
# Stop all bastille containers.
|
||||
echo "${PRDNAME} Extension: Stopping all containers..."
|
||||
bastille stop ALL
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
bastille_restart()
|
||||
{
|
||||
# Restart all bastille containers.
|
||||
echo "${PRDNAME} Extension: Restarting all containers..."
|
||||
bastille restart ALL
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -603,7 +698,7 @@ bastille_init()
|
||||
echo "Unsupported platform!"; exit 1
|
||||
fi
|
||||
# Check for product compatibility.
|
||||
if [ ! "${PRDVERSION}" -ge "110" ]; then
|
||||
if [ ! "${PRDVERSION}" -ge "112" ]; then
|
||||
echo "Unsupported version!"; exit 1
|
||||
fi
|
||||
|
||||
@@ -621,18 +716,24 @@ bastille_init()
|
||||
# Run-time configuration.
|
||||
runtime_config
|
||||
|
||||
while getopts ":ouxRvgth" option; do
|
||||
while getopts ":ospruxRvgth" option; do
|
||||
case ${option} in
|
||||
[h]) echo "Usage: ${SCRIPTNAME} -[option]";
|
||||
echo "Options:"
|
||||
echo " -s Start All ${PRDNAME} Containers."
|
||||
echo " -p Stop All ${PRDNAME} Containers."
|
||||
echo " -r Restart All ${PRDNAME} Containers."
|
||||
echo " -u Upgrade ${PRDNAME}/Extension packages."
|
||||
echo " -v Display product versions."
|
||||
echo " -g Enables the addon GUI."
|
||||
echo " -t Disable the addon GUI."
|
||||
echo " -x Reset ${PRDNAME}/Extension config."
|
||||
echo " -R Remove ${PRDNAME}."
|
||||
echo " -R Remove ${PRDNAME} (Extension files only)."
|
||||
echo " -h Display this help message."; exit 0;;
|
||||
[o]) OBI_INSTALL="ON";; # To prevent nested PHP-CGI call for installation with OBI.
|
||||
[s]) bastille_start;;
|
||||
[p]) bastille_stop;;
|
||||
[r]) bastille_restart;;
|
||||
[u]) pkg_upgrade;;
|
||||
[x]) reset_install;;
|
||||
[R]) remove_addon;;
|
||||
|
||||
20
conf/bastille.conf.ext
Normal file
20
conf/bastille.conf.ext
Normal file
@@ -0,0 +1,20 @@
|
||||
bastille_prefix="/usr/local/bastille"
|
||||
bastille_cachedir="${bastille_prefix}/cache"
|
||||
bastille_jailsdir="${bastille_prefix}/jails"
|
||||
bastille_logsdir="${bastille_prefix}/logs"
|
||||
bastille_releasesdir="${bastille_prefix}/releases"
|
||||
bastille_templatesdir="${bastille_prefix}/templates"
|
||||
bastille_sharedir="/usr/local/share/bastille"
|
||||
bastille_bootstrap_archives="base"
|
||||
bastille_tzdata="etc/UTC"
|
||||
bastille_resolv_conf="/etc/resolv.conf"
|
||||
bastille_zfs_enable=""
|
||||
bastille_zfs_zpool=""
|
||||
bastille_zfs_prefix="bastille"
|
||||
bastille_zfs_mountpoint="${bastille_prefix}"
|
||||
bastille_zfs_options="-o compress=lz4 -o atime=off"
|
||||
bastille_jail_loopback=""
|
||||
bastille_jail_interface=""
|
||||
bastille_jail_external=""
|
||||
bastille_jail_addr=""
|
||||
bastille_jail_gateway=""
|
||||
37
conf/bastille.conf.sample
Normal file
37
conf/bastille.conf.sample
Normal file
@@ -0,0 +1,37 @@
|
||||
#####################
|
||||
## [ BastilleBSD ] ##
|
||||
#####################
|
||||
|
||||
## default paths
|
||||
bastille_prefix="/usr/local/bastille" ## default: "/usr/local/bastille"
|
||||
bastille_cachedir="${bastille_prefix}/cache" ## default: ${bastille_prefix}/cache
|
||||
bastille_jailsdir="${bastille_prefix}/jails" ## default: ${bastille_prefix}/jails
|
||||
bastille_logsdir="${bastille_prefix}/logs" ## default: ${bastille_prefix}/logs
|
||||
bastille_releasesdir="${bastille_prefix}/releases" ## default: ${bastille_prefix}/releases
|
||||
bastille_templatesdir="${bastille_prefix}/templates" ## default: ${bastille_prefix}/templates
|
||||
|
||||
## bastille scripts directory (assumed by bastille pkg)
|
||||
bastille_sharedir="/usr/local/share/bastille" ## default: "/usr/local/share/bastille"
|
||||
|
||||
## bootstrap archives (base, lib32, ports, src, test)
|
||||
bastille_bootstrap_archives="base" ## default: "base"
|
||||
|
||||
## default timezone
|
||||
bastille_tzdata="etc/UTC" ## default: "etc/UTC"
|
||||
|
||||
## default jail resolv.conf
|
||||
bastille_resolv_conf="/etc/resolv.conf" ## default: "/etc/resolv.conf"
|
||||
|
||||
## ZFS options
|
||||
bastille_zfs_enable="" ## default: ""
|
||||
bastille_zfs_zpool="" ## default: ""
|
||||
bastille_zfs_prefix="bastille" ## default: "${bastille_zfs_zpool}/bastille"
|
||||
bastille_zfs_mountpoint=${bastille_prefix} ## default: "${bastille_prefix}"
|
||||
bastille_zfs_options="-o compress=lz4 -o atime=off" ## default: "-o compress=lz4 -o atime=off"
|
||||
|
||||
## Networking
|
||||
bastille_jail_loopback="lo1" ## default: "lo1"
|
||||
bastille_jail_interface="bastille0" ## default: "bastille0"
|
||||
bastille_jail_external="" ## default: ""
|
||||
bastille_jail_addr="10.17.89.10" ## default: "10.17.89.10"
|
||||
bastille_jail_gateway="" ## default: ""
|
||||
187
gui/bastille_manager-lib.inc
Executable file
187
gui/bastille_manager-lib.inc
Executable file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager-lib.inc
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'super_fun.inc';
|
||||
require_once 'globals.inc';
|
||||
require_once 'array.inc';
|
||||
require_once 'system.inc';
|
||||
|
||||
// Initialize some variables.
|
||||
// TODO: Some infos can be gathered with-
|
||||
// internal PHP functions rather than external shell commands.
|
||||
|
||||
//$rootfolder = dirname($config['rc']['postinit']['cmd'][$i]);
|
||||
$restore_name = "restore";
|
||||
$confdir = "/var/etc/bastille_conf";
|
||||
$cwdir = exec("/usr/bin/grep 'INSTALL_DIR=' {$confdir}/conf/bastille_config | /usr/bin/cut -d'\"' -f2");
|
||||
$rootfolder = $cwdir;
|
||||
$configfile = "{$rootfolder}/conf/bastille_config";
|
||||
$versionfile = "{$rootfolder}/version";
|
||||
$date = strftime('%c');
|
||||
$logfile = "{$rootfolder}/log/bastille_ext.log";
|
||||
$logevent = "{$rootfolder}/log/bastille_last_event.log";
|
||||
$backup_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR=' | /usr/bin/cut -d'\"' -f2");
|
||||
$bastille_config = "{$rootfolder}/conf/bastille_config";
|
||||
$jail_dir = "{$rootfolder}/jails";
|
||||
$image_dir = "ext/bastille/images";
|
||||
|
||||
$avail_releases = exec("/bin/echo $(/bin/ls {$rootfolder}/releases 2>/dev/null)");
|
||||
if ($avail_releases == ''):
|
||||
$empty_releases = "YES";
|
||||
$avail_releases = "No base releases detected!";
|
||||
endif;
|
||||
|
||||
// Ensure the root directory is configured.
|
||||
if ($rootfolder == "")
|
||||
$input_errors[] = gtext("Extension installed with fault");
|
||||
else {
|
||||
// Initialize locales.
|
||||
$textdomain = "/usr/local/share/locale";
|
||||
$textdomain_bastille = "/usr/local/share/locale-bastille";
|
||||
if (!is_link($textdomain_bastille)) { mwexec("ln -s {$rootfolder}/locale-bastille {$textdomain_bastille}", true); }
|
||||
bindtextdomain("xigmanas", $textdomain_bastille);
|
||||
}
|
||||
if (is_file("{$rootfolder}/postinit")) unlink("{$rootfolder}/postinit");
|
||||
|
||||
// Get all base releases list.
|
||||
function get_all_release_list() {
|
||||
global $rootfolder;
|
||||
global $g;
|
||||
exec("/bin/echo; /bin/ls {$rootfolder}/releases 2>/dev/null | /usr/bin/tr -s ' ' '\n'",$relinfo);
|
||||
array_shift($relinfo);
|
||||
$rellist = [];
|
||||
foreach($relinfo as $rel):
|
||||
$arel = preg_split("/\s+/",ltrim($rel));
|
||||
$relname = chop($arel[0]);
|
||||
if(substr($relname,-1) === '*'):
|
||||
$relname = substr($relname,0,strlen($relname) - 1);
|
||||
endif;
|
||||
$rellist[$relname] = [];
|
||||
endforeach;
|
||||
return $rellist;
|
||||
}
|
||||
|
||||
// Get all interface list.
|
||||
function get_all_interface_list() {
|
||||
global $g;
|
||||
exec("/bin/echo; /sbin/ifconfig -l | /usr/bin/tr -s ' ' '\n'; /bin/echo 'NONE'",$linkinfo);
|
||||
array_shift($linkinfo);
|
||||
$iflist = [];
|
||||
foreach($linkinfo as $link):
|
||||
$alink = preg_split("/\s+/",ltrim($link));
|
||||
$ifname = chop($alink[0]);
|
||||
if(substr($ifname,-1) === '*'):
|
||||
$ifname = substr($ifname,0,strlen($ifname) - 1);
|
||||
endif;
|
||||
$iflist[$ifname] = [];
|
||||
endforeach;
|
||||
return $iflist;
|
||||
}
|
||||
|
||||
// Get jail infos.
|
||||
function get_jail_infos() {
|
||||
global $img_path;
|
||||
global $image_dir;
|
||||
global $configfile;
|
||||
global $jail_dir;
|
||||
$result = [];
|
||||
if(is_dir($jail_dir)):
|
||||
$cmd = '/usr/local/bin/bastille list jail 2>&1';
|
||||
else:
|
||||
$cmd = ":";
|
||||
endif;
|
||||
mwexec2($cmd,$rawdata);
|
||||
foreach($rawdata as $line):
|
||||
$a = preg_split('/\t/',$line);
|
||||
$r = [];
|
||||
$name = $a[0];
|
||||
if(preg_match('/(.*)/', $name, $m)):
|
||||
$r['name'] = $m[1];
|
||||
else:
|
||||
$r['name'] = '-';
|
||||
endif;
|
||||
$r['jailname'] = $r['name'];
|
||||
|
||||
// Set the JID on the running jails.
|
||||
$item = $r['jailname'];
|
||||
$r['id'] = exec("/usr/sbin/jls | /usr/bin/grep {$item} | /usr/bin/awk '{print $1}'");
|
||||
if (!$r['id']):
|
||||
$r['id'] = "-";
|
||||
endif;
|
||||
// Set the IPv4 on the running jails.
|
||||
//$r['ip'] = exec("/usr/sbin/jls | /usr/bin/grep {$item} | /usr/bin/awk '{print $2}'");
|
||||
$r['ip'] = exec("/usr/bin/grep -w 'ip4.addr' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'");
|
||||
if (!$r['ip']):
|
||||
$r['ip'] = "-";
|
||||
endif;
|
||||
// Display interfaces.
|
||||
$r['nic'] = exec("/usr/bin/grep -w 'interface' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'");
|
||||
if (!$r['nic']):
|
||||
$r['nic'] = "-";
|
||||
endif;
|
||||
// Display path.
|
||||
$r['path'] = exec("/usr/bin/grep -w 'path' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'");
|
||||
if (!$r['path']):
|
||||
$r['path'] = "-";
|
||||
endif;
|
||||
// Display auto-start settings.
|
||||
$jail_autostart = exec("/usr/sbin/sysrc -qn -f {$configfile} {$item}_AUTO_START");
|
||||
if ($jail_autostart == 'YES') {
|
||||
$r['boot'] = $img_path['ena'];
|
||||
} elseif ($jail_autostart == 'NO') {
|
||||
$r['boot'] = $img_path['dis'];
|
||||
} else {
|
||||
$r['boot'] = $img_path['dis'];
|
||||
}
|
||||
// Display running status icons.
|
||||
$jail_running = exec("/usr/sbin/jls | /usr/bin/grep -w {$item}");
|
||||
if ($jail_running):
|
||||
$r['stat'] = $img_path['ena'];
|
||||
else:
|
||||
$r['stat'] = $img_path['dis'];
|
||||
endif;
|
||||
// Display custom template icons if available.
|
||||
$item = $item;
|
||||
$template_icon = "{$image_dir}/{$item}_icon.png";
|
||||
if(file_exists($template_icon)):
|
||||
$r['logo'] = "{$image_dir}/{$item}_icon.png";
|
||||
else:
|
||||
// Display standard FreeBSD icon.
|
||||
$r['logo'] = "{$image_dir}/bsd_icon.png";
|
||||
endif;
|
||||
|
||||
$result[] = $r;
|
||||
endforeach;
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
||||
188
gui/bastille_manager_add.php
Normal file
188
gui/bastille_manager_add.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_add.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
$pgtitle = array(gtext("Extensions"), "Bastille", "Create");
|
||||
|
||||
if(!$pconfig['jailname']):
|
||||
$pconfig['jailname'] = 'jail1';
|
||||
endif;
|
||||
if(!$pconfig['ipaddress']):
|
||||
$pconfig['ipaddress'] = '';
|
||||
endif;
|
||||
|
||||
// list of configured interfaces
|
||||
$a_interface = get_all_interface_list();
|
||||
$l_interfaces = [];
|
||||
foreach($a_interface as $k_interface => $ifinfo):
|
||||
$l_interfaces[$k_interface] = $k_interface;
|
||||
endforeach;
|
||||
|
||||
// list base releases
|
||||
$a_release = get_all_release_list();
|
||||
$l_release = [];
|
||||
foreach($a_release as $k_release => $release):
|
||||
$l_release[$k_release] = $k_release;
|
||||
endforeach;
|
||||
|
||||
if(!is_dir($jail_dir)):
|
||||
$errormsg = gtext('No base releases extracted yet.')
|
||||
. ' '
|
||||
. '<a href="' . 'bastille_manager_tarballs.php' . '">'
|
||||
. gtext('Please download a base release first.')
|
||||
. '</a>';
|
||||
$prerequisites_ok = false;
|
||||
endif;
|
||||
|
||||
if($_POST):
|
||||
global $empty_releases;
|
||||
global $configfile;
|
||||
unset($input_errors);
|
||||
$pconfig = $_POST;
|
||||
if(isset($_POST['Cancel']) && $_POST['Cancel']):
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
endif;
|
||||
if(isset($_POST['Create']) && $_POST['Create']):
|
||||
$jname = $pconfig['jailname'];
|
||||
$ipaddr = $pconfig['ipaddress'];
|
||||
$release = $pconfig['release'];
|
||||
if ($_POST['interface'] == 'NONE'):
|
||||
$interface = "";
|
||||
else:
|
||||
$interface = $pconfig['interface'];
|
||||
endif;
|
||||
|
||||
if($empty_releases !== "YES"):
|
||||
if ($_POST['nowstart']):
|
||||
$cmd = ("/usr/local/bin/bastille create {$jname} {$release} {$ipaddr} {$interface} && /usr/local/bin/bastille start {$jname}");
|
||||
else:
|
||||
$cmd = ("/usr/local/bin/bastille create {$jname} {$release} {$ipaddr} {$interface}");
|
||||
endif;
|
||||
else:
|
||||
$cmd = "";
|
||||
endif;
|
||||
if ($_POST['Create']):
|
||||
if ($_POST['autostart']):
|
||||
exec("/usr/sbin/sysrc -f {$configfile} {$jname}_AUTO_START=\"YES\"");
|
||||
endif;
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
//$savemsg .= gtext("Boot Environment created and activated successfully.");
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to create container.");
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
include 'fbegin.inc';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(window).on("load",function() {
|
||||
$("#iform").submit(function() { spinner(); });
|
||||
$(".spin").click(function() { spinner(); });
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
$document = new co_DOMDocument();
|
||||
$document->
|
||||
add_area_tabnav()->
|
||||
push()->
|
||||
add_tabnav_upper()->
|
||||
ins_tabnav_record('bastille_manager_gui.php',gettext('Containers'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_info.php',gettext('Information'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_maintenance.php',gettext('Maintenance'),gettext('Reload page'),true);
|
||||
$document->render();
|
||||
?>
|
||||
<form action="bastille_manager_add.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
<?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 class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('Create new Container'));
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
html_inputbox2('jailname',gettext('Friendly name'),$pconfig['jailname'],'',true,20);
|
||||
html_inputbox2('ipaddress',gettext('IPv4 Address'),$pconfig['ipaddress'],'',true,20);
|
||||
$a_action = $l_interfaces;
|
||||
$b_action = $l_release;
|
||||
html_combobox2('interface',gettext('Network interface'),$pconfig['interface'],$a_action,'',true,false,'action_change()');
|
||||
html_combobox2('release',gettext('Base release'),$pconfig['release'],$b_action,'',true,false,'action_change()');
|
||||
html_checkbox2('nowstart',gettext('Start after creation'),!empty($pconfig['nowstart']) ? true : false,gettext('Start the container after creation.'),'',false);
|
||||
html_checkbox2('autostart',gettext('Auto start on boot'),!empty($pconfig['autostart']) ? true : false,gettext('Automatically start the container at boot time.'),'',false);
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="submit">
|
||||
<input name="Create" type="submit" class="formbtn" value="<?=gtext('Create');?>"/>
|
||||
<input name="Cancel" type="submit" class="formbtn" value="<?=gtext('Cancel');?>" />
|
||||
|
||||
</div>
|
||||
<?php
|
||||
include 'formend.inc';
|
||||
?>
|
||||
</td></tr></tbody></table></form>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
?>
|
||||
177
gui/bastille_manager_config.php
Normal file
177
gui/bastille_manager_config.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_config.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Copyright (c) 2018 Andreas Schmidhuber
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require("auth.inc");
|
||||
require("guiconfig.inc");
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
$configAddon = "{$bastille_config}";
|
||||
|
||||
$textdomain = "/usr/local/share/locale";
|
||||
$textdomain_bastille = "/usr/local/share/locale-bastille";
|
||||
if (!is_link($textdomain_bastille)) { mwexec("ln -s {$rootfolder}/locale-bastille {$textdomain_bastille}", true); }
|
||||
bindtextdomain("xigmanas", $textdomain_bastille);
|
||||
|
||||
$pgtitle = array(gtext("Extensions"), gtext("Bastille"), gtext("Configuration"));
|
||||
|
||||
$wSpace = " ";
|
||||
$wSpaceEqual = " = ";
|
||||
$paramNameSize = 30; //length of parameter name input field, default for parameter value input field is '80'
|
||||
|
||||
function htmlInput($name, $title, $value="", $size=80) {
|
||||
$result = "<input name='{$name}' size='{$size}' title='{$title}' placeholder='{$title}' value='{$value}' />";
|
||||
return $result;
|
||||
}
|
||||
|
||||
function htmlButton($name, $text, $value="", $title="", $confirm="", $buttonImage="") {
|
||||
$onClick = ($confirm == "") ? "" : "onclick='return confirm(\"{$confirm}\")'";
|
||||
switch ($buttonImage) {
|
||||
case "save": $buttonImage = "<img src='images/status_enabled.png' height='10' width='10'>"; break;
|
||||
default: $buttonImage = "";
|
||||
}
|
||||
$result = "<button name='{$name}' type='submit' class='formbtn' title='{$title}' value='{$value}' {$onClick}>{$buttonImage}{$text}</button>";
|
||||
return $result;
|
||||
}
|
||||
|
||||
function parseConfigFile($configFile) {
|
||||
$fileArray = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // load config file content to array
|
||||
$configArray = array();
|
||||
foreach($fileArray as $line) { // create array from config
|
||||
$line = trim($line); // remove leading/trailing space
|
||||
if ($line[0] == "#") continue; // skip if comment line
|
||||
if ($line[0] == "[") { // add as section
|
||||
$configArray[$line] = [];
|
||||
$section = $line; // remember section name for params
|
||||
} else { // process params
|
||||
$parameter = explode("=", $line, 2); // seperate key and value, (Split at the first occurrence only)
|
||||
$key = trim($parameter[0]); // set key
|
||||
$val = explode("#", trim($parameter[1])); // get value, remove trailing comments
|
||||
$value = $val[0]; // set value
|
||||
$configArray[$section][$key] = $value; // add param to section
|
||||
}
|
||||
}
|
||||
return $configArray;
|
||||
}
|
||||
|
||||
function saveConfigFile($configFile, $configArray, $hashTag="", $prettyPrint=true) {
|
||||
//$printTab = ($prettyPrint) ? "\t" : ""; // Print leading tab.
|
||||
//$printSpace = ($prettyPrint) ? " " : ""; // Print spaces.
|
||||
$printTab = ($prettyPrint) ? "" : ""; // Do not print leading tab.
|
||||
$printSpace = ($prettyPrint) ? "" : ""; // Do not print spaces.
|
||||
|
||||
$cFile = fopen($configFile, "w");
|
||||
foreach($configArray as $key => $line) { // traverse array, key = section
|
||||
if (is_array($line)) {
|
||||
if ($key != '') fwrite($cFile, $key.PHP_EOL); // write section if not "['']" => NO section
|
||||
foreach($line as $pName => $pValue) fwrite($cFile, $printTab.$pName.$printSpace."=".$printSpace.$pValue.PHP_EOL); // "\t".$pName = add TAB for output formatting
|
||||
fwrite($cFile, PHP_EOL);
|
||||
} else fwrite($cFile, $key.$printSpace."=".$printSpace.$line.PHP_EOL);
|
||||
} // end foreach
|
||||
fclose($cFile);
|
||||
if (!empty($hashTag)) header("Location:#{$hashTag}");
|
||||
}
|
||||
|
||||
// load addon config - use selected config from Bastille tab or alternative if exist
|
||||
$configAddonArray = parseConfigFile($configAddon); // read addon config file
|
||||
if (empty($configAddonArray['']['ALTERNATIVE_CONFIG'])) $configFile = str_replace('"', "", $configAddonArray['']['BASTILLE_CONFIG']); // get Bastille config file path and name
|
||||
else $configFile = str_replace('"', "", $configAddonArray['']['ALTERNATIVE_CONFIG']); // get Bastille config file path and name
|
||||
|
||||
// load Bastille config
|
||||
if (!is_file($configFile)) $input_errors[] = sprintf(gtext("%s not found!"), gettext("Configuration File")." {$configFile}");
|
||||
else {
|
||||
$configArray = parseConfigFile($configFile); // parse Bastille config file
|
||||
//$savemsg = gtext("Loaded config file").": <b>".basename($configFile)."</b>";
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
unset($input_errors);
|
||||
|
||||
if (isset($_POST['saveParam']) && $_POST['saveParam']) { // saveParam s/n/v: [[outputs.influxdb]]#urls outputsinfluxdburls ["http://192.168.1.XYZ:8086"]
|
||||
$buttonTag = explode("#", $_POST['saveParam']); // buttonTag[0] = section, buttonTag[1] = paramName
|
||||
$hashTag = str_replace(["[", "]", ".", "#"], "", $buttonTag[0]); // create destination to jump to after post
|
||||
$nameTag = str_replace(["[", "]", ".", "#"], "", $_POST['saveParam']); // nameTag = <input title='$nameTag + addParam' ... />
|
||||
$configArray[$buttonTag[0]][$buttonTag[1]] = $_POST[$nameTag]; // save param to section
|
||||
# $savemsg .= "saveParam s/n/v: ".$_POST['saveParam']." ".$nameTag." ".$_POST[$nameTag];
|
||||
}
|
||||
|
||||
if (empty($input_errors) && !isset($_POST['loadConfig'])) saveConfigFile($configFile, $configArray, $hashTag);
|
||||
}
|
||||
|
||||
bindtextdomain("xigmanas", $textdomain);
|
||||
include("fbegin.inc");
|
||||
bindtextdomain("xigmanas", $textdomain_bastille);
|
||||
?>
|
||||
<form action="bastille_manager_config.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td class="tabnavtbl">
|
||||
<ul id="tabnav">
|
||||
<li class="tabinact"><a href="bastille_manager_gui.php"><span><?=gettext("Bastille");?></span></a></li>
|
||||
<li class="tabact"><a href="bastille_manager_config.php"><span><?=gettext("Configuration");?></span></a></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
<tr><td class="tabcont">
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<?php // create table from configuration
|
||||
echo "<tr><td colspan='2' style='padding-left:0px; padding-right:0px;'>";
|
||||
if (!empty($input_errors)) print_input_errors($input_errors);
|
||||
if (!empty($savemsg)) print_info_box($savemsg);
|
||||
echo "</td></tr>";
|
||||
// loop through configuration
|
||||
$firstSection = true; // prevent first html_separator in loop
|
||||
if (is_array($configArray) && !empty($configArray))
|
||||
foreach($configArray as $key => $line) { // traverse array, key = section
|
||||
$nameTag = str_replace(["[", "]", "."], "", $key); // create tag for post jump address and config changes
|
||||
if (is_array($line)) {
|
||||
if ($firstSection === true) $firstSection = false;
|
||||
else html_separator();
|
||||
html_titleline(gtext("Variable Name").": ".$key, 2, $nameTag); // section title bar
|
||||
foreach($line as $pName => $pValue) // traverse params within section, pName = param name, pValue = param value
|
||||
html_text($pName, $pName, // create param entry
|
||||
htmlInput($nameTag.$pName, gtext("Parameter Value"), $pValue).$wSpace.
|
||||
htmlButton("saveParam", "", $key."#".$pName, gtext("Save"), "", "save").$wSpace. "",
|
||||
);
|
||||
}
|
||||
echo "<tr><td style='padding-left:0px;'>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo "<tr><td colspan='2' style='padding-left:0px;'>";
|
||||
html_remark("noteAddSection", gtext("Note"), gtext("Please be careful, as no validation will be performed on your input!"));
|
||||
echo "</td></tr>";
|
||||
?>
|
||||
</table><?php include("formend.inc");?>
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include("fend.inc");?>
|
||||
162
gui/bastille_manager_editor.php
Normal file
162
gui/bastille_manager_editor.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_editor.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
$savetopath = "{$rootfolder}/jails/";
|
||||
if (isset($_POST['savetopath'])) {
|
||||
$savetopath = htmlspecialchars($_POST['savetopath']);
|
||||
}
|
||||
if(isset($_POST['submit'])) {
|
||||
switch($_POST['submit']) {
|
||||
case 'edit':
|
||||
if(preg_match('/\S/', $savetopath)) {
|
||||
if(file_exists($savetopath) && is_file($savetopath)) {
|
||||
$content = file_get_contents($savetopath);
|
||||
$edit_area = "";
|
||||
if (stristr($savetopath, ".php") == true) $language = "php";
|
||||
else if (stristr($savetopath, ".inc") == true) $language = "php";
|
||||
else if (stristr($savetopath, ".sh") == true) $language = "core";
|
||||
else if (stristr($savetopath, ".xml") == true) $language = "xml";
|
||||
else if (stristr($savetopath, ".js") == true) $language = "js";
|
||||
else if (stristr($savetopath, ".css") == true) $language = "css";
|
||||
} else {
|
||||
$savemsg = sprintf('%s %s', gtext('File not found'), $savetopath);
|
||||
$content = '';
|
||||
$savetopath = '';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'save':
|
||||
if(preg_match('/\S/', $savetopath)) {
|
||||
conf_mount_rw();
|
||||
$content = preg_replace("/\r/","",$_POST['code']) ;
|
||||
file_put_contents($savetopath, $content);
|
||||
$edit_area = "";
|
||||
$savemsg = sprintf('%s %s', gtext('Saved file to'), $savetopath);
|
||||
if ($savetopath === "{$g['cf_conf_path']}/config.xml") {
|
||||
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
||||
}
|
||||
conf_mount_ro();
|
||||
}
|
||||
break;
|
||||
case 'bastille':
|
||||
// Return to Bastille index.
|
||||
header('Location: bastille_manager_gui.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['rows']) && !empty($_POST['rows'])) {
|
||||
$rows = $_POST['rows'];
|
||||
} else {
|
||||
$rows = 30;
|
||||
}
|
||||
if(isset($_POST['cols']) && !empty($_POST['cols'])) {
|
||||
$cols = $_POST['cols'];
|
||||
} else {
|
||||
$cols = 66;
|
||||
}
|
||||
$pgtitle = [gtext('Bastille'), gtext('File Editor')];
|
||||
include 'fbegin.inc';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(window).on("load", function() {
|
||||
<?php // Init spinner onsubmit()?>
|
||||
$("#iform").submit(function() { spinner(); });
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<table id="area_data"><tbody><tr><td id="area_data_frame"><form action="bastille_manager_editor.php" method="post" name="iform" id="iform">
|
||||
<?php
|
||||
if(!empty($savemsg)):
|
||||
print_info_box($savemsg);
|
||||
endif;
|
||||
?>
|
||||
<table class="area_data_settings">
|
||||
<colgroup>
|
||||
<col style="width:100%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('File Editor'),1);
|
||||
html_separator2(1);
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label"><?=gtext('File Path');?></span>
|
||||
<input size="42" id="savetopath" name="savetopath" value="<?=$savetopath;?>" />
|
||||
<input name="browse" type="button" class="formbtn" id="Browse" onclick='ifield = form.savetopath; filechooser = window.open("filechooser.php?p="+encodeURIComponent(ifield.value), "filechooser", "scrollbars=yes,toolbar=no,menubar=no,statusbar=no,width=550,height=300"); filechooser.ifield = ifield; window.ifield = ifield;' value="..." />
|
||||
<button name="submit" type="submit" class="formbtn" id="Edit" value="edit"><?=gtext('Edit');?></button>
|
||||
<button name="submit" type="submit" class="formbtn" id="Save" value="save"><?=gtext('Save');?></button>
|
||||
<button name="submit" type="submit" class="formbtn" id="Return" value="bastille"><?=gtext('Return to Bastille');?></button>
|
||||
<hr noshade="noshade" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
html_separator2(1);
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" class="label">
|
||||
<div style="background: #eeeeee;" id="textareaitem">
|
||||
<?php
|
||||
// NOTE: The opening *and* the closing textarea tag must be on the same line.
|
||||
?>
|
||||
<textarea style="width:100%; margin:0;" class="<?=$language;?>:showcolumns" rows="<?=$rows;?>" cols="<?=$cols;?>" name="code"><?=htmlspecialchars(!empty($content) ? $content : '');?></textarea>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
include 'formend.inc';
|
||||
?>
|
||||
</form></td></tr></tbody></table>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
// Set focus.
|
||||
document.forms[0].savetopath.focus();
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
351
gui/bastille_manager_gui.php
Normal file
351
gui/bastille_manager_gui.php
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_gui.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once 'bastille_manager-lib.inc';
|
||||
|
||||
$sphere_scriptname = basename(__FILE__);
|
||||
$sphere_scriptname_child = 'bastille_manager_util.php';
|
||||
$sphere_header = 'Location: '.$sphere_scriptname;
|
||||
$sphere_header_parent = $sphere_header;
|
||||
$sphere_array = [];
|
||||
$sphere_record = [];
|
||||
$checkbox_member_name = 'checkbox_member_array';
|
||||
$checkbox_member_array = [];
|
||||
$checkbox_member_record = [];
|
||||
$gt_record_add = gtext('Create new jail');
|
||||
$gt_record_mod = gtext('Utilities');
|
||||
$gt_selection_start = gtext('Start Selected');
|
||||
$gt_selection_stop = gtext('Stop Selected');
|
||||
$gt_selection_restart = gtext('Restart Selected');
|
||||
$gt_record_inf = gtext('Information');
|
||||
$gt_selection_start_confirm = gtext('Do you really want to start selected jail(s)?');
|
||||
$gt_selection_stop_confirm = gtext('Do you want to stop the selected jail(s)?');
|
||||
$gt_selection_restart_confirm = gtext('Do you want to restart the selected jail(s)?');
|
||||
$img_path = [
|
||||
'add' => 'images/add.png',
|
||||
'mod' => 'images/edit.png',
|
||||
'del' => 'images/delete.png',
|
||||
'loc' => 'images/locked.png',
|
||||
'unl' => 'images/unlocked.png',
|
||||
'mai' => 'images/maintain.png',
|
||||
'inf' => 'images/info.png',
|
||||
'ena' => 'images/status_enabled.png',
|
||||
'dis' => 'images/status_disabled.png',
|
||||
'mup' => 'images/up.png',
|
||||
'mdn' => 'images/down.png'
|
||||
];
|
||||
|
||||
$jls_list = get_jail_infos();
|
||||
$sphere_array = $jls_list;
|
||||
|
||||
if($_POST):
|
||||
if(isset($_POST['apply']) && $_POST['apply']):
|
||||
$ret = array('output' => [], 'retval' => 0);
|
||||
if(!file_exists($d_sysrebootreqd_path)):
|
||||
// Process notifications
|
||||
endif;
|
||||
$savemsg = get_std_save_message($ret['retval']);
|
||||
if($ret['retval'] == 0):
|
||||
updatenotify_delete($sphere_notifier);
|
||||
header($sphere_header);
|
||||
exit;
|
||||
endif;
|
||||
updatenotify_delete($sphere_notifier);
|
||||
$errormsg = implode("\n", $ret['output']);
|
||||
endif;
|
||||
|
||||
if(isset($_POST['start_selected_jail']) && $_POST['start_selected_jail']):
|
||||
$checkbox_member_array = isset($_POST[$checkbox_member_name]) ? $_POST[$checkbox_member_name] : [];
|
||||
foreach($checkbox_member_array as $checkbox_member_record):
|
||||
if(false !== ($index = array_search_ex($checkbox_member_record, $sphere_array, 'jailname'))):
|
||||
if(!isset($sphere_array[$index]['protected'])):
|
||||
$cmd = ("/usr/local/bin/bastille start {$checkbox_member_record}");
|
||||
$return_val = mwexec($cmd);
|
||||
if($return_val == 0):
|
||||
//$savemsg .= gtext("Jail(s) started successfully.");
|
||||
header($sphere_header);
|
||||
else:
|
||||
$errormsg .= gtext("Failed to start jail(s).");
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if(isset($_POST['stop_selected_jail']) && $_POST['stop_selected_jail']):
|
||||
$checkbox_member_array = isset($_POST[$checkbox_member_name]) ? $_POST[$checkbox_member_name] : [];
|
||||
foreach($checkbox_member_array as $checkbox_member_record):
|
||||
if(false !== ($index = array_search_ex($checkbox_member_record, $sphere_array, 'jailname'))):
|
||||
if(!isset($sphere_array[$index]['protected'])):
|
||||
$cmd = ("/usr/local/bin/bastille stop {$checkbox_member_record}");
|
||||
$return_val = mwexec($cmd);
|
||||
if($return_val == 0):
|
||||
//$savemsg .= gtext("Jail(s) stopped successfully.");
|
||||
header($sphere_header);
|
||||
else:
|
||||
$errormsg .= gtext("Failed to stop jail(s).");
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if(isset($_POST['restart_selected_jail']) && $_POST['restart_selected_jail']):
|
||||
$checkbox_member_array = isset($_POST[$checkbox_member_name]) ? $_POST[$checkbox_member_name] : [];
|
||||
foreach($checkbox_member_array as $checkbox_member_record):
|
||||
if(false !== ($index = array_search_ex($checkbox_member_record, $sphere_array, 'jailname'))):
|
||||
if(!isset($sphere_array[$index]['protected'])):
|
||||
$cmd = ("/usr/local/bin/bastille restart {$checkbox_member_record}");
|
||||
$return_val = mwexec($cmd);
|
||||
if($return_val == 0):
|
||||
//$savemsg .= gtext("Jail(s) restarted successfully.");
|
||||
header($sphere_header);
|
||||
else:
|
||||
$errormsg .= gtext("Failed to restart jail(s).");
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$pgtitle = [gtext("Extensions"), gtext('Bastille')];
|
||||
include 'fbegin.inc';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(window).on("load", function() {
|
||||
// Init action buttons
|
||||
$("#start_selected_jail").click(function () {
|
||||
return confirm('<?=$gt_selection_start_confirm;?>');
|
||||
});
|
||||
$("#stop_selected_jail").click(function () {
|
||||
return confirm('<?=$gt_selection_stop_confirm;?>');
|
||||
});
|
||||
$("#restart_selected_jail").click(function () {
|
||||
return confirm('<?=$gt_selection_restart_confirm;?>');
|
||||
});
|
||||
// Disable action buttons.
|
||||
disableactionbuttons(true);
|
||||
|
||||
// Init member checkboxes
|
||||
$("input[name='<?=$checkbox_member_name;?>[]']").click(function() {
|
||||
controlactionbuttons(this, '<?=$checkbox_member_name;?>[]');
|
||||
});
|
||||
// Init spinner onsubmit()
|
||||
$("#iform").submit(function() { spinner(); });
|
||||
$(".spin").click(function() { spinner(); });
|
||||
});
|
||||
function disableactionbuttons(ab_disable) {
|
||||
$("#start_selected_jail").prop("disabled", ab_disable);
|
||||
$("#stop_selected_jail").prop("disabled", ab_disable);
|
||||
$("#restart_selected_jail").prop("disabled", ab_disable);
|
||||
}
|
||||
|
||||
function controlactionbuttons(ego, triggerbyname) {
|
||||
var a_trigger = document.getElementsByName(triggerbyname);
|
||||
var n_trigger = a_trigger.length;
|
||||
var ab_disable = true;
|
||||
var i = 0;
|
||||
for (; i < n_trigger; i++) {
|
||||
if (a_trigger[i].type == 'checkbox') {
|
||||
if (a_trigger[i].checked) {
|
||||
ab_disable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
disableactionbuttons(ab_disable);
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
$document = new co_DOMDocument();
|
||||
$document->
|
||||
add_area_tabnav()->
|
||||
push()->
|
||||
add_tabnav_upper()->
|
||||
ins_tabnav_record('bastille_manager_gui.php',gettext('Containers'))->
|
||||
ins_tabnav_record('bastille_manager_info.php',gettext('Information'))->
|
||||
ins_tabnav_record('bastille_manager_maintenance.php',gettext('Maintenance'));
|
||||
$document->render();
|
||||
?>
|
||||
<form action="bastille_manager_gui.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
<?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(updatenotify_exists($sphere_notifier)):
|
||||
print_config_change_box();
|
||||
endif;
|
||||
?>
|
||||
<table class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="area_data_selection">
|
||||
<colgroup>
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
<col style="width:10%">
|
||||
<col style="width:10%">
|
||||
<col style="width:5%">
|
||||
<col style="width:25%">
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_separator2();
|
||||
html_titleline2(gettext('Overview'), 10);
|
||||
?>
|
||||
<tr>
|
||||
<th class="lhelc"><?=gtext('Select');?></th>
|
||||
<th class="lhell"><?=gtext('JID');?></th>
|
||||
<th class="lhell"><?=gtext('IPv4 Address');?></th>
|
||||
<th class="lhell"><?=gtext('Hostname');?></th>
|
||||
<th class="lhell"><?=gtext('Interface');?></th>
|
||||
<th class="lhell"><?=gtext('Path');?></th>
|
||||
<th class="lhell"><?=gtext('Boot');?></th>
|
||||
<th class="lhell"><?=gtext('Active');?></th>
|
||||
<th class="lhell"><?=gtext('Template');?></th>
|
||||
<th class="lhebl"><?=gtext('Toolbox');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($sphere_array as $sphere_record):
|
||||
$notificationmode = updatenotify_get_mode($sphere_notifier, $identifier);
|
||||
$notdirty = (UPDATENOTIFY_MODE_DIRTY != $notificationmode) && (UPDATENOTIFY_MODE_DIRTY_CONFIG != $notificationmode);
|
||||
$notprotected = !isset($sphere_record['protected']);
|
||||
?>
|
||||
<tr>
|
||||
<td class="lcelc">
|
||||
<?php
|
||||
if ($notdirty && $notprotected):
|
||||
?>
|
||||
<input type="checkbox" name="<?=$checkbox_member_name;?>[]" value="<?=$sphere_record['jailname'];?>" id="<?=$sphere_record['jailname'];?>"/>
|
||||
<?php
|
||||
else:
|
||||
?>
|
||||
<input type="checkbox" name="<?=$checkbox_member_name;?>[]" value="<?=$sphere_record['jailname'];?>" id="<?=$sphere_record['jailname'];?>" disabled="disabled"/>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</td>
|
||||
<td class="lcell"><?=htmlspecialchars($sphere_record['id']);?> </td>
|
||||
<td class="lcell"><?=htmlspecialchars($sphere_record['ip']);?> </td>
|
||||
<td class="lcell"><?=htmlspecialchars($sphere_record['name']);?> </td>
|
||||
<td class="lcell"><?=htmlspecialchars($sphere_record['nic']);?> </td>
|
||||
<td class="lcell"><?=htmlspecialchars($sphere_record['path']);?> </td>
|
||||
<td class="lcell"><img src="<?=$sphere_record['boot'];?>"></td>
|
||||
<td class="lcell"><img src="<?=$sphere_record['stat'];?>"></td>
|
||||
<td class="lcell"><img src="<?=$sphere_record['logo'];?>"></td>
|
||||
<td class="lcebld">
|
||||
<table class="area_data_selection_toolbox"><tbody><tr>
|
||||
<td>
|
||||
<?php
|
||||
if($notdirty && $notprotected):
|
||||
?>
|
||||
<a href="<?=$sphere_scriptname_child;?>?jailname=<?=urlencode($sphere_record['jailname']);?>"><img src="<?=$img_path['mai'];?>" title="<?=$gt_record_mod;?>" alt="<?=$gt_record_mod;?>" class="spin oneemhigh"/></a>
|
||||
<?php
|
||||
else:
|
||||
if ($notprotected):
|
||||
?>
|
||||
<img src="<?=$img_path['del'];?>" title="<?=$gt_record_del;?>" alt="<?=$gt_record_del;?>"/>
|
||||
<?php
|
||||
else:
|
||||
?>
|
||||
<img src="<?=$img_path['loc'];?>" title="<?=$gt_record_loc;?>" alt="<?=$gt_record_loc;?>"/>
|
||||
<?php
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<a href="bastille_manager_info.php?uuid=<?=urlencode($sphere_record['jailname']);?>"><img src="<?=$g_img['inf'];?>" title="<?=$gt_record_inf?>" alt="<?=$gt_record_inf?>"/></a>
|
||||
</td>
|
||||
</tr></tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="lcenl" colspan="9"></td>
|
||||
<td class="lceadd">
|
||||
<a href="bastille_manager_add.php"><img src="<?=$img_path['add'];?>" title="<?=$gt_record_add;?>" border="0" alt="<?=$gt_record_add;?>" class="spin oneemhigh"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div id="submit">
|
||||
<input name="start_selected_jail" id="start_selected_jail" type="submit" class="formbtn" value="<?=$gt_selection_start;?>"/>
|
||||
<input name="stop_selected_jail" id="stop_selected_jail" type="submit" class="formbtn" value="<?=$gt_selection_stop;?>"/>
|
||||
<input name="restart_selected_jail" id="restart_selected_jail" type="submit" class="formbtn" value="<?=$gt_selection_restart;?>"/>
|
||||
</div>
|
||||
<?php
|
||||
include 'formend.inc';
|
||||
?>
|
||||
</td></tr></tbody></table></form>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
148
gui/bastille_manager_info.php
Normal file
148
gui/bastille_manager_info.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_info.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
function jls_get_jail_list(string $entity_name = NULL) {
|
||||
if(isset($entity_name)):
|
||||
$cmd = "/usr/sbin/jls -v -j $entity_name 2>&1";
|
||||
else:
|
||||
$cmd = '/usr/sbin/jls -v 2>&1';
|
||||
endif;
|
||||
unset($output);
|
||||
mwexec2($cmd,$output);
|
||||
return implode(PHP_EOL,$output);
|
||||
}
|
||||
|
||||
function jls_get_all(string $entity_name = NULL) {
|
||||
if(isset($entity_name)):
|
||||
$cmd = "/usr/sbin/jls -qn -j $entity_name | tr -s \" \" \"\n\" 2>&1";
|
||||
else:
|
||||
$cmd = ':';
|
||||
endif;
|
||||
unset($a_names);
|
||||
mwexec2($cmd,$a_names);
|
||||
if(is_array($a_names) && count($a_names) > 0):
|
||||
$names = implode(' ',array_map('escapeshellarg',$a_names));
|
||||
unset($output);
|
||||
mwexec2($cmd,$output);
|
||||
else:
|
||||
$output = [gtext('Parameters information available for individual selection only.')];
|
||||
endif;
|
||||
return implode(PHP_EOL,$output);
|
||||
}
|
||||
|
||||
$entity_name = NULL;
|
||||
if(isset($_GET['uuid']) && is_string($_GET['uuid'])):
|
||||
$entity_name = sprintf('%s',$_GET['uuid']);
|
||||
endif;
|
||||
$pgtitle = [gtext("Extensions"), gtext('Bastille'),gtext('Information')];
|
||||
include 'fbegin.inc';
|
||||
$document = new co_DOMDocument();
|
||||
$document->
|
||||
add_area_tabnav()->
|
||||
push()->
|
||||
add_tabnav_upper()->
|
||||
ins_tabnav_record('bastille_manager_gui.php',gettext('Containers'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_info.php',gettext('Information'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_maintenance.php',gettext('Maintenance'),gettext('Reload page'),true);
|
||||
$document->render();
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(!empty($errormsg)):
|
||||
print_error_box($errormsg);
|
||||
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 id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
<table class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('Container Summary'));
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="celltag"><?=gtext('Summary');?></td>
|
||||
<td class="celldata">
|
||||
<pre><span id="jls_jail_list"><?=jls_get_jail_list($entity_name);?></span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<?php
|
||||
html_separator2();
|
||||
?>
|
||||
</tfoot>
|
||||
</table>
|
||||
<table class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('Container Parameters'));
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="celltag"><?=gtext('Parameters');?></td>
|
||||
<td class="celldata">
|
||||
<pre><span id="jls_get_info"><?=jls_get_all($entity_name);?></span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tbody>
|
||||
</table>
|
||||
<tbody>
|
||||
</td></tr></tbody></table>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
?>
|
||||
@@ -1,48 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
bastille-gui.php
|
||||
bastille_manager_maintenance.php
|
||||
|
||||
WebGUI wrapper for the XigmaNAS "Bastille" add-on created by JoseMR.
|
||||
(https://www.xigmanas.com/forums/viewtopic.php?f=71&t=11184)
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Copyright (c) 2016 Andreas Schmidhuber
|
||||
All rights reserved.
|
||||
|
||||
Portions of NAS4Free (http://www.nas4free.org).
|
||||
Portions of XigmaNAS (http://www.nas4free.org).
|
||||
Copyright (c) 2012-2016 The NAS4Free Project <info@nas4free.org>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the NAS4Free Project.
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require("auth.inc");
|
||||
require("guiconfig.inc");
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
$application = "Bastille";
|
||||
$pgtitle = array(gtext("Extensions"), "Bastille");
|
||||
$pgtitle = array(gtext("Extensions"), "Bastille", "Maintenance");
|
||||
|
||||
// For NAS4Free 10.x versions.
|
||||
// For legacy product versions.
|
||||
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
|
||||
if ($return_val == 0) {
|
||||
if (is_array($config['rc']['postinit'] ) && is_array( $config['rc']['postinit']['cmd'] ) ) {
|
||||
@@ -50,29 +52,15 @@ if ($return_val == 0) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize some variables.
|
||||
//$rootfolder = dirname($config['rc']['postinit']['cmd'][$i]);
|
||||
$confdir = "/var/etc/bastilleconf";
|
||||
$cwdir = exec("/usr/bin/grep 'INSTALL_DIR=' {$confdir}/conf/bastille_config | cut -d'\"' -f2");
|
||||
$rootfolder = $cwdir;
|
||||
$configfile = "{$rootfolder}/conf/bastille_config";
|
||||
$versionfile = "{$rootfolder}/version";
|
||||
$date = strftime('%c');
|
||||
$logfile = "{$rootfolder}/log/bastille_ext.log";
|
||||
$logevent = "{$rootfolder}/log/bastille_last_event.log";
|
||||
// Set default backup directory.
|
||||
if (1 == mwexec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR='")) {
|
||||
if (is_file("{$configfile}")) exec("/usr/sbin/sysrc -f {$configfile} BACKUP_DIR={$rootfolder}/backups");
|
||||
}
|
||||
$backup_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR=' | cut -d'\"' -f2");
|
||||
|
||||
$prdname = "bastille";
|
||||
$tarballversion = "/usr/local/bin/bastille";
|
||||
|
||||
if ($rootfolder == "") $input_errors[] = gtext("Extension installed with fault");
|
||||
else {
|
||||
// Initialize locales.
|
||||
$textdomain = "/usr/local/share/locale";
|
||||
$textdomain_bastille = "/usr/local/share/locale-bastille";
|
||||
if (!is_link($textdomain_bastille)) { mwexec("ln -s {$rootfolder}/locale-bastille {$textdomain_bastille}", true); }
|
||||
bindtextdomain("xigmanas", $textdomain_bastille);
|
||||
}
|
||||
if (is_file("{$rootfolder}/postinit")) unlink("{$rootfolder}/postinit");
|
||||
|
||||
if ($_POST) {
|
||||
if(isset($_POST['upgrade']) && $_POST['upgrade']):
|
||||
$cmd = sprintf('%1$s/bastille-init -u > %2$s',$rootfolder,$logevent);
|
||||
@@ -105,7 +93,7 @@ if ($_POST) {
|
||||
if (is_link("/var/cache/pkg")) mwexec("rm /var/cache/pkg", true);
|
||||
if (is_link("/var/db/pkg")) mwexec("rm /var/db/pkg && mkdir /var/db/pkg", true);
|
||||
|
||||
// Remove postinit cmd in NAS4Free 10.x versions.
|
||||
// Remove postinit cmd in legacy product versions.
|
||||
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
|
||||
if ($return_val == 0) {
|
||||
if (is_array($config['rc']['postinit']) && is_array($config['rc']['postinit']['cmd'])) {
|
||||
@@ -117,7 +105,7 @@ if ($_POST) {
|
||||
write_config();
|
||||
}
|
||||
|
||||
// Remove postinit cmd in NAS4Free later versions.
|
||||
// Remove postinit cmd in later product versions.
|
||||
if (is_array($config['rc']) && is_array($config['rc']['param'])) {
|
||||
$postinit_cmd = "{$rootfolder}/bastille-init";
|
||||
$value = $postinit_cmd;
|
||||
@@ -135,6 +123,29 @@ if ($_POST) {
|
||||
header("Location:index.php");
|
||||
}
|
||||
|
||||
if (isset($_POST['save']) && $_POST['save']) {
|
||||
// Ensure to have NO whitespace & trailing slash.
|
||||
$backup_path = rtrim(trim($_POST['backup_path']),'/');
|
||||
if ("{$backup_path}" == "") {
|
||||
$backup_path = "{$rootfolder}/backups";
|
||||
}
|
||||
if (!is_file($backup_path)) {
|
||||
$cmd = "/usr/sbin/sysrc -f {$configfile} BACKUP_DIR={$backup_path}";
|
||||
unset($retval);mwexec($cmd,$retval);
|
||||
if ($retval == 0) {
|
||||
$savemsg .= gtext("Extension settings saved successfully.");
|
||||
exec("echo '{$date}: {$application} Extension settings saved successfully' >> {$logfile}");
|
||||
}
|
||||
else {
|
||||
$input_errors[] = gtext("Failed to save extension settings.");
|
||||
exec("echo '{$date}: {$application} Failed to save extension settings' >> {$logfile}");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$input_errors[] = gtext("Failed to save extension settings.");
|
||||
exec("echo '{$date}: {$application} Failed to save extension settings' >> {$logfile}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_version_bastille() {
|
||||
@@ -185,11 +196,33 @@ $(document).ready(function(){
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<form action="bastille-gui.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($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">
|
||||
<tr><td class="tabnavtbl">
|
||||
<ul id="tabnav">
|
||||
<li class="tabinact"><a href="bastille_manager_gui.php"><span><?=gettext("Containers");?></span></a></li>
|
||||
<li class="tabact"><a href="bastille_manager_info.php"><span><?=gettext("Information");?></span></a></li>
|
||||
<li class="tabact"><a href="bastille_manager_maintenance.php"><span><?=gettext("Maintenance");?></span></a></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
<tr><td class="tabnavtbl">
|
||||
<ul id="tabnav2">
|
||||
<li class="tabact"><a href="bastille_manager_config.php"><span><?=gettext("Bastille Configuration");?></span></a></li>
|
||||
<li class="tabact"><a href="bastille_manager_tarballs.php"><span><?=gettext("Base Releases");?></span></a></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
<tr><td class="tabcont">
|
||||
<?php if (!empty($input_errors)) print_input_errors($input_errors);?>
|
||||
<?php if (!empty($savemsg)) print_info_box($savemsg);?>
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<?php html_titleline(gtext("Bastille"));?>
|
||||
<?php html_text("installation_directory", gtext("Installation directory"), sprintf(gtext("The extension is installed in %s"), $rootfolder));?>
|
||||
@@ -201,8 +234,10 @@ $(document).ready(function(){
|
||||
<td class="vncellt"><?=gtext("Extension version");?></td>
|
||||
<td class="vtable"><span name="getinfo_ext" id="getinfo_ext"><?=get_version_ext()?></span></td>
|
||||
</tr>
|
||||
<?php html_filechooser("backup_path", gtext("Backup directory"), $backup_path, gtext("Directory to store containers .tar backup archives."), $backup_path, true, 60);?>
|
||||
</table>
|
||||
<div id="submit">
|
||||
<input id="save" name="save" type="submit" class="formbtn" title="<?=gtext("Save settings");?>" value="<?=gtext("Save");?>"/>
|
||||
<input name="upgrade" type="submit" class="formbtn" title="<?=gtext("Upgrade Extension and Bastille Packages");?>" value="<?=gtext("Upgrade");?>" />
|
||||
</div>
|
||||
<div id="remarks">
|
||||
@@ -215,7 +250,7 @@ $(document).ready(function(){
|
||||
<?php html_separator();?>
|
||||
</table>
|
||||
<div id="submit1">
|
||||
<input name="uninstall" type="submit" class="formbtn" title="<?=gtext("Uninstall Extension");?>" value="<?=gtext("Uninstall");?>" onclick="return confirm('<?=gtext("Bastille Extension and packages will be completely removed, ready to proceed?");?>')" />
|
||||
<input name="uninstall" type="submit" class="formbtn" title="<?=gtext("Uninstall Extension");?>" value="<?=gtext("Uninstall");?>" onclick="return confirm('<?=gtext("Bastille Extension and packages will be completely removed, Bastille containers and child directories will not be touched, really to proceed?");?>')" />
|
||||
</div>
|
||||
</td></tr>
|
||||
</table>
|
||||
214
gui/bastille_manager_tarballs.php
Normal file
214
gui/bastille_manager_tarballs.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_tarballs.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
$gt_selection_delete_confirm = gtext('Do you really want to destroy this base release?');
|
||||
$pgtitle = [gtext("Extensions"), gtext('Bastille'),gtext('Releases')];
|
||||
|
||||
$sphere_array = [];
|
||||
$sphere_record = [];
|
||||
|
||||
function get_rel_list() {
|
||||
global $rootfolder;
|
||||
$result = [];
|
||||
if (is_dir("{$rootfolder}/releases")):
|
||||
$entries = preg_grep('/^([^.])/', scandir("{$rootfolder}/releases"));
|
||||
foreach($entries as $entry):
|
||||
$a = preg_split('/\t/',$entry);
|
||||
$r = [];
|
||||
$name = $a[0];
|
||||
if(preg_match('/^[0-9]+\.[0-9]+\-RELEASE/', $name, $m)):
|
||||
$r['name'] = $m[0];
|
||||
else:
|
||||
$r['name'] = 'unknown';
|
||||
endif;
|
||||
$r['relname'] = $r['name'];
|
||||
|
||||
$result[] = $r;
|
||||
endforeach;
|
||||
endif;
|
||||
return $result;
|
||||
}
|
||||
$rel_list = get_rel_list();
|
||||
$sphere_array = $rel_list;
|
||||
|
||||
if($_POST):
|
||||
unset($input_errors);
|
||||
unset($savemsg);
|
||||
$pconfig = $_POST;
|
||||
if(isset($_POST['Cancel']) && $_POST['Cancel']):
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
endif;
|
||||
|
||||
if (isset($_POST['Download']) && $_POST['Download']):
|
||||
$get_release = $pconfig['release_item'];
|
||||
$check_release = ("{$rootfolder}/releases/{$get_release}");
|
||||
$cmd = ("/usr/local/bin/bastille bootstrap {$get_release}");
|
||||
if(file_exists($check_release)):
|
||||
// FreeBSD base release check.
|
||||
$savemsg .= sprintf(gtext('%s base appears to be already extracted.'),$get_release);
|
||||
else:
|
||||
// Download a FreeBSD base release.
|
||||
if ($_POST['Download']):
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
//$savemsg .= sprintf(gtext('%s base downloaded and extracted successfully.'),$get_release);
|
||||
header('Location: bastille_manager_tarballs.php');
|
||||
else:
|
||||
$errormsg .= sprintf(gtext('%s Failed to download and/or extract release base.'),$get_release);
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if (isset($_POST['Destroy']) && $_POST['Destroy']):
|
||||
if ($_POST['Destroy']):
|
||||
$get_release = $pconfig['release_item'];
|
||||
$check_release = ("{$rootfolder}/releases/{$get_release}");
|
||||
$cmd = ("/usr/local/bin/bastille destroy {$get_release}");
|
||||
if(!file_exists($check_release)):
|
||||
// FreeBSD base release check.
|
||||
$savemsg .= sprintf(gtext('%s base does not exist, nothing to do.'),$get_release);
|
||||
else:
|
||||
// Delete the FreeBSD base release/directory.
|
||||
if ($_POST['Destroy']):
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
//$savemsg .= sprintf(gtext('%s base deleted successfully.'),$get_release);
|
||||
header('Location: bastille_manager_tarballs.php');
|
||||
else:
|
||||
$errormsg .= sprintf(gtext('%s failed to delete.'),$get_release);
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
include 'fbegin.inc';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(window).on("load",function() {
|
||||
// Init action buttons
|
||||
$("#Destroy").click(function () {
|
||||
return confirm('<?=$gt_selection_delete_confirm;?>');
|
||||
});
|
||||
$("#iform").submit(function() { spinner(); });
|
||||
$(".spin").click(function() { spinner(); });
|
||||
});
|
||||
function enable_change(enable_change) {
|
||||
document.iform.name.disabled = !enable_change;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
$document = new co_DOMDocument();
|
||||
$document->
|
||||
add_area_tabnav()->
|
||||
push()->
|
||||
add_tabnav_upper()->
|
||||
ins_tabnav_record('bastille_manager_gui.php',gettext('Containers'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_info.php',gettext('Information'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_maintenance.php',gettext('Maintenance'),gettext('Reload page'),true)->
|
||||
pop()->add_tabnav_lower()->
|
||||
ins_tabnav_record('bastille_manager_config.php',gettext('Bastille Configuration'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_tarballs.php',gettext('Base Releases'),gettext('Reload page'),true);
|
||||
$document->render();
|
||||
?>
|
||||
<form action="bastille_manager_tarballs.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
<?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 class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('FreeBSD Base Releases'));
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($sphere_array as $sphere_record):
|
||||
html_text2('releases',gettext('Installed Base:'),htmlspecialchars($sphere_record['relname']));
|
||||
endforeach;
|
||||
$a_action = [
|
||||
//'12.1-RELEASE' => gettext('12.1-RELEASE'),
|
||||
'12.0-RELEASE' => gettext('12.0-RELEASE'),
|
||||
'11.3-RELEASE' => gettext('11.3-RELEASE'),
|
||||
'11.2-RELEASE' => gettext('11.2-RELEASE'),
|
||||
];
|
||||
html_combobox2('release_item',gettext('Select Base Release'),$pconfig['release_item'],$a_action,'',true,false,'action_change()');
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="submit">
|
||||
<input name="Download" type="submit" class="formbtn" value="<?=gtext("Download");?>" onclick="enable_change(true)" />
|
||||
|
||||
<input name="Destroy" id="Destroy" type="submit" class="formbtn" value="<?=gtext("Destroy");?>"/>
|
||||
|
||||
|
||||
<input name="Cancel" type="submit" class="formbtn" value="<?=gtext("Cancel");?>" />
|
||||
</div>
|
||||
<div id="remarks">
|
||||
<?php html_remark("note", gtext("Note"), sprintf(gtext("Slow Internet connections may render the Web GUI unresponsive until download completes.")));?>
|
||||
</div>
|
||||
<?php
|
||||
include 'formend.inc';
|
||||
?>
|
||||
</td></tr></tbody></table></form>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
?>
|
||||
376
gui/bastille_manager_util.php
Normal file
376
gui/bastille_manager_util.php
Normal file
@@ -0,0 +1,376 @@
|
||||
<?php
|
||||
/*
|
||||
bastille_manager_util.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Portions of XigmaNAS® (https://www.xigmanas.com).
|
||||
Copyright (c) 2018 XigmaNAS® <info@xigmanas.com>.
|
||||
XigmaNAS® is a registered trademark of Michael Zoon (zoon01@xigmanas.com).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the developer nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once 'auth.inc';
|
||||
require_once 'guiconfig.inc';
|
||||
require_once("bastille_manager-lib.inc");
|
||||
|
||||
if(isset($_GET['uuid'])):
|
||||
$uuid = $_GET['uuid'];
|
||||
endif;
|
||||
if(isset($_POST['uuid'])):
|
||||
$uuid = $_POST['uuid'];
|
||||
endif;
|
||||
|
||||
$pgtitle = [gtext("Extensions"), gtext('Bastille'),gtext('Utilities')];
|
||||
|
||||
if(isset($_GET['jailname'])):
|
||||
$container = $_GET['jailname'];
|
||||
endif;
|
||||
if(isset($_POST['jailname'])):
|
||||
$container = $_POST['jailname'];
|
||||
endif;
|
||||
|
||||
$cnid = FALSE;
|
||||
if(isset($container) && !empty($container)):
|
||||
$pconfig['uuid'] = uuid();
|
||||
$pconfig['jailname'] = $container;
|
||||
if(preg_match('/^([^\/\@]+)(\/([^\@]+))?\@(.*)$/', $pconfig['jailname'], $m)):
|
||||
$pconfig['name'] = $m[''];
|
||||
else:
|
||||
$pconfig['name'] = 'unknown';
|
||||
endif;
|
||||
$pconfig['newname'] = '';
|
||||
$pconfig['recursive'] = false;
|
||||
$pconfig['action'] = 'activate';
|
||||
else:
|
||||
// not supported
|
||||
$pconfig = [];
|
||||
endif;
|
||||
|
||||
if($_POST):
|
||||
global $configfile;
|
||||
global $backup_path;
|
||||
global $rootfolder;
|
||||
unset($input_errors);
|
||||
$pconfig = $_POST;
|
||||
if(isset($_POST['Cancel']) && $_POST['Cancel']):
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
endif;
|
||||
if(isset($_POST['action'])):
|
||||
$action = $_POST['action'];
|
||||
endif;
|
||||
if(empty($action)):
|
||||
$input_errors[] = sprintf(gtext("The attribute '%s' is required."), gtext("Action"));
|
||||
else:
|
||||
switch($action):
|
||||
case 'advanced':
|
||||
// Input validation not required
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
if ($_POST['advanced']):
|
||||
header('Location: bastille_manager_editor.php');
|
||||
exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to open editor, confirmation is required.");
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'backup':
|
||||
// Input validation not required
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
$date = (strftime('%Y-%m-%d-%H%M%S'));
|
||||
$cmd = ("cd {$rootfolder}/jails && /usr/bin/tar -cf {$item}-{$date}.tar --exclude=.bastille --exclude=.template {$item} && /bin/mv {$item}-{$date}.tar {$backup_path}");
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
$savemsg .= gtext("Container backup process completed successfully.");
|
||||
//header('Location: bastille_manager_gui.php');
|
||||
//exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to backup container.");
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'autoboot':
|
||||
// Input validation not required
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
$cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"YES\"");
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to set auto-boot.");
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'noauto':
|
||||
// Input validation not required
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
$cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"NO\"");
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to set no-auto.");
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'fstab':
|
||||
// Input validation not required
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
$sourcedir = $pconfig['source_path'];
|
||||
$targetdir = $pconfig['target_path'];
|
||||
|
||||
if ($_POST['readonly']):
|
||||
$dir_mode = "ro";
|
||||
else:
|
||||
$dir_mode = "rw";
|
||||
endif;
|
||||
|
||||
$cmd = ("/bin/echo \"{$sourcedir} {$targetdir} nullfs {$dir_mode} 0 0\" >> {$rootfolder}/jails/{$item}/fstab");
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
if ($_POST['createdir']):
|
||||
mkdir("$targetdir");
|
||||
endif;
|
||||
|
||||
$savemsg .= gtext("Container backup process completed successfully.");
|
||||
//header('Location: bastille_manager_gui.php');
|
||||
//exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to backup container.");
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
// Delete a contained
|
||||
if(empty($input_errors)):
|
||||
$container = [];
|
||||
$container['uuid'] = $_POST['uuid'];
|
||||
$container['jailname'] = $_POST['jailname'];
|
||||
$confirm_name = $pconfig['confirmname'];
|
||||
$item = $container['jailname'];
|
||||
|
||||
if(strcmp($confirm_name, $item) !== 0):
|
||||
$errormsg .= gtext("Failed to destroy container, name confirmation is required.");
|
||||
break;
|
||||
else:
|
||||
if ($_POST['nowstop']):
|
||||
$cmd = ("/usr/local/bin/bastille stop {$item} && /usr/local/bin/bastille destroy {$item}");
|
||||
else:
|
||||
$cmd = ("/usr/local/bin/bastille destroy {$item}");
|
||||
endif;
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if($retval == 0):
|
||||
exec("/usr/sbin/sysrc -f {$configfile} -qx {$item}_AUTO_START");
|
||||
header('Location: bastille_manager_gui.php');
|
||||
exit;
|
||||
else:
|
||||
$errormsg .= gtext("Failed to destroy container, make sure this container is stopped.");
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
default:
|
||||
$input_errors[] = sprintf(gtext("The attribute '%s' is invalid."), 'action');
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
endif;
|
||||
include 'fbegin.inc';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(window).on("load",function() {
|
||||
$("#iform").submit(function() { spinner(); });
|
||||
$(".spin").click(function() { spinner(); });
|
||||
});
|
||||
function enable_change(enable_change) {
|
||||
document.iform.name.disabled = !enable_change;
|
||||
}
|
||||
function action_change() {
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr', 'hide');
|
||||
showElementById('source_path_tr', 'hide');
|
||||
showElementById('target_path_tr', 'hide');
|
||||
showElementById('advanced_tr', 'hide');
|
||||
showElementById('readonly_tr', 'hide');
|
||||
showElementById('createdir_tr', 'hide');
|
||||
//showElementById('dateadd_tr','hide');
|
||||
var action = document.iform.action.value;
|
||||
switch (action) {
|
||||
case "backup":
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr','hide');
|
||||
break;
|
||||
case "autoboot":
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr','hide');
|
||||
break;
|
||||
case "noauto":
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr','hide');
|
||||
break;
|
||||
case "fstab":
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr','hide');
|
||||
showElementById('source_path_tr','show');
|
||||
showElementById('target_path_tr','show');
|
||||
showElementById('readonly_tr','show');
|
||||
showElementById('createdir_tr','show');
|
||||
break;
|
||||
case "delete":
|
||||
showElementById('confirmname_tr','show');
|
||||
showElementById('nowstop_tr','show');
|
||||
break;
|
||||
case "advanced":
|
||||
showElementById('confirmname_tr','hide');
|
||||
showElementById('nowstop_tr','hide');
|
||||
showElementById('advanced_tr','show');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
$document = new co_DOMDocument();
|
||||
$document->
|
||||
add_area_tabnav()->
|
||||
push()->
|
||||
add_tabnav_upper()->
|
||||
ins_tabnav_record('bastille_manager_gui.php',gettext('Containers'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_info.php',gettext('Information'),gettext('Reload page'),true)->
|
||||
ins_tabnav_record('bastille_manager_maintenance.php',gettext('Maintenance'),gettext('Reload page'),true);
|
||||
$document->render();
|
||||
?>
|
||||
<form action="bastille_manager_util.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
<?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(updatenotify_exists($sphere_notifier)):
|
||||
print_config_change_box();
|
||||
endif;
|
||||
?>
|
||||
<table class="area_data_settings">
|
||||
<colgroup>
|
||||
<col class="area_data_settings_col_tag">
|
||||
<col class="area_data_settings_col_data">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
html_titleline2(gettext('Utilities'));
|
||||
?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$pconfig['source_path'] = "/mnt";
|
||||
$pconfig['target_path'] = "{$rootfolder}/jails/{$pconfig['jailname']}/root/mnt/";
|
||||
html_text2('jailname',gettext('Container name:'),htmlspecialchars($pconfig['jailname']));
|
||||
$a_action = [
|
||||
'backup' => gettext('Backup'),
|
||||
'autoboot' => gettext('Autoboot'),
|
||||
'noauto' => gettext('Noauto'),
|
||||
'fstab' => gettext('Fstab'),
|
||||
'delete' => gettext('Destroy'),
|
||||
'advanced' => gettext('Advanced'),
|
||||
];
|
||||
html_combobox2('action',gettext('Action'),$pconfig['action'],$a_action,'',true,false,'action_change()');
|
||||
html_inputbox2('confirmname',gettext('Enter name for confirmation'),$pconfig['confirmname'],'',true,30);
|
||||
html_checkbox2('nowstop',gettext('Stop container'),!empty($pconfig['nowstop']) ? true : false,gettext('Stop the container if running before deletetion.'),'',false);
|
||||
html_filechooser("source_path", gtext("Source Data Directory"), $pconfig['source_path'], gtext("Source data directory to be shared, full path here."), $source_path, true, 60);
|
||||
html_filechooser("target_path", gtext("Target Data Directory"), $pconfig['target_path'], gtext("Target data directory to be mapped, path within the jail only."), $target_path, true, 60);
|
||||
html_checkbox2('advanced',gettext('Advanced jail configuration Files'),!empty($pconfig['advanced']) ? true : false,gettext('I understand the risks, take me to the advanced jail config files.'),'',true);
|
||||
html_checkbox2('readonly',gettext('Read-Only Mode'),!empty($pconfig['readonly']) ? true : false,gettext('Set target directory in Read-Only mode.'),'',false);
|
||||
html_checkbox2('createdir',gettext('Create Target Directory'),!empty($pconfig['createdir']) ? true : true,gettext('Create target directory if missing (recommended).'),'',true);
|
||||
//html_checkbox2('dateadd',gettext('Date'),!empty($pconfig['dateadd']) ? true : false,gettext('Append the date in the following format: ITEM-XXXX-XX-XX-XXXXXX.'),'',false);
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="submit">
|
||||
<input name="Submit" type="submit" class="formbtn" value="<?=gtext("Execute");?>" onclick="enable_change(true)" />
|
||||
<input name="Cancel" type="submit" class="formbtn" value="<?=gtext("Cancel");?>" />
|
||||
<input name="uuid" type="hidden" value="<?=$pconfig['uuid'];?>" />
|
||||
<input name="jailname" type="hidden" value="<?=$pconfig['jailname'];?>" />
|
||||
<input name="name" type="hidden" value="<?=$pconfig['name'];?>" />
|
||||
</div>
|
||||
<div id="remarks">
|
||||
<?php html_remark("note", gtext("Note"), sprintf(gtext("Some tasks such as backups may render the WebGUI unresponsive until task completes.")));?>
|
||||
</div>
|
||||
<?php
|
||||
include 'formend.inc';
|
||||
?>
|
||||
</td></tr></tbody></table></form>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
enable_change(true);
|
||||
action_change();
|
||||
//-->
|
||||
</script>
|
||||
<?php
|
||||
include 'fend.inc';
|
||||
?>
|
||||
@@ -1 +0,0 @@
|
||||
<a href="bastille-gui.php">Bastille</a>
|
||||
1
gui/ext/bastille/menu.inc
Normal file
1
gui/ext/bastille/menu.inc
Normal file
@@ -0,0 +1 @@
|
||||
<a href="bastille_manager_gui.php">Bastille</a>
|
||||
BIN
gui/images/bsd_icon.png
Normal file
BIN
gui/images/bsd_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 872 B |
BIN
gui/images/icon.png
Normal file
BIN
gui/images/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.4 KiB |
BIN
gui/images/icon_small.png
Normal file
BIN
gui/images/icon_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 482 B |
@@ -1,11 +0,0 @@
|
||||
======================
|
||||
= Extension Bastille =
|
||||
======================
|
||||
Version Description
|
||||
|
||||
0.0.6......Switch to alternate repository supporting 11.3-RELEASE base.
|
||||
0.0.5......Start all jails once.
|
||||
0.0.4......Start jails if directory not empty.
|
||||
0.0.3......Minor code adjustment.
|
||||
0.0.2......Added addon preview page.
|
||||
0.0.1......First Release.
|
||||
Reference in New Issue
Block a user