mirror of
https://github.com/JRGTH/xigmanas-bastille-extension.git
synced 2025-12-11 01:10:57 +01:00
Add initial support for IPv6 and VNET
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
======================
|
||||
Version Description
|
||||
|
||||
1.0.37......Add initial support for IPv6 and VNET.
|
||||
1.0.36......Remove obsolete code, update config.
|
||||
1.0.35......Use bastille built-in convert function.
|
||||
1.0.34......Use bastille built-in export/import functions.
|
||||
|
||||
@@ -762,6 +762,9 @@ zfs_activate()
|
||||
jail_import()
|
||||
{
|
||||
# Foreign jail import support using rsync.
|
||||
# This will attempt to import a foreign(Thebrig) jail into Bastille,
|
||||
# however only basic IOcage jails are officially supported by Bastille import.
|
||||
# Since importing Thebrig jails is almost unsupported/untested, this function may be deprecated at any time.
|
||||
|
||||
USAGE="Usage: ${SCRIPTNAME} -I [path]"
|
||||
if [ -z "${TARGET}" ]; then
|
||||
@@ -821,10 +824,10 @@ jail_import()
|
||||
if [ -f "${TARGET}/root/.profile" ]; then
|
||||
if [ -d "${bastille_jailsdir}" ]; then
|
||||
if [ ! -d "${bastille_jailsdir}/${NAME_TRIM}" ]; then
|
||||
# Create required ZFS datasets.
|
||||
# Create required ZFS datasets, mountpoint should be inherited.
|
||||
echo "Creating required ZFS datasets..."
|
||||
zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME_TRIM}
|
||||
zfs create ${bastille_zfs_options} -o mountpoint=${bastille_jailsdir}/${NAME_TRIM}/root ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME_TRIM}/root
|
||||
zfs create ${bastille_zfs_options} ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NAME_TRIM}/root
|
||||
echo "Importing foreign jail '${NAME_TRIM}' to ${PRDNAME}..."
|
||||
echo "Synchronizing '${NAME_TRIM}' data to ${bastille_jailsdir}/${NAME_TRIM}..."
|
||||
rsync -a ${EXCLUDE} ${TARGET}/ ${bastille_jailsdir}/${NAME_TRIM}/root/
|
||||
|
||||
@@ -56,7 +56,7 @@ $config_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BASTILLE_CONFIG=' |
|
||||
$default_distfiles = exec("/bin/cat {$config_path} | /usr/bin/grep 'bastille_bootstrap_archives=' | /usr/bin/cut -d'\"' -f2");
|
||||
$jail_dir = "{$rootfolder}/jails";
|
||||
$image_dir = "ext/bastille/images";
|
||||
$thick_jail = exec("/usr/local/bin/bastille create | grep -wo '\[option\]'");
|
||||
$options_support = exec("/usr/local/bin/bastille create | grep -wo '\[option\]'");
|
||||
$reldir = "{$rootfolder}/releases";
|
||||
$zfs_support = exec("/bin/cat {$configfile} | /usr/bin/grep 'ZFS_SUPPORT=' | /usr/bin/cut -d'\"' -f2");
|
||||
|
||||
@@ -174,6 +174,9 @@ function get_jail_infos() {
|
||||
// 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'] = exec("/usr/bin/grep -w 'ip6.addr' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'");
|
||||
endif;
|
||||
if (!$r['ip']):
|
||||
$r['ip'] = "-";
|
||||
endif;
|
||||
|
||||
@@ -81,10 +81,16 @@ if($_POST):
|
||||
$thick_jail = "";
|
||||
endif;
|
||||
|
||||
if ($_POST['nowstart']):
|
||||
$cmd = ("/usr/local/bin/bastille create {$thick_jail} {$jname} {$release} {$ipaddr} {$interface} && /usr/local/bin/bastille start {$jname}");
|
||||
if($_POST['vnetjail']):
|
||||
$vnet_jail = "-V";
|
||||
else:
|
||||
$cmd = ("/usr/local/bin/bastille create {$thick_jail} {$jname} {$release} {$ipaddr} {$interface}");
|
||||
$vnet_jail = "";
|
||||
endif;
|
||||
|
||||
if ($_POST['nowstart']):
|
||||
$cmd = ("/usr/local/bin/bastille create {$thick_jail} {$vnet_jail} {$jname} {$release} {$ipaddr} {$interface} && /usr/local/bin/bastille start {$jname}");
|
||||
else:
|
||||
$cmd = ("/usr/local/bin/bastille create {$thick_jail} {$vnet_jail} {$jname} {$release} {$ipaddr} {$interface}");
|
||||
endif;
|
||||
|
||||
if ($_POST['Create']):
|
||||
@@ -156,13 +162,14 @@ $document->render();
|
||||
<tbody>
|
||||
<?php
|
||||
html_inputbox2('jailname',gettext('Friendly name'),$pconfig['jailname'],'',true,20);
|
||||
html_inputbox2('ipaddress',gettext('IPv4 Address'),$pconfig['ipaddress'],'',true,20);
|
||||
html_inputbox2('ipaddress',gettext('IP 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()');
|
||||
if($thick_jail):
|
||||
if($options_support):
|
||||
html_checkbox2('thickjail',gettext('Create a thick container'),!empty($pconfig['thickjail']) ? true : false,gettext('These containers consume more space, but are self contained.'),'',false);
|
||||
html_checkbox2('vnetjail',gettext('Enable VNET(VIMAGE)'),!empty($pconfig['vnetjail']) ? true : false,gettext('VNET-enabled containers are attached to a virtual bridge interface for connectivity(Advanced).'),'',false);
|
||||
endif;
|
||||
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);
|
||||
|
||||
@@ -239,10 +239,10 @@ $document->render();
|
||||
<colgroup>
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
<col style="width:12%">
|
||||
<col style="width:10%">
|
||||
<col style="width:10%">
|
||||
<col style="width:10%">
|
||||
<col style="width:5%">
|
||||
<col style="width:25%">
|
||||
<col style="width:5%">
|
||||
<col style="width:5%">
|
||||
@@ -257,7 +257,7 @@ $document->render();
|
||||
<tr>
|
||||
<th class="lhelc"><?=gtext('Select');?></th>
|
||||
<th class="lhell"><?=gtext('JID');?></th>
|
||||
<th class="lhell"><?=gtext('IPv4 Address');?></th>
|
||||
<th class="lhell"><?=gtext('IP Address');?></th>
|
||||
<th class="lhell"><?=gtext('Hostname');?></th>
|
||||
<th class="lhell"><?=gtext('Release');?></th>
|
||||
<th class="lhell"><?=gtext('Interface');?></th>
|
||||
|
||||
@@ -164,7 +164,7 @@ if ($_POST) {
|
||||
else:
|
||||
if (is_file($backup_file)) {
|
||||
$cmd = ("/usr/local/bin/bastille import '{$filename_trim}'");
|
||||
unset($retval);mwexec($cmd,$retval);
|
||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||
if ($retval == 0) {
|
||||
$savemsg .= gtext("Container restored successfully.");
|
||||
exec("echo '{$date}: {$application}: Container restored successfully from {$filename_trim}' >> {$logfile}");
|
||||
|
||||
@@ -296,7 +296,7 @@ if($_POST):
|
||||
break;
|
||||
else:
|
||||
if ($_POST['nowstop']):
|
||||
$cmd = ("/usr/local/bin/bastille stop {$item} && /usr/local/bin/bastille destroy {$item}");
|
||||
$cmd = ("/usr/local/bin/bastille destroy -f {$item}");
|
||||
else:
|
||||
$cmd = ("/usr/local/bin/bastille destroy {$item}");
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user