Files
unraid-lxc-plugin/source/usr/local/emhttp/plugins/lxc/LXCSettingsMain.page

158 lines
9.5 KiB
Plaintext

Menu="LXCSettings:1"
Title="General"
Tag="wrench"
---
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
<?
require_once '/usr/local/emhttp/plugins/lxc/include/Settings.php';
$settings = new Settings();
$started = $var['fsState']=='Started';
$bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c';
$lxc_version = shell_exec('lxc-info --version');
?>
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.filetree.css')?>">
<style>
body{-webkit-overflow-scrolling:touch}
.errortext{color:#EF3D47;display:none}
.fileTree{background:<?=$bgcolor?>;width:300px;max-height:150px;overflow-y:scroll;overflow-x:hidden;position:absolute;z-index:100;display:none}
.basic{display:block}
.advanced{display:none}
</style>
<link rel="stylesheet" href="/plugins/lxc/css/lxc.css">
<script src="/plugins/lxc/js/lxc.js"></script>
<form markdown="1" id="changecfg" method="post">
_(Enable LXC)_:
: <select id="SERVICE" name="SERVICE">
<?= mk_option($settings->status, 'disabled', '_(No)_')?>
<?= mk_option($settings->status, 'enabled', '_(Yes)_')?>
</select>
<blockquote class="inline_help">
<p>Enable or Disable the LXC service</p>
</blockquote>
Default LXC storage path:
: <input type="text" id="defaultdir" name="DEFAULTDIR" autocomplete="off" spellcheck="false" data-pickfolders="true" data-pickfilter="HIDE_FILES_FILTER" data-pickroot="<?=is_dir('/mnt/')?'/mnt/':'/mnt'?>" value="<?=htmlspecialchars($settings->default_path)?>/" placeholder="Click to Select" pattern="^[^\\]*/$" class="forbidSpace" required>
<?if (!$started):?><span><i class="fa fa-warning icon warning"></i> Modify with caution: unable to validate path until Array is Started</span>
<?elseif (!is_dir($settings->default_path)):?><span><i class="fa fa-warning icon warning"></i> Path does not exist, </span><span style="color: #ff0000;">this path will be created after applying the settings!</span><?endif;?>
<br/>
<?php
if (strpos($settings->default_path, '/mnt/user/') !== false) {
echo "<span style=\"color: #ff0000;\">ATTENTION: It is strongly recommended to not use a FUSE path like /mnt/user/lxc/ instead use the real path to the share like /mnt/cache/lxc/ or /mnt/diskX/lxc/<br/>Don't share this directory via SMB or NFS or change the permissions from this directory!</span>";
}
?>
<blockquote class="inline_help">
<p>Select your default storage path for LXC<br/></p>
<p>It is strongly recommended to not use a FUSE path like: /mnt/user/lxc/ instead use the real path to the share like: <b>/mnt/cache/lxc/</b> or <b>/mnt/diskX/lxc/</b><br/><b>Make sure that the mover does not move the files off of this path or to another disk!</b></p>
<p><b style="color: #ff0000;">ATTENTION:</b><b> Don't share this directory via SMB or NFS or change the permissions from this directory! You will most likely break all your containers.</b></p>
<p>Please note that the path requires a trailing / at the end.</p>
</blockquote>
Default LXC backing storage type:
: <select id="bdevtype" name="BDEVTYPE">
<?= mk_option($settings->default_bdevtype, 'dir', 'Directory (Default)')?>
<?php
$path_fstype = exec("df -T $settings->default_path | awk 'NR==2 {print $2}'");
if(!empty($path_fstype)) {
if($path_fstype == "zfs") {
echo mk_option($settings->default_bdevtype, 'zfs', 'ZFS');
} elseif($path_fstype == "btrfs") {
echo mk_option($settings->default_bdevtype, 'btrfs', 'BTRFS');
}
} ?>
</select>
<blockquote class="inline_help">
<p>Select your default backing storage type<br/>(All available options will be populated after a storage path is choosen)</p>
<p><b>Directory (Default):</b> This is the default storage type and also the simplest, all containers, configurations and snapshots are stored in your Default LXC storage path: <?php echo (is_dir($settings->default_path)) ? $settings->default_path : 'eg: /mnt/cache/lxc/'; ?><br/><i>For small instances fine but not suitable for lage production environments (no Copy-on-Write Images, slow Snapshots)</i></p>
<p><b>BTRFS:</b> This option will show up if your Default LXC storage path: <?php echo (is_dir($settings->default_path)) ? $settings->default_path : 'eg: /mnt/cache/lxc/'; ?> is on a BTRFS volume.<br/><i>Supports Copy-on-Write Images, fast Snapshots, native send/receive.</i></p>
<p><b>ZFS:</b> This option will show up if your Default LXC storage path: <?php echo (is_dir($settings->default_path)) ? $settings->default_path : 'eg: /mnt/cache/lxc/'; ?> is on a ZFS volume.<br/>It will create it's own dataset (<?php echo (explode('/', $settings->default_path)[2] ?? 'poolname'); ?>/zfs_lxccontainers/...) on the ZFS pool where your Default LXC storage path is located for the storage from the containers and snapshots.<br/><b>Make sure that the mover does not move the files off of this dataset or to another disk!</b><br/>The contents from the dataset will be linked to the Default LXC storage path.<br/><i>Supports Copy-on-Write Images, fast Snapshots, native send/receive.</i></p>
<p><b>NOTE:</b> Existing container will not be changed!<br/>You can use <code>lxc-dirtobtrfs</code> from the terminal to convert a container from Directory to BTRFS (this change is irreversible!).<br/>You can use <code>lxc-dirtozfs</code> from the terminal to convert a container from Directory to ZFS (this change is irreversible!).</p>
<p><b style="color: #ff0000;">ATTENTION:</b> When using ZFS please only use the built in Snapshot function from the LXC plugin or <code>lxc-autosnapshot</code> from the command line otherwise you will most likely destroy your container!</p>
</blockquote>
Default network interface:
: <select name="INTERFACENAME">
<?php
foreach($settings->available_interfaces as $item){
if ( $item == $settings->default_interface ) {
echo "<option selected=\"selected\" value=\"$item\"> $item</option>";
} else {
echo "<option value=\"$item\"> $item</option>";
}
}
?>
<input type="checkbox" name="CHANGENETCONT" <?php echo (!$started) ? "disabled" : ""; ?>>
<label for="CHANGENETCONT"><?php echo (!$started) ? 'Array must be started to change networks from containers' : 'Change network from existing containers'; ?></label>
<blockquote class="inline_help">
<p>Select your default network interface</p>
<p>If a brX interface is selected the default net type will be changed to veth and the link interface to the selected bridge interface (should be selected if you are using the bridge and IPVLAN).<br/>
If a ethX or vhostX interface is selected the net type will be changed to maclvan, the macvlan mode will be set to bridge and the link interface will be changed to bridge (should be selected if you are not using the bridge in your network settings).<br/>
<b>Note:</b> If you are using ethX or vhostX you have to enable <b>Host access to custom networks</b> in your <a href="/Settings/DockerSettings" target="_blank">Docker Settings</a></p>
<p><b style="color: #ff0000;">ATTENTION:</b> If you are changing the interfaces from brX to ethX/vhostX or vice versa the network configurations from the existing containers will not be changed! To change the network configurations from the existing containers tick the checkbox "Change network from existing containers".</p>
</blockquote>
</select>
<input type="hidden" name="TIMEOUT" value="<?php echo $settings->default_timeout;?>">
<input type="hidden" name="AUTOSTART_DELAY" value="<?php echo $settings->default_startdelay;?>">
<input type="hidden" name="DYNAMIC_STATS" value="<?php echo $settings->dynamic_stats;?>">
<input type="hidden" name="LXC_CONTAINER_URL" value="<?php echo $settings->default_cont_url;?>">
<input type="hidden" name="BACKUP_ENABLED" value="<?php echo $settings->backup_enabled;?>">
<input type="hidden" name="BACKUPDIR" value="<?php echo $settings->backup_path;?>">
<input type="hidden" name="BACKUPS_TO_KEEP" value="<?php echo $settings->backup_keep;?>">
<input type="hidden" name="CPU_THREADS" value="<?php echo $settings->backup_threads;?>">
<input type="hidden" name="COMPRESSION_RATIO" value="<?php echo $settings->backup_compression;?>">
<input type="hidden" name="USE_SNAPSHOT" value="<?php echo $settings->backup_use_snapshot;?>">
<p>&nbsp;</p>
Update configuration:
: <input type="submit" name="changeCFG" value="_(Apply)_">
<blockquote class="inline_help">
<p style="color: #ff0000;"><b>This will restart the LXC service and all your LXC containers!</b></p>
</blockquote>
</form>
<p>&nbsp;</p>
<table>
<tr>
<th>
<div id="title"><span class="left"><i class="title fa fa-list"></i>lxc.conf</span></div>
</th>
<th>
<div id="title"><span class="left"><i class="title fa fa-list"></i>default.conf</span></div>
</th>
</tr>
<tr>
<td><?="<pre id='btrfs-scrub'>".shell_exec("cat /boot/config/plugins/lxc/lxc.conf")."</pre>"?></td>
<td><?="<pre id='btrfs-scrub'>".shell_exec("cat /boot/config/plugins/lxc/default.conf")."</pre>"?></td>
</tr>
</table>
<?php
echo "<div style=\"text-align: right;\"><span>Installed LXC Version: " . $lxc_version . "</span></div>";
?>
<?php
if(isset($_POST['changeCFG'])) {
$settings->changeConfig($started, $_POST["DEFAULTDIR"], $_POST["BDEVTYPE"], $_POST["SERVICE"], $_POST["DYNAMIC_STATS"], $_POST["TIMEOUT"], $_POST["AUTOSTART_DELAY"], $_POST["INTERFACENAME"], $_POST["CHANGENETCONT"], $_POST["LXC_CONTAINER_URL"], $_POST["BACKUP_ENABLED"], $_POST["BACKUPDIR"], $_POST["BACKUPS_TO_KEEP"], $_POST["CPU_THREADS"], $_POST["COMPRESSION_RATIO"], $_POST["USE_SNAPSHOT"]);
echo '<script>parent.window.location.reload();</script>';
}
?>
<script src="<?autov('/webGui/javascript/jquery.filetree.js')?>" charset="utf-8"></script>
<script>
$('#defaultdir').fileTreeAttach();
</script>