Compare commits
112 Commits
7.0.0-beta
...
tailscale-
Author | SHA1 | Date | |
---|---|---|---|
a7ac0986a1 | |||
57edfd6d7b | |||
3a5d5f07ef | |||
13413b5d1f | |||
47a04e10c0 | |||
44e09d534c | |||
1b65b07110 | |||
da01e24ff8 | |||
a080ec364d | |||
|
95c6913c62 | ||
|
b783d4b207 | ||
|
a866de833a | ||
|
ee31e35849 | ||
|
50e7389c8a | ||
|
d536ef285b | ||
|
2dc82b61de | ||
|
57ec7909e5 | ||
|
01c6f64b52 | ||
|
80d567dfde | ||
|
99d60fa08a | ||
|
8bbf176b8b | ||
|
ca51a3799b | ||
|
e4bb758b05 | ||
|
3c007fa1d0 | ||
|
c062e4dd9c | ||
|
06b1c9a20f | ||
|
bf6d5982be | ||
|
d9bd5b56c8 | ||
|
bc7c66fec9 | ||
|
dc50e7d2c2 | ||
|
0061c66dfe | ||
|
91caf869f5 | ||
|
97c3a4621b | ||
|
1ffb22bddf | ||
|
1d9e14f07c | ||
6f7b97e37a | |||
|
ed7219d9c7 | ||
|
082d7d842b | ||
|
9a502776a1 | ||
|
03346f4709 | ||
|
1cc84832ee | ||
|
959df7e46c | ||
|
3fb6c2147b | ||
|
3db6fa9a1d | ||
|
0c5987fab0 | ||
|
fcbc8f700e | ||
|
6fd88575b2 | ||
|
bff0238f88 | ||
|
ee7f1f4a5b | ||
|
c3dd62f1d5 | ||
|
7c0fb18e3c | ||
|
fe2e2ff897 | ||
|
74530129ae | ||
|
968e3b1d72 | ||
|
6bdcb38c47 | ||
|
8c7cdca4aa | ||
|
08024a0464 | ||
|
828cd7b747 | ||
|
0ce3960de6 | ||
|
8b91d22796 | ||
b716920800 | |||
6d749a8b1a | |||
69b95ae27d | |||
|
20e29ab5af | ||
a75bc3d4d7 | |||
|
e8e5ccdf18 | ||
020ed9a07f | |||
|
8f656e87b1 | ||
|
54b1e81b38 | ||
|
4c6be23467 | ||
|
4a4983f7c5 | ||
|
dcfaa1afa0 | ||
|
e52813b626 | ||
|
760aac71df | ||
|
20ef176665 | ||
|
66d7193dab | ||
|
9c9c79b1b3 | ||
|
8aac4ee119 | ||
|
8120959c2f | ||
|
72abe50721 | ||
|
18e37ed045 | ||
|
6845c007a7 | ||
|
b844f941d0 | ||
|
5883e767aa | ||
|
efc4fa2673 | ||
|
0810fc5bd8 | ||
|
897365a5de | ||
|
8d628aad4f | ||
e3c4ff280d | |||
19de7c1979 | |||
5ec695921a | |||
171a77feec | |||
3e29f0b8b8 | |||
b62c8f5a12 | |||
e9faee0d27 | |||
|
16823d07b1 | ||
|
73705b71fa | ||
|
6b31532688 | ||
|
039c798b43 | ||
1e43abc785 | |||
|
9b1081d2e1 | ||
|
c27e018fdb | ||
|
ef5067584b | ||
|
4ea425411a | ||
|
24bdc5169d | ||
|
753d87c690 | ||
07d02f579f | |||
|
ceb97ab392 | ||
|
6a15afa2a8 | ||
|
175d24afd2 | ||
|
156599031a | ||
|
33a73b2fb5 |
@@ -256,7 +256,7 @@ Unraid OS uses these default options when creating a multiple-device pool:
|
||||
|
||||
`-dconvert=raid1 -mconvert=raid1`
|
||||
|
||||
For more complete documentation, please refer to the btrfs-balance [Manpage](https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-balance)
|
||||
For more complete documentation, please refer to the btrfs-balance [Manpage](https://man7.org/linux/man-pages/man8/btrfs-balance.8.html)
|
||||
|
||||
*Note: raid5 and raid6 are generally still considered **experimental** by the Linux community*
|
||||
:end
|
||||
@@ -1283,6 +1283,14 @@ The Local Access URLs shown above are based on your current settings.
|
||||
To adjust URLs or redirects, see the help text for "Use SSL/TLS".
|
||||
:end
|
||||
|
||||
:mgmt_wg_access_urls_help:
|
||||
These URLs will only work when connected via the appropriate WireGuard tunnel as configured on ***Settings > VPN Manager***
|
||||
:end
|
||||
|
||||
:mgmt_tailscale_access_urls_help:
|
||||
These URLs will only work when connected to the appropriate Tailscale Tailnet.
|
||||
:end
|
||||
|
||||
:mgmt_certificate_expiration_help:
|
||||
**Provision** may be used to install a *free* myunraid.net SSL Certificate from
|
||||
[Let's Encrypt](https://letsencrypt.org/).
|
||||
@@ -2295,6 +2303,136 @@ Generally speaking, it is recommended to leave this setting to its default value
|
||||
IMPORTANT NOTE: If adjusting port mappings, do not modify the settings for the Container port as only the Host port can be adjusted.
|
||||
:end
|
||||
|
||||
:docker_container_network_help:
|
||||
This allows your container to utilize the network configuration of another container. Select the appropriate container from the list.<br/>This setup can be particularly beneficial if you wish to route your container's traffic through a VPN.
|
||||
:end
|
||||
|
||||
:docker_tailscale_help:
|
||||
Enable Tailscale to add this container as a machine on your Tailnet.
|
||||
:end
|
||||
|
||||
:docker_tailscale_hostname_help:
|
||||
Provide the hostname for this container. It does not need to match the container name, but it must be unique on your Tailnet. Note that an HTTPS certificate will be generated for this hostname, which means it will be placed in a public ledger, so use a name that you don't mind being public.
|
||||
For more information see <a href="https://tailscale.com/kb/1153/enabling-https" target="_blank">enabling https</a>.
|
||||
:end
|
||||
|
||||
:docker_tailscale_be_exitnode_help:
|
||||
Enable this if other machines on your Tailnet should route their Internet traffic through this container, this is most useful for containers that connect to commercial VPN services.
|
||||
Be sure to authorize this Exit Node in your <a href="https://login.tailscale.com/admin/machines" target="_blank">Tailscale Machines Admin Panel</a>.
|
||||
For more details, see the Tailscale documentation on <a href="https://tailscale.com/kb/1103/exit-nodes" target="_blank">Exit Nodes</a>.
|
||||
:end
|
||||
|
||||
:docker_tailscale_exitnode_ip_help:
|
||||
Optionally route this container's outgoing Internet traffic through an Exit Node on your Tailnet. Choose the Exit Node or input its Tailscale IP address.
|
||||
For more details, see <a href="https://tailscale.com/kb/1103/exit-nodes" target="_blank">Exit Nodes</a>.
|
||||
:end
|
||||
|
||||
:docker_tailscale_lanaccess_help:
|
||||
Only applies when this container is using an Exit Node. Enable this to allow the container to access the local network.
|
||||
|
||||
<b>WARNING:</b> Even with this feature enabled, systems on your LAN may not be able to access the container unless they have Tailscale installed.
|
||||
:end
|
||||
|
||||
:docker_tailscale_userspace_networking_help:
|
||||
When enabled, this container will operate in a restricted environment. Tailscale DNS will not work, and the container will not be able to initiate connections to other Tailscale machines. However, other machines on your Tailnet will still be able to communicate with this container.
|
||||
|
||||
When disabled, this container will have full access to your Tailnet. Tailscale DNS will work, and the container can fully communicate with other machines on the Tailnet.
|
||||
However, systems on your LAN may not be able to access the container unless they have Tailscale installed.
|
||||
:end
|
||||
|
||||
:docker_tailscale_ssh_help:
|
||||
Tailscale SSH is similar to the Docker "Console" option in the Unraid webgui, except you connect with an SSH client and authenticate via Tailscale.
|
||||
For more details, see the <a href="https://tailscale.com/kb/1193/tailscale-ssh" target="_blank">Tailscale SSH</a> documentation..
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_mode_help:
|
||||
Enabling <b>Serve</b> will automatically reverse proxy the primary web service from this container and make it available on your Tailnet using https with a valid certificate!
|
||||
|
||||
Note that when accessing the <b>Tailscale WebUI</b> url, no additional authentication layer is added beyond restricting it to your Tailnet - the container is still responsible for managing usernames/passwords that are allowed to access it. Depending on your configuration, direct access to the container may still be possible as well.
|
||||
|
||||
For more details, see the <a href="https://tailscale.com/kb/1312/serve" target="_blank">Tailscale Serve</a> documentation.
|
||||
|
||||
If the documentation recommends additional settings for a more complex use case, enable "Tailscale Show Advanced Settings". Support for these advanced settings is not available beyond confirming the commands are passed to Tailscale correctly.
|
||||
|
||||
<b>Funnel</b> is similar to <b>Serve</b>, except that the web service is made available on the open Internet. Use with care as the service will likely be attacked. As with <b>Serve</b>, the container itself is responsible for handling any authentication.
|
||||
|
||||
We recommend reading the <a href="https://tailscale.com/kb/1223/funnel" target="_blank">Tailscale Funnel</a> documentation. before enabling this feature.
|
||||
|
||||
<b>Note:</b> Enabling <b>Serve</b> or <b>Funnel</b> publishes the Tailscale hostname to a public ledger.
|
||||
For more details, see the Tailscale Documentation: <a href="https://tailscale.com/kb/1153/enabling-https" target="_blank">Enabling HTTPS</a>.
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_port_help:
|
||||
This field should specify the port for the primary web service this container offers. Note: it should specify the port in the container, not a port that was remapped on the host.
|
||||
|
||||
The system attempted to determine the correct port automatically. If it used the wrong value then there is likely an issue with the "Web UI" field for this container, visible by switching from "Basic View" to "Advanced View" in the upper right corner of this page.
|
||||
|
||||
In most cases this port is all you will need to specify in order to Serve the website in this container, although additional options are available below for more complex containers.
|
||||
|
||||
This value is passed to the `<serve_port>` portion of this command which starts serve or funnel:<br>
|
||||
`tailscale [serve|funnel] --bg --<protocol><protocol_port><path> http://localhost:`**`<serve_port>`**`<local_path>`<br>
|
||||
For more details see the <a href="https://tailscale.com/kb/1242/tailscale-serve" target="_blank">Tailscale Serve Command Line</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_show_advanced_help:
|
||||
Here there be dragons!
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_local_path_help:
|
||||
When not specified, this value defaults to an empty string. It is passed to the `<local_path>` portion of this command which starts serve or funnel:<br>
|
||||
`tailscale [serve|funnel] --bg --<protocol><protocol_port><path> http://localhost:<serve_port>`**`<local_path>`**<br>
|
||||
For more details see the <a href="https://tailscale.com/kb/1242/tailscale-serve" target="_blank">Tailscale Serve Command Line</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_protocol_help:
|
||||
When not specified, this value defaults to "https". It is passed to the `<protocol>` portion of this command which starts serve or funnel:<br>
|
||||
`tailscale [serve|funnel] --bg --`**`<protocol>`**`=<protocol_port><path> http://localhost:<serve_port><local_path>`<br>
|
||||
For more details see the <a href="https://tailscale.com/kb/1242/tailscale-serve" target="_blank">Tailscale Serve Command Line</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_protocol_port_help:
|
||||
When not specified, this value defaults to "=443". It is passed to the `<protocol_port>` portion of this command which starts serve or funnel:<br>
|
||||
`tailscale [serve|funnel] --bg --<protocol>`**`<protocol_port>`**`<path> http://localhost:<serve_port><local_path>`<br>
|
||||
For more details see the <a href="https://tailscale.com/kb/1242/tailscale-serve" target="_blank">Tailscale Serve Command Line</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_path_help:
|
||||
When not specified, this value defaults to an empty string. It is passed to the `<path>` portion of this command which starts serve or funnel:<br>
|
||||
`tailscale [serve|funnel] --bg --<protocol><protocol_port>`**`<path>`** `http://localhost:<serve_port><local_path>`<br>
|
||||
For more details see the <a href="https://tailscale.com/kb/1242/tailscale-serve" target="_blank">Tailscale Serve Command Line</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_serve_webui_help:
|
||||
If <b>Serve</b> is enabled this will be an https url with a proper domain name that is accessible over your Tailnet, no port needed!
|
||||
|
||||
If <b>Funnel</b> is enabled the same url will be available on the Internet.
|
||||
|
||||
If they are disabled then the url will be generated from the container's main "Web UI" field, but modified to use the Tailscale IP. If the wrong port is specified here then switch from "Basic View" to "Advanced View" and review the "Web UI" field for this container.
|
||||
:end
|
||||
|
||||
:docker_tailscale_advertise_routes_help:
|
||||
If desired, specify any routes that should be passed to the **`--advertise-routes=`** parameter when running **`tailscale up`**.
|
||||
For more details see the <a href="https://tailscale.com/kb/1019/subnets#connect-to-tailscale-as-a-subnet-router" target="_blank">Subnet routers</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_daemon_extra_params_help:
|
||||
Specify any extra parameters to pass when starting **`tailscaled`**.
|
||||
For more details see the <a href="https://tailscale.com/kb/1278/tailscaled" target="_blank">tailscaled</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_extra_param_help:
|
||||
Specify any extra parameters to pass when running **`tailscale up`**.
|
||||
For more details see the <a href="https://tailscale.com/kb/1080/cli#up" target="_blank">Tailscale CLI</a> documentation.
|
||||
:end
|
||||
|
||||
:docker_tailscale_statedir_help:
|
||||
If state directory detection fails on startup, you can specify a persistent directory in the container to override automatic detection.
|
||||
:end
|
||||
|
||||
:docker_tailscale_troubleshooting_packages_help:
|
||||
Enable this to install `ping`, `nslookup`, and `curl` into the container to help troubleshoot networking issues. Once the issues are resolved we recommend disabling this to reduce the size of the container.
|
||||
:end
|
||||
|
||||
:docker_privileged_help:
|
||||
For containers that require the use of host-device access directly or need full exposure to host capabilities, this option will need to be selected.
|
||||
For more information, see this link: <a href="https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities" target="_blank">https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities</a>
|
||||
|
@@ -195,8 +195,8 @@ _(Docker directory)_:
|
||||
<div markdown="1" id="backingfs_type" style="display:none">
|
||||
_(Docker storage driver)_:
|
||||
: <select id="DOCKER_BACKINGFS" name="DOCKER_BACKINGFS" onchange="updateBackingFS(this.value)">
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_BACKINGFS'), 'native', _('native'))?>
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_BACKINGFS'), 'overlay2', _('overlay2'))?>
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_BACKINGFS'), 'native', _('native'))?>
|
||||
</select>
|
||||
<?if ($var['fsState'] != "Started"):?>
|
||||
<span id="WARNING_BACKINGFS" style="display:none;"><i class="fa fa-warning icon warning"></i>_(Only modify if this is a new installation since this can lead to unwanted behaviour!)_</span>
|
||||
@@ -886,13 +886,14 @@ function btrfsScrub(path) {
|
||||
}
|
||||
});
|
||||
}
|
||||
var originalPath = $("#DOCKER_IMAGE_FILE2").val();
|
||||
function updateLocation(val) {
|
||||
var content1 = $("#DOCKER_IMAGE_FILE1");
|
||||
var content2 = $("#DOCKER_IMAGE_FILE2");
|
||||
var dropdown = $("#DOCKER_BACKINGFS");
|
||||
var path = originalPath.split('/');
|
||||
switch (val) {
|
||||
case 'xfs':
|
||||
var path = content2.val().split('/');
|
||||
path.splice(-1,1);
|
||||
content1.val((path.join('/') + '/docker-xfs.img'));
|
||||
$('#vdisk_file').show('slow');
|
||||
@@ -903,9 +904,8 @@ function updateLocation(val) {
|
||||
dropdown.val('native');
|
||||
break;
|
||||
case 'folder':
|
||||
var path = content2.val().split('/');
|
||||
if (path[path.length-1]=='') path.splice(-2,2); else path.splice(-1,1);
|
||||
content2.val(path.join('/'));
|
||||
content2.val(path.join('/') + '/');
|
||||
$('#vdisk_file').hide('slow');
|
||||
$('#vdisk_dir').show('slow');
|
||||
$('#backingfs_type').show('slow');
|
||||
@@ -913,7 +913,6 @@ function updateLocation(val) {
|
||||
content2.prop('disabled',false).trigger('change');
|
||||
break;
|
||||
default:
|
||||
var path = content2.val().split('/');
|
||||
path.splice(-1,1);
|
||||
content1.val((path.join('/') + '/docker.img'));
|
||||
$('#vdisk_file').show('slow');
|
||||
|
BIN
emhttp/plugins/dynamix.docker.manager/images/tailscale.png
Executable file
BIN
emhttp/plugins/dynamix.docker.manager/images/tailscale.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 300 KiB |
@@ -141,11 +141,24 @@ if (isset($_POST['contName'])) {
|
||||
@unlink("$userTmplDir/my-$existing.xml");
|
||||
}
|
||||
}
|
||||
// Extract real Entrypoint and Cmd from container for Tailscale
|
||||
if (isset($_POST['contTailscale']) && $_POST['contTailscale'] == 'on') {
|
||||
// Create preliminary base container but don't run it
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker create --name '" . escapeshellarg($Name) . "' '" . escapeshellarg($Repository) . "'");
|
||||
// Get Entrypoint and Cmd from docker inspect
|
||||
$containerInfo = $DockerClient->getContainerDetails($Name);
|
||||
$ts_env = isset($containerInfo['Config']['Entrypoint']) ? '-e ORG_ENTRYPOINT="' . implode(' ', $containerInfo['Config']['Entrypoint']) . '" ' : '';
|
||||
$ts_env .= isset($containerInfo['Config']['Cmd']) ? '-e ORG_CMD="' . implode(' ', $containerInfo['Config']['Cmd']) . '" ' : '';
|
||||
// Insert Entrypoint and Cmd to docker command
|
||||
$cmd = str_replace('-l net.unraid.docker.managed=dockerman', $ts_env . '-l net.unraid.docker.managed=dockerman' , $cmd);
|
||||
// Remove preliminary container
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker rm '" . escapeshellarg($Name) . "'");
|
||||
}
|
||||
if ($startContainer) $cmd = str_replace('/docker create ', '/docker run -d ', $cmd);
|
||||
execCommand($cmd);
|
||||
if ($startContainer) addRoute($Name); // add route for remote WireGuard access
|
||||
|
||||
echo '<div style="text-align:center"><button type="button" onclick="done()">'._('Done').'</button></div><br>';
|
||||
echo '<div style="text-align:center"><button type="button" onclick="openTerminal(\'docker\',\''.addslashes($Name).'\',\'.log\')">'._('View Container Log').'</button> <button type="button" onclick="done()">'._('Done').'</button></div><br>';
|
||||
goto END;
|
||||
}
|
||||
|
||||
@@ -169,6 +182,9 @@ if (isset($_GET['updateContainer'])){
|
||||
$xml = file_get_contents($tmpl);
|
||||
[$cmd, $Name, $Repository] = xmlToCommand($tmpl);
|
||||
$Registry = getXmlVal($xml, "Registry");
|
||||
$ExtraParams = getXmlVal($xml, "ExtraParams");
|
||||
$Network = getXmlVal($xml, "Network");
|
||||
$TS_Enabled = getXmlVal($xml, "TailscaleEnabled");
|
||||
$oldImageID = $DockerClient->getImageID($Repository);
|
||||
// pull image
|
||||
if ($echo && !pullImage($Name, $Repository)) continue;
|
||||
@@ -182,8 +198,39 @@ if (isset($_GET['updateContainer'])){
|
||||
// attempt graceful stop of container first
|
||||
stopContainer($Name, false, $echo);
|
||||
}
|
||||
// check if network from another container is specified in xml (Network & ExtraParams)
|
||||
if (preg_match('/^container:(.*)/', $Network)) {
|
||||
$Net_Container = str_replace("container:", "", $Network);
|
||||
} else {
|
||||
preg_match("/--(net|network)=container:[^\s]+/", $ExtraParams, $NetworkParam);
|
||||
if (!empty($NetworkParam[0])) {
|
||||
$Net_Container = explode(':', $NetworkParam[0])[1];
|
||||
$Net_Container = str_replace(['"', "'"], '', $Net_Container);
|
||||
}
|
||||
}
|
||||
// check if the container still exists from which the network should be used, if it doesn't exist any more recreate container with network none and don't start it
|
||||
if (!empty($Net_Container)) {
|
||||
$Net_Container_ID = $DockerClient->getContainerID($Net_Container);
|
||||
if (empty($Net_Container_ID)) {
|
||||
$cmd = str_replace('/docker run -d ', '/docker create ', $cmd);
|
||||
$cmd = preg_replace("/--(net|network)=(['\"]?)container:[^'\"]+\\2/", "--network=none ", $cmd);
|
||||
}
|
||||
}
|
||||
// force kill container if still running after time-out
|
||||
if (empty($_GET['communityApplications'])) removeContainer($Name, $echo);
|
||||
// Extract real Entrypoint and Cmd from container for Tailscale
|
||||
if ($TS_Enabled == 'true') {
|
||||
// Create preliminary base container but don't run it
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker create --name '" . escapeshellarg($Name) . "' '" . escapeshellarg($Repository) . "'");
|
||||
// Get Entrypoint and Cmd from docker inspect
|
||||
$containerInfo = $DockerClient->getContainerDetails($Name);
|
||||
$ts_env = isset($containerInfo['Config']['Entrypoint']) ? '-e ORG_ENTRYPOINT="' . implode(' ', $containerInfo['Config']['Entrypoint']) . '" ' : '';
|
||||
$ts_env .= isset($containerInfo['Config']['Cmd']) ? '-e ORG_CMD="' . implode(' ', $containerInfo['Config']['Cmd']) . '" ' : '';
|
||||
// Insert Entrypoint and Cmd to docker command
|
||||
$cmd = str_replace('-l net.unraid.docker.managed=dockerman', $ts_env . '-l net.unraid.docker.managed=dockerman' , $cmd);
|
||||
// Remove preliminary container
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker rm '" . escapeshellarg($Name) . "'");
|
||||
}
|
||||
execCommand($cmd, $echo);
|
||||
if ($startContainer) addRoute($Name); // add route for remote WireGuard access
|
||||
$DockerClient->flushCaches();
|
||||
@@ -213,6 +260,9 @@ if (isset($_GET['xmlTemplate'])) {
|
||||
if (is_file($xmlTemplate)) {
|
||||
$xml = xmlToVar($xmlTemplate);
|
||||
$templateName = $xml['Name'];
|
||||
if (preg_match('/^container:(.*)/', $xml['Network'])) {
|
||||
$xml['Network'] = explode(':', $xml['Network'], 2);
|
||||
}
|
||||
if ($xmlType == 'default') {
|
||||
if (!empty($dockercfg['DOCKER_APP_CONFIG_PATH']) && file_exists($dockercfg['DOCKER_APP_CONFIG_PATH'])) {
|
||||
// override /config
|
||||
@@ -269,6 +319,153 @@ $authoring = $authoringMode ? 'advanced' : 'noshow';
|
||||
$disableEdit = $authoringMode ? 'false' : 'true';
|
||||
$showAdditionalInfo = '';
|
||||
$bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c';
|
||||
|
||||
# Search for existing TAILSCALE_ entries in the Docker template
|
||||
$TS_existing_vars = false;
|
||||
foreach ($xml["Config"] as $config) {
|
||||
if (isset($config["Target"]) && strpos($config["Target"], "TAILSCALE_") === 0) {
|
||||
$TS_existing_vars = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Look for Exit Nodes if Tailscale plugin is installed
|
||||
$ts_exit_nodes = [];
|
||||
$ts_en_check = false;
|
||||
if (file_exists('/usr/local/sbin/tailscale') && exec('pgrep --ns $$ -f "/usr/local/sbin/tailscaled"')) {
|
||||
exec('tailscale exit-node list', $ts_exit_node_list, $retval);
|
||||
if ($retval === 0) {
|
||||
foreach ($ts_exit_node_list as $line) {
|
||||
if (!empty(trim($line))) {
|
||||
if (preg_match('/^(\d+\.\d+\.\d+\.\d+)\s+(.+)$/', trim($line), $matches)) {
|
||||
$parts = preg_split('/\s+/', $matches[2]);
|
||||
$ts_exit_nodes[] = [
|
||||
'ip' => $matches[1],
|
||||
'hostname' => $parts[0],
|
||||
'country' => $parts[1],
|
||||
'city' => $parts[2],
|
||||
'status' => $parts[3]
|
||||
];
|
||||
$ts_en_check = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Try to detect port from WebUI and set webui_url
|
||||
$TSwebuiport = '';
|
||||
$webui_url = '';
|
||||
if (empty($xml['TailscalePort'])) {
|
||||
if (!empty($xml['WebUI'])) {
|
||||
$webui_url = parse_url($xml['WebUI']);
|
||||
preg_match('/:(\d+)\]/', $webui_url['host'], $matches);
|
||||
$TSwebuiport = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
$TS_raw = [];
|
||||
$TS_container_raw = [];
|
||||
$TS_HostNameWarning = "";
|
||||
$TS_HTTPSDisabledWarning = "";
|
||||
$TS_ExitNodeNeedsApproval = false;
|
||||
$TS_MachinesLink = "https://login.tailscale.com/admin/machines/";
|
||||
$TS_DirectMachineLink = $TS_MachinesLink;
|
||||
$TS_HostNameActual = "";
|
||||
$TS_not_approved = "";
|
||||
// Get Tailscale information and create arrays/variables
|
||||
exec("docker exec -i ".$xml['Name']." /bin/sh -c \"tailscale status --peers=false --json\"", $TS_raw);
|
||||
$TS_no_peers = json_decode(implode('', $TS_raw),true);
|
||||
$TS_container = json_decode(implode('', $TS_raw),true);
|
||||
$TS_container = $TS_container['Self'];
|
||||
if (!empty($TS_no_peers) && !empty($TS_container)) {
|
||||
// define the direct link to this machine on the Tailscale website
|
||||
if (!empty($TS_container['TailscaleIPs']) && !empty($TS_container['TailscaleIPs'][0])) {
|
||||
$TS_DirectMachineLink = $TS_MachinesLink.$TS_container['TailscaleIPs'][0];
|
||||
}
|
||||
// warn if MagicDNS or HTTPS is disabled
|
||||
if (empty($TS_no_peers['CurrentTailnet']['MagicDNSEnabled']) || !$TS_no_peers['CurrentTailnet']['MagicDNSEnabled'] || empty($TS_no_peers['CertDomains']) || empty($TS_no_peers['CertDomains'][0])) {
|
||||
$TS_HTTPSDisabledWarning = "<span><b><a href='https://tailscale.com/kb/1153/enabling-https' target='_blank'>Enable HTTPS</a> on your Tailscale account to use Tailscale Serve/Funnel.</b></span>";
|
||||
}
|
||||
// In $TS_container, 'HostName' is what the user requested, need to parse 'DNSName' to find the actual HostName in use
|
||||
$TS_DNSName = _var($TS_container,'DNSName','');
|
||||
$TS_HostNameActual = substr($TS_DNSName, 0, strpos($TS_DNSName, '.'));
|
||||
// compare the actual HostName in use to the one in the XML file
|
||||
if (strcasecmp($TS_HostNameActual, _var($xml, 'TailscaleHostname')) !== 0 && !empty($TS_DNSName)) {
|
||||
// they are different, show a warning
|
||||
$TS_HostNameWarning = "<span><b>Warning: the actual Tailscale hostname is '".$TS_HostNameActual."'</b></span>";
|
||||
}
|
||||
// If this is an Exit Node, show warning if it still needs approval
|
||||
if (_var($xml,'TailscaleIsExitNode') == 'true' && _var($TS_container, 'ExitNodeOption') === false) {
|
||||
$TS_ExitNodeNeedsApproval = true;
|
||||
}
|
||||
//Check for key expiry
|
||||
if(!empty($TS_container['KeyExpiry'])) {
|
||||
$TS_expiry = new DateTime($TS_container['KeyExpiry']);
|
||||
$current_Date = new DateTime();
|
||||
$TS_expiry_diff = $current_Date->diff($TS_expiry);
|
||||
}
|
||||
// Check for non approved routes
|
||||
if(!empty($xml['TailscaleRoutes'])) {
|
||||
$TS_advertise_routes = str_replace(' ', '', $xml['TailscaleRoutes']);
|
||||
if (empty($TS_container['PrimaryRoutes'])) {
|
||||
$TS_container['PrimaryRoutes'] = [];
|
||||
}
|
||||
$routes = explode(',', $TS_advertise_routes);
|
||||
foreach ($routes as $route) {
|
||||
if (!in_array($route, $TS_container['PrimaryRoutes'])) {
|
||||
$TS_not_approved .= " " . $route;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check for exit nodes if ts_en_check was not already done
|
||||
if (!$ts_en_check) {
|
||||
exec("docker exec -i ".$xml['Name']." /bin/sh -c \"tailscale exit-node list\"", $ts_exit_node_list, $retval);
|
||||
if ($retval === 0) {
|
||||
foreach ($ts_exit_node_list as $line) {
|
||||
if (!empty(trim($line))) {
|
||||
if (preg_match('/^(\d+\.\d+\.\d+\.\d+)\s+(.+)$/', trim($line), $matches)) {
|
||||
$parts = preg_split('/\s+/', $matches[2]);
|
||||
$ts_exit_nodes[] = [
|
||||
'ip' => $matches[1],
|
||||
'hostname' => $parts[0],
|
||||
'country' => $parts[1],
|
||||
'city' => $parts[2],
|
||||
'status' => $parts[3]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Construct WebUI URL on container template page
|
||||
// Check if webui_url, Tailscale WebUI and MagicDNS are not empty and make sure that MagicDNS is enabled
|
||||
if (!empty($webui_url) && !empty($xml['TailscaleWebUI']) && (!empty($TS_no_peers['CurrentTailnet']['MagicDNSEnabled']) || $TS_no_peers['CurrentTailnet']['MagicDNSEnabled'])) {
|
||||
// Check if serve or funnel are enabled by checking for [hostname] and replace string with TS_DNSName
|
||||
if (!empty($xml['TailscaleWebUI']) && strpos($xml['TailscaleWebUI'], '[hostname]') !== false && isset($TS_DNSName)) {
|
||||
$TS_webui_url = str_replace("[hostname][magicdns]", rtrim($TS_DNSName, '.'), $xml['TailscaleWebUI']);
|
||||
// Check if serve is disabled, construct url with port, path and query if present and replace [noserve] with url
|
||||
} elseif (strpos($xml['TailscaleWebUI'], '[noserve]') !== false && isset($TS_container['TailscaleIPs'])) {
|
||||
$ipv4 = '';
|
||||
foreach ($TS_container['TailscaleIPs'] as $ip) {
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
$ipv4 = $ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($ipv4)) {
|
||||
$webui_url = isset($xml['WebUI']) ? parse_url($xml['WebUI']) : '';
|
||||
$webui_port = (preg_match('/\[PORT:(\d+)\]/', $xml['WebUI'], $matches)) ? ':' . $matches[1] : '';
|
||||
$webui_path = $webui_url['path'] ?? '';
|
||||
$webui_query = isset($webui_url['query']) ? '?' . $webui_url['query'] : '';
|
||||
$TS_webui_url = 'http://' . $ipv4 . $webui_port . $webui_path . $webui_query;
|
||||
}
|
||||
// Check if TailscaleWebUI in the xml is custom and display instead
|
||||
} elseif (strpos($xml['TailscaleWebUI'], '[hostname]') === false && strpos($xml['TailscaleWebUI'], '[noserve]') === false) {
|
||||
$TS_webui_url = $xml['TailscaleWebUI'];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.switchbutton.css")?>">
|
||||
@@ -423,6 +620,9 @@ function addConfigPopup() {
|
||||
Opts.Buttons += "<button type='button' onclick='removeConfig("+confNum+")'>_(Remove)_</button>";
|
||||
}
|
||||
Opts.Number = confNum;
|
||||
if (Opts.Type == "Device") {
|
||||
Opts.Target = Opts.Value;
|
||||
}
|
||||
newConf = makeConfig(Opts);
|
||||
$("#configLocation").append(newConf);
|
||||
reloadTriggers();
|
||||
@@ -491,6 +691,9 @@ function editConfigPopup(num,disabled) {
|
||||
}
|
||||
|
||||
Opts.Number = num;
|
||||
if (Opts.Type == "Device") {
|
||||
Opts.Target = Opts.Value;
|
||||
}
|
||||
newConf = makeConfig(Opts);
|
||||
if (config.hasClass("config_"+Opts.Display)) {
|
||||
config.html(newConf);
|
||||
@@ -666,6 +869,16 @@ $(function() {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
foreach ($xml["Config"] as $config) {
|
||||
if (isset($config["Target"]) && strpos($config["Target"], "TAILSCALE_") === 0) {
|
||||
$tailscaleTargetFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="canvas">
|
||||
<form markdown="1" method="POST" autocomplete="off" onsubmit="prepareConfig(this)">
|
||||
<input type="hidden" name="csrf_token" value="<?=$var['csrf_token']?>">
|
||||
@@ -706,7 +919,7 @@ _(Template)_:
|
||||
|
||||
<div markdown="1" class="<?=$showAdditionalInfo?>">
|
||||
_(Name)_:
|
||||
: <input type="text" name="contName" pattern="[a-zA-Z0-9][a-zA-Z0-9_.-]+" required>
|
||||
: <input type="text" name="contName" pattern="[a-zA-Z0-9][a-zA-Z0-9_.\-]+" required>
|
||||
|
||||
:docker_client_name_help:
|
||||
|
||||
@@ -858,6 +1071,7 @@ _(Network Type)_:
|
||||
: <select name="contNetwork" onchange="showSubnet(this.value)">
|
||||
<?=mk_option(1,'bridge',_('Bridge'))?>
|
||||
<?=mk_option(1,'host',_('Host'))?>
|
||||
<?=mk_option(1,'container',_('Container'))?>
|
||||
<?=mk_option(1,'none',_('None'))?>
|
||||
<?foreach ($custom as $network):?>
|
||||
<?$name = $network;
|
||||
@@ -881,6 +1095,275 @@ _(Fixed IP address)_ (_(optional)_):
|
||||
:docker_fixed_ip_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="netCONT noshow">
|
||||
_(Container Network)_:
|
||||
: <select name="netCONT" id="netCONT">
|
||||
<?php
|
||||
foreach ($DockerClient->getDockerContainers() as $ct) {
|
||||
if ($ct['Name'] !== $xml['Name']) {
|
||||
$list[] = $ct['Name'];
|
||||
echo mk_option($ct['Name'], $ct['Name'], $ct['Name']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
:docker_container_network_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSdivider noshow"><hr></div>
|
||||
|
||||
<?if ($TS_existing_vars == 'true'):?>
|
||||
<div markdown="1" class="TSwarning noshow">
|
||||
<b style="color:red;">_(WARNING)_</b>:
|
||||
: <b>_(Existing TAILSCALE variables found, please remove any existing modifications in the Template for Tailscale before using this function!)_</b>
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
<?if (empty($xml['TailscaleEnabled'])):?>
|
||||
<div markdown="1" class="TSdeploy noshow">
|
||||
<b>_(First deployment)_</b>:
|
||||
: <p>_(After deploying the container, open the log and follow the link to register the container to your Tailnet!)_</p>
|
||||
</div>
|
||||
|
||||
<?if (!file_exists('/usr/local/sbin/tailscale')):?>
|
||||
<div markdown="1" class="TSdeploy noshow">
|
||||
<b>_(Recommendation)_</b>:
|
||||
: <p>_(For the best experience with Tailscale, install "Tailscale (Plugin)" from)_ <a href="/Apps" target='_blank'> Community Applications</a>.</p>
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
<?endif;?>
|
||||
|
||||
<div markdown="1">
|
||||
_(Use Tailscale)_:
|
||||
: <input type="checkbox" class="switch-on-off" name="contTailscale" id="contTailscale" <?php if (!empty($xml['TailscaleEnabled']) && $xml['TailscaleEnabled'] == 'true') echo 'checked'; ?> onchange="showTailscale(this)">
|
||||
|
||||
:docker_tailscale_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSdivider noshow">
|
||||
<b>_(NOTE)_</b>:
|
||||
: <i>_(This option will install Tailscale and dependencies into the container.)_</i>
|
||||
</div>
|
||||
|
||||
<?if($TS_ExitNodeNeedsApproval):?>
|
||||
<div markdown="1" class="TShostname noshow">
|
||||
<b>Warning:</b>
|
||||
: Exit Node not yet approved. Navigate to the <a href="<?=$TS_DirectMachineLink?>" target='_blank'>Tailscale website</a> and approve it.
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
<?if(!empty($TS_expiry_diff)):?>
|
||||
<div markdown="1" class="TSdivider noshow">
|
||||
<b>_(Warning)_</b>:
|
||||
<?if($TS_expiry_diff->invert):?>
|
||||
: <b>Tailscale Key expired!</b> <a href="<?=$TS_MachinesLink?>" target='_blank'>Renew/Disable key expiry</a> for '<b><?=$TS_HostNameActual?></b>'.
|
||||
<?else:?>
|
||||
: Tailscale Key will expire in <b><?=$TS_expiry_diff->days?> days</b>! <a href="<?=$TS_MachinesLink?>" target='_blank'>Disable Key Expiry</a> for '<b><?=$TS_HostNameActual?></b>'.
|
||||
<?endif;?>
|
||||
<label>See <a href="https://tailscale.com/kb/1028/key-expiry" target='_blank'>key-expiry</a>.</label>
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
<?if(!empty($TS_not_approved)):?>
|
||||
<div markdown="1" class="TSdivider noshow">
|
||||
<b>_(Warning)_</b>:
|
||||
: The following route(s) are not approved: <b><?=trim($TS_not_approved)?></b>
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
<div markdown="1" class="TShostname noshow">
|
||||
_(Tailscale Hostname)_:
|
||||
: <input type="text" pattern="[A-Za-z0-9_\-]*" name="TShostname" <?php if (!empty($xml['TailscaleHostname'])) echo 'value="' . $xml['TailscaleHostname'] . '"'; ?> placeholder="_(Hostname for the container)_"> <?=$TS_HostNameWarning?>
|
||||
|
||||
:docker_tailscale_hostname_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSisexitnode noshow">
|
||||
_(Be a Tailscale Exit Node)_:
|
||||
: <select name="TSisexitnode" id="TSisexitnode" onchange="showTailscale(this)">
|
||||
<?=mk_option(1,'false',_('No'))?>
|
||||
<?=mk_option(1,'true',_('Yes'))?>
|
||||
</select>
|
||||
<span id='TSisexitnode_msg' style='font-style: italic;'></span>
|
||||
|
||||
:docker_tailscale_be_exitnode_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSexitnodeip noshow">
|
||||
_(Use a Tailscale Exit Node)_:
|
||||
<?if($ts_en_check !== true && empty($ts_exit_nodes)):?>
|
||||
: <input type="text" name="TSexitnodeip" <?php if (!empty($xml['TailscaleExitNodeIP'])) echo 'value="' . $xml['TailscaleExitNodeIP'] . '"'; ?> placeholder="_(IP/Hostname from Exit Node)_" onchange="processExitNodeoptions(this)">
|
||||
<?else:?>
|
||||
: <select name="TSexitnodeip" id="TSexitnodeip" onchange="processExitNodeoptions(this)">
|
||||
<?=mk_option(1,'',_('None'))?>
|
||||
<?foreach ($ts_exit_nodes as $ts_exit_node):?>
|
||||
<?=$node_offline = $ts_exit_node['status'] === 'offline' ? ' - OFFLINE' : '';?>
|
||||
<?=mk_option(1,$ts_exit_node['ip'],$ts_exit_node['ip'] . ' - ' . $ts_exit_node['hostname'] . $node_offline)?>
|
||||
<?endforeach;?></select>
|
||||
<?endif;?>
|
||||
</select>
|
||||
<span id='TSexitnodeip_msg' style='font-style: italic;'></span>
|
||||
|
||||
:docker_tailscale_exitnode_ip_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSallowlanaccess noshow">
|
||||
_(Tailscale Allow LAN Access)_:
|
||||
: <select name="TSallowlanaccess" id="TSallowlanaccess">
|
||||
<?=mk_option(1,'false',_('No'))?>
|
||||
<?=mk_option(1,'true',_('Yes'))?>
|
||||
</select>
|
||||
<?=$TS_HTTPSDisabledWarning?>
|
||||
|
||||
:docker_tailscale_lanaccess_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSuserspacenetworking noshow">
|
||||
_(Tailscale Userspace Networking)_:
|
||||
: <select name="TSuserspacenetworking" id="TSuserspacenetworking" onchange="setExitNodeoptions()">
|
||||
<?=mk_option(1,'true',_('Enabled'))?>
|
||||
<?=mk_option(1,'false',_('Disabled'))?>
|
||||
</select>
|
||||
<span id='TSuserspacenetworking_msg' style='font-style: italic;'></span>
|
||||
|
||||
:docker_tailscale_userspace_networking_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSssh noshow">
|
||||
_(Enable Tailscale SSH)_:
|
||||
: <select name="TSssh" id="TSssh">
|
||||
<?=mk_option(1,'false',_('No'))?>
|
||||
<?=mk_option(1,'true',_('Yes'))?>
|
||||
</select>
|
||||
|
||||
:docker_tailscale_ssh_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSserve noshow">
|
||||
_(Tailscale Serve)_:
|
||||
: <select name="TSserve" id="TSserve" onchange="showServe(this.value)">
|
||||
<?=mk_option(1,'no',_('No'))?>
|
||||
<?=mk_option(1,'serve',_('Serve'))?>
|
||||
<?=mk_option(1,'funnel',_('Funnel'))?>
|
||||
</select>
|
||||
<?php if (!empty($TS_webui_url)) echo '<label for="TSserve"><a href="' . $TS_webui_url . '" target="_blank">' . $TS_webui_url . '</a></label>'; ?>
|
||||
|
||||
:docker_tailscale_serve_mode_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSserveport noshow">
|
||||
_(Tailscale Serve Port)_:
|
||||
: <input type="text" name="TSserveport" value="<?php echo !empty($xml['TailscaleServePort']) ? $xml['TailscaleServePort'] : (!empty($TSwebuiport) ? $TSwebuiport : ''); ?>" placeholder="_(Will be detected automatically if possible)_">
|
||||
|
||||
:docker_tailscale_serve_port_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSadvanced noshow">
|
||||
_(Tailscale Show Advanced Settings)_:
|
||||
: <input type="checkbox" name="TSadvanced" class="switch-on-off" onchange="showTSAdvanced(this.checked)">
|
||||
|
||||
:docker_tailscale_show_advanced_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSservelocalpath noshow">
|
||||
_(Tailscale Serve Local Path)_:
|
||||
: <input type="text" name="TSservelocalpath" <?php if (!empty($xml['TailscaleServeLocalPath'])) echo 'value="' . $xml['TailscaleServeLocalPath'] . '"'; ?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_serve_local_path_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSserveprotocol noshow">
|
||||
_(Tailscale Serve Protocol)_:
|
||||
: <input type="text" name="TSserveprotocol" <?php if (!empty($xml['TailscaleServeProtocol'])) echo 'value="' . $xml['TailscaleServeProtocol'] . '"'; ?> placeholder="_(Leave empty if unsure, defaults to https)_">
|
||||
|
||||
:docker_tailscale_serve_protocol_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSserveprotocolport noshow">
|
||||
_(Tailscale Serve Protocol Port)_:
|
||||
: <input type="text" name="TSserveprotocolport" <?php if (!empty($xml['TailscaleServeProtocolPort'])) echo 'value="' . $xml['TailscaleServeProtocolPort'] . '"'; ?> placeholder="_(Leave empty if unsure, defaults to =443)_">
|
||||
|
||||
:docker_tailscale_serve_protocol_port_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSservepath noshow">
|
||||
_(Tailscale Serve Path)_:
|
||||
: <input type="text" name="TSservepath" <?php if (!empty($xml['TailscaleServePath'])) echo 'value="' . $xml['TailscaleServePath'] . '"'; ?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_serve_path_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSwebui noshow">
|
||||
_(Tailscale WebUI)_:
|
||||
: <input type="text" name="TSwebui" value="<?php echo !empty($TS_webui_url) ? $TS_webui_url : ''; ?>" placeholder="Will be determined automatically if possible" disabled>
|
||||
<input type="hidden" name="TSwebui" <?php if (!empty($xml['TailscaleWebUI'])) echo 'value="' . $xml['TailscaleWebUI'] . '"'; ?>>
|
||||
|
||||
:docker_tailscale_serve_webui_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSroutes noshow">
|
||||
_(Tailscale Advertise Routes)_:
|
||||
: <input type="text" pattern="[0-9:., ]*" name="TSroutes" <?php if (!empty($xml['TailscaleRoutes'])) echo 'value="' . $xml['TailscaleRoutes'] . '"'?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_advertise_routes_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSdaemonparams noshow">
|
||||
_(Tailscale Daemon Parameters)_:
|
||||
: <input type="text" name="TSdaemonparams" <?php if (!empty($xml['TailscaleDParams'])) echo 'value="' . $xml['TailscaleDParams'] . '"'; ?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_daemon_extra_params_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSextraparams noshow">
|
||||
_(Tailscale Extra Parameters)_:
|
||||
: <input type="text" name="TSextraparams" <?php if (!empty($xml['TailscaleParams'])) echo 'value="' . $xml['TailscaleParams'] . '"'; ?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_extra_param_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSstatedir noshow">
|
||||
_(Tailscale State Directory)_:
|
||||
: <input type="text" name="TSstatedir" <?php if (!empty($xml['TailscaleStateDir'])) echo 'value="' . $xml['TailscaleStateDir'] . '"'; ?> placeholder="_(Leave empty if unsure)_">
|
||||
|
||||
:docker_tailscale_statedir_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TStroubleshooting noshow">
|
||||
_(Tailscale Install Troubleshooting Packages)_:
|
||||
: <input type="checkbox" class="switch-on-off" name="TStroubleshooting" <?php if (!empty($xml['TailscaleTroubleshooting']) && $xml['TailscaleTroubleshooting'] == 'true') echo 'checked'; ?>>
|
||||
|
||||
:docker_tailscale_troubleshooting_packages_help:
|
||||
|
||||
</div>
|
||||
|
||||
<div markdown="1" class="TSdivider noshow">
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
_(Console shell command)_:
|
||||
: <select name="contShell">
|
||||
<?=mk_option(1,'sh',_('Shell'))?>
|
||||
@@ -1013,9 +1496,222 @@ function showSubnet(bridge) {
|
||||
if (bridge.match(/^(bridge|host|none)$/i) !== null) {
|
||||
$('.myIP').hide();
|
||||
$('input[name="contMyIP"]').val('');
|
||||
$('.netCONT').hide();
|
||||
$('#netCONT').val('');
|
||||
} else if (bridge.match(/^(container)$/i) !== null) {
|
||||
$('.netCONT').show();
|
||||
$('#netCONT').val('<?php echo $xml['Network'][1]; ?>');
|
||||
$('.myIP').hide();
|
||||
$('input[name="contMyIP"]').val('');
|
||||
} else {
|
||||
$('.myIP').show();
|
||||
$('#myIP').html('Subnet: '+subnet[bridge]);
|
||||
$('.netCONT').hide();
|
||||
$('#netCONT').val('');
|
||||
}
|
||||
}
|
||||
|
||||
function processExitNodeoptions(value) {
|
||||
val = null;
|
||||
if (value.tagName.toLowerCase() === "input") {
|
||||
val = value.value.trim();
|
||||
} else if (value.tagName.toLowerCase() === "select") {
|
||||
val = value.value;
|
||||
}
|
||||
if (val) {
|
||||
$('.TSallowlanaccess').show();
|
||||
} else {
|
||||
$('#TSallowlanaccess').val('false');
|
||||
$('.TSallowlanaccess').hide();
|
||||
}
|
||||
setUserspaceNetworkOptions();
|
||||
setIsExitNodeoptions();
|
||||
}
|
||||
|
||||
function setUserspaceNetworkOptions() {
|
||||
optTrueDisabled = false;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "";
|
||||
value = null;
|
||||
|
||||
var network = $('select[name="contNetwork"]')[0].value;
|
||||
var isExitnode = $('#TSisexitnode').val();
|
||||
if (network == 'host' || isExitnode == 'true') {
|
||||
// in host mode or if this container is an Exit Node
|
||||
// then Userspace Networking MUST be enabled ('true')
|
||||
value = 'true';
|
||||
optTrueDisabled = false;
|
||||
optFalseDisabled = true;
|
||||
optMessage = (isExitnode == 'true') ? "Enabled because this is an Exit Node" : "Enabled due to Docker "+network+" mode";
|
||||
} else {
|
||||
if (document.querySelector('input[name="TSexitnodeip"], select[name="TSexitnodeip"]').value) {
|
||||
// If an Exit Node IP is set, Userspace Networking MUST be disabled ('false')
|
||||
value = 'false';
|
||||
optTrueDisabled = true;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "Disabled due to use of an Exit Node";
|
||||
} else {
|
||||
// Exit Node IP is not set, user can decide whether to enable/disable Userspace Networking
|
||||
optTrueDisabled = false;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "";
|
||||
}
|
||||
}
|
||||
|
||||
$("#TSuserspacenetworking option[value='true']").prop("disabled", optTrueDisabled);
|
||||
$("#TSuserspacenetworking option[value='false']").prop("disabled", optFalseDisabled);
|
||||
if (value != null) $('#TSuserspacenetworking').val(value);
|
||||
$('#TSuserspacenetworking_msg').text(optMessage);
|
||||
setExitNodeoptions();
|
||||
}
|
||||
|
||||
function setIsExitNodeoptions() {
|
||||
optTrueDisabled = false;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "";
|
||||
value = null;
|
||||
|
||||
var network = $('select[name="contNetwork"]')[0].value;
|
||||
if (network == 'host') {
|
||||
// in host mode then this cannot be an Exit Node
|
||||
value = 'false';
|
||||
optTrueDisabled = true;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "Disabled due to Docker "+network+" mode";
|
||||
} else {
|
||||
if (document.querySelector('input[name="TSexitnodeip"], select[name="TSexitnodeip"]').value) {
|
||||
// If an Exit Node IP is set, this cannot be an Exit Node
|
||||
value = 'false';
|
||||
optTrueDisabled = true;
|
||||
optFalseDisabled = false;
|
||||
optMessage = "Disabled due to use of an Exit Node";
|
||||
} else {
|
||||
optTrueDisabled = false;
|
||||
optFalseDisabled = false;
|
||||
}
|
||||
}
|
||||
$("#TSisexitnode option[value='true']").prop("disabled", optTrueDisabled);
|
||||
$("#TSisexitnode option[value='false']").prop("disabled", optFalseDisabled);
|
||||
if (value != null) $('#TSisexitnode').val(value);
|
||||
$('#TSisexitnode_msg').text(optMessage);
|
||||
}
|
||||
|
||||
function setExitNodeoptions() {
|
||||
optMessage = "";
|
||||
var $exitNodeInput = $('input[name="TSexitnodeip"]');
|
||||
var $exitNodeSelect = $('#TSexitnodeip');
|
||||
// In host mode, TSuserspacenetworking is true
|
||||
if ($('#TSuserspacenetworking').val() == 'true') {
|
||||
// if TSuserspacenetworking is true, then TSexitnodeip must be "" and all options are disabled
|
||||
optMessage = "Disabled because Userspace Networking is Enabled.";
|
||||
$exitNodeInput.val('').prop('disabled', true); // Disable the input field
|
||||
$exitNodeSelect.val('').prop('disabled', true).find('option').each(function() {
|
||||
if ($(this).val() === "") {
|
||||
$(this).prop('disabled', false); // Enable the option with value=""
|
||||
} else {
|
||||
$(this).prop('disabled', true); // Disable all other options
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// if TSuserspacenetworking is false, then all TSexitnodeip options can be enabled
|
||||
$exitNodeInput.prop('disabled', false); // Enable the input field
|
||||
$exitNodeSelect.prop('disabled', false).find('option').each(function() {
|
||||
$(this).prop('disabled', false); // Enable all options
|
||||
});
|
||||
}
|
||||
$('#TSexitnodeip_msg').text(optMessage);
|
||||
}
|
||||
|
||||
function showTSAdvanced(checked) {
|
||||
if (!checked) {
|
||||
<?if (!empty($TSwebuiport)):?>
|
||||
$('.TSserveport').hide();
|
||||
<?elseif (empty($contTailscale) || $contTailscale == 'false'):?>
|
||||
$('.TSserveport').hide();
|
||||
<?else:?>
|
||||
$('.TSserveport').show();
|
||||
<?endif;?>
|
||||
$('.TSdaemonparams').hide();
|
||||
$('.TSextraparams').hide();
|
||||
$('.TSstatedir').hide();
|
||||
$('.TSservepath').hide();
|
||||
$('.TSserveprotocol').hide();
|
||||
$('.TSserveprotocolport').hide();
|
||||
$('.TSservelocalpath').hide();
|
||||
$('.TSwebui').hide();
|
||||
$('.TStroubleshooting').hide();
|
||||
$('.TSroutes').hide();
|
||||
} else {
|
||||
$('.TSdaemonparams').show();
|
||||
$('.TSextraparams').show();
|
||||
$('.TSstatedir').show();
|
||||
$('.TSserveport').show();
|
||||
$('.TSservepath').show();
|
||||
$('.TSserveprotocol').show();
|
||||
$('.TSserveprotocolport').show();
|
||||
$('.TSservelocalpath').show();
|
||||
$('.TSwebui').show();
|
||||
$('.TStroubleshooting').show();
|
||||
$('.TSroutes').show();
|
||||
}
|
||||
}
|
||||
|
||||
function showTailscale(source) {
|
||||
if (!$.trim($('#TSallowlanaccess').val())) {
|
||||
$('#TSallowlanaccess').val('false');
|
||||
}
|
||||
if (!$.trim($('#TSserve').val())) {
|
||||
$('#TSserve').val('no');
|
||||
}
|
||||
checked = $('#contTailscale').prop('checked');
|
||||
if (!checked) {
|
||||
$('.TSdivider').hide();
|
||||
$('.TSwarning').hide();
|
||||
$('.TSdeploy').hide();
|
||||
$('.TSisexitnode').hide();
|
||||
$('.TShostname').hide();
|
||||
$('.TSexitnodeip').hide();
|
||||
$('.TSssh').hide();
|
||||
$('.TSallowlanaccess').hide();
|
||||
$('.TSdaemonparams').hide();
|
||||
$('.TSextraparams').hide();
|
||||
$('.TSstatedir').hide();
|
||||
$('.TSserve').hide();
|
||||
$('.TSuserspacenetworking').hide();
|
||||
$('.TSservepath').hide();
|
||||
$('.TSserveprotocol').hide();
|
||||
$('.TSserveprotocolport').hide();
|
||||
$('.TSservelocalpath').hide();
|
||||
$('.TSwebui').hide();
|
||||
$('.TSserveport').hide();
|
||||
$('.TSadvanced').hide();
|
||||
$('.TSroutes').hide();
|
||||
} else {
|
||||
// reset these vals back to what they were in the XML
|
||||
$('#TSssh').val('<?php echo !empty($xml['TailscaleSSH']) ? $xml['TailscaleSSH'] : 'false' ?>');
|
||||
$('#TSallowlanaccess').val('<?php echo $xml['TailscaleLANAccess']; ?>');
|
||||
$('#TSserve').val('<?php echo $xml['TailscaleServe']; ?>');
|
||||
$('#TSexitnodeip').val('<?php echo $xml['TailscaleExitNodeIP']; ?>');
|
||||
$('#TSuserspacenetworking').val('<?php echo !empty($xml['TailscaleUserspaceNetworking']) ? $xml['TailscaleUserspaceNetworking'] : 'false' ?>');
|
||||
<?if (empty($xml['TailscaleServe']) && !empty($TSwebuiport) && empty($xml['TailscaleServePort'])):?>
|
||||
$('#TSserve').val('serve');
|
||||
<?elseif (empty($xml['TailscaleServe']) && empty($TSwebuiport) && empty($xml['TailscaleServePort'])):?>
|
||||
$('#TSserve').val('no');
|
||||
<?endif;?>
|
||||
// don't reset this field if caller was the onchange event for this field
|
||||
if (source.id != 'TSisexitnode') $('#TSisexitnode').val('<?php echo !empty($xml['TailscaleIsExitNode']) ? $xml['TailscaleIsExitNode'] : 'false'; ?>');
|
||||
$('.TSisexitnode').show();
|
||||
$('.TShostname').show();
|
||||
$('.TSssh').show();
|
||||
$('.TSexitnodeip').show();
|
||||
$('.TSallowlanaccess').hide();
|
||||
$('.TSserve').show();
|
||||
$('.TSuserspacenetworking').show();
|
||||
processExitNodeoptions(document.querySelector('input[name="TSexitnodeip"], select[name="TSexitnodeip"]'));
|
||||
$('.TSdivider').show();
|
||||
$('.TSwarning').show();
|
||||
$('.TSdeploy').show();
|
||||
$('.TSadvanced').show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,6 +1807,9 @@ $(function() {
|
||||
Opts.Buttons += "<button type='button' onclick='removeConfig("+confNum+")'>_(Remove)_</button>";
|
||||
}
|
||||
Opts.Number = confNum;
|
||||
if (Opts.Type == "Device") {
|
||||
Opts.Target = Opts.Value;
|
||||
}
|
||||
newConf = makeConfig(Opts);
|
||||
if (Opts.Display == 'advanced' || Opts.Display == 'advanced-hide') {
|
||||
$("#configLocationAdvanced").append(newConf);
|
||||
|
@@ -292,6 +292,16 @@ class DockerTemplates {
|
||||
return $WebUI;
|
||||
}
|
||||
|
||||
private function getTailscaleJson($name) {
|
||||
$TS_raw = [];
|
||||
exec("docker exec -i ".$name." /bin/sh -c \"tailscale status --peers=false --json\" 2>/dev/null", $TS_raw);
|
||||
if (!empty($TS_raw)) {
|
||||
$TS_raw = implode("\n", $TS_raw);
|
||||
return json_decode($TS_raw, true);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getAllInfo($reload=false,$com=true,$communityApplications=false) {
|
||||
global $driver, $dockerManPaths, $host;
|
||||
$DockerClient = new DockerClient();
|
||||
@@ -299,6 +309,7 @@ class DockerTemplates {
|
||||
//$DockerUpdate->verbose = $this->verbose;
|
||||
$info = DockerUtil::loadJSON($dockerManPaths['webui-info']);
|
||||
$autoStart = array_map('var_split', @file($dockerManPaths['autostart-file'],FILE_IGNORE_NEW_LINES) ?: []);
|
||||
//$TS_dns = $this->getTailscaleDNS();
|
||||
foreach ($DockerClient->getDockerContainers() as $ct) {
|
||||
$name = $ct['Name'];
|
||||
$image = $ct['Image'];
|
||||
@@ -334,6 +345,39 @@ class DockerTemplates {
|
||||
if (strpos($ct['NetworkMode'], 'container:') === 0)
|
||||
$tmp['url'] = '';
|
||||
}
|
||||
// Check if webui & ct TSurl is set, if set construct WebUI URL on Docker page
|
||||
$tmp['TSurl'] = '';
|
||||
if (!empty($webui) && !empty($ct['TSUrl'])) {
|
||||
$TS_no_peers = $this->getTailscaleJson($name);
|
||||
if (!empty($TS_no_peers) && (!empty($TS_no_peers['CurrentTailnet']['MagicDNSEnabled']) || $TS_no_peers['CurrentTailnet']['MagicDNSEnabled'])) {
|
||||
$TS_container = $TS_no_peers['Self'];
|
||||
$TS_DNSName = _var($TS_container,'DNSName','');
|
||||
$TS_HostNameActual = substr($TS_DNSName, 0, strpos($TS_DNSName, '.'));
|
||||
// Check if serve or funnel are enabled by checking for [hostname] and replace string with TS_DNSName
|
||||
if (strpos($ct['TSUrl'], '[hostname]') !== false && isset($TS_DNSName)) {
|
||||
$tmp['TSurl'] = str_replace("[hostname][magicdns]", rtrim($TS_DNSName, '.'), $ct['TSUrl']);
|
||||
// Check if serve is disabled, construct url with port, path and query if present and replace [noserve] with url
|
||||
} elseif (strpos($ct['TSUrl'], '[noserve]') !== false && isset($TS_container['TailscaleIPs'])) {
|
||||
$ipv4 = '';
|
||||
foreach ($TS_container['TailscaleIPs'] as $ip) {
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
$ipv4 = $ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($ipv4)) {
|
||||
$webui_url = isset($webui) ? parse_url($webui) : '';
|
||||
$webui_port = (preg_match('/\[PORT:(\d+)\]/', $webui, $matches)) ? ':' . $matches[1] : '';
|
||||
$webui_path = $webui_url['path'] ?? '';
|
||||
$webui_query = isset($webui_url['query']) ? '?' . $webui_url['query'] : '';
|
||||
$tmp['TSurl'] = 'http://' . $ipv4 . $webui_port . $webui_path . $webui_query;
|
||||
}
|
||||
// Check if TailscaleWebUI in the xml is custom and display instead
|
||||
} elseif (strpos($ct['TSUrl'], '[hostname]') === false && strpos($ct['TSUrl'], '[noserve]') === false) {
|
||||
$tmp['TSurl'] = $ct['TSUrl'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ($tmp['shell'] ?? false) == false )
|
||||
$tmp['shell'] = $this->getTemplateValue($image, 'Shell');
|
||||
}
|
||||
@@ -929,13 +973,18 @@ class DockerClient {
|
||||
$c['Created'] = $this->humanTiming($ct['Created']);
|
||||
$c['NetworkMode'] = $ct['HostConfig']['NetworkMode'];
|
||||
$c['Manager'] = $info['Config']['Labels']['net.unraid.docker.managed'] ?? false;
|
||||
if ($c['Manager'] == 'composeman') {
|
||||
$c['ComposeProject'] = $info['Config']['Labels']['com.docker.compose.project'];
|
||||
}
|
||||
[$net, $id] = array_pad(explode(':',$c['NetworkMode']),2,'');
|
||||
$c['CPUset'] = $info['HostConfig']['CpusetCpus'];
|
||||
$c['BaseImage'] = $ct['Labels']['BASEIMAGE'] ?? false;
|
||||
$c['Icon'] = $info['Config']['Labels']['net.unraid.docker.icon'] ?? false;
|
||||
$c['Url'] = $info['Config']['Labels']['net.unraid.docker.webui'] ?? false;
|
||||
$c['Shell'] = $info['Config']['Labels']['net.unraid.docker.shell'] ?? false;
|
||||
$c['Manager'] = $info['Config']['Labels']['net.unraid.docker.managed'] ?? false;
|
||||
$c['TSUrl'] = $info['Config']['Labels']['net.unraid.docker.tailscale.webui'] ?? false;
|
||||
$c['TSHostname'] = $info['Config']['Labels']['net.unraid.docker.tailscale.hostname'] ?? false;
|
||||
$c['Shell'] = $info['Config']['Labels']['net.unraid.docker.shell'] ?? false;
|
||||
$c['Manager'] = $info['Config']['Labels']['net.unraid.docker.managed'] ?? false;
|
||||
$c['Ports'] = [];
|
||||
$c['Networks'] = [];
|
||||
if ($id) $c['NetworkMode'] = $net.str_replace('/',':',DockerUtil::ctMap($id)?:'/???');
|
||||
|
@@ -48,6 +48,55 @@ $null = '0.0.0.0';
|
||||
$autostart = (array)@file($autostart_file,FILE_IGNORE_NEW_LINES);
|
||||
$names = array_map('var_split',$autostart);
|
||||
|
||||
// Grab Tailscale json from container
|
||||
function tailscale_stats($name) {
|
||||
exec("docker exec -i ".$name." /bin/sh -c \"tailscale status --json | jq '{Self: .Self, ExitNodeStatus: .ExitNodeStatus, Version: .Version}'\" 2>/dev/null", $TS_stats);
|
||||
if (!empty($TS_stats)) {
|
||||
$TS_stats = implode("\n", $TS_stats);
|
||||
return json_decode($TS_stats, true);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// Download Tailscal JSON and return Array, refresh file if older than 24 hours
|
||||
function tailscale_json_dl($file, $url) {
|
||||
$dl_status = 0;
|
||||
if (!is_dir('/tmp/tailscale')) {
|
||||
mkdir('/tmp/tailscale', 0777, true);
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
exec("wget -T 3 -q -O " . $file . " " . $url, $output, $dl_status);
|
||||
} else {
|
||||
$fileage = time() - filemtime($file);
|
||||
if ($fileage > 86400) {
|
||||
unlink($file);
|
||||
exec("wget -T 3 -q -O " . $file . " " . $url, $output, $dl_status);
|
||||
}
|
||||
}
|
||||
if ($dl_status === 0) {
|
||||
return json_decode(@file_get_contents($file), true);
|
||||
} elseif ($dl_status === 0 && is_file($file)) {
|
||||
return json_decode(@file_get_contents($file), true);
|
||||
} else {
|
||||
unlink($file);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// Grab Tailscale DERP map JSON
|
||||
$TS_derp_url = 'https://login.tailscale.com/derpmap/default';
|
||||
$TS_derp_file = '/tmp/tailscale/tailscale-derpmap.json';
|
||||
$TS_derp_list = tailscale_json_dl($TS_derp_file, $TS_derp_url);
|
||||
|
||||
// Grab Tailscale version JSON
|
||||
$TS_version_url = 'https://pkgs.tailscale.com/stable/?mode=json';
|
||||
$TS_version_file = '/tmp/tailscale/tailscale-latest-version.json';
|
||||
// Extract tarbal version string
|
||||
$TS_latest_version = tailscale_json_dl($TS_version_file, $TS_version_url);
|
||||
if (!empty($TS_latest_version)) {
|
||||
$TS_latest_version = $TS_latest_version["TarballsVersion"];
|
||||
}
|
||||
|
||||
function my_lang_time($text) {
|
||||
[$number, $text] = my_explode(' ',$text,2);
|
||||
return sprintf(_("%s $text"),$number);
|
||||
@@ -69,21 +118,24 @@ foreach ($containers as $ct) {
|
||||
$running = $info['running'] ? 1 : 0;
|
||||
$paused = $info['paused'] ? 1 : 0;
|
||||
$is_autostart = $info['autostart'] ? 'true':'false';
|
||||
$updateStatus = substr($ct['NetworkMode'],-4)==':???' ? 2 : ($info['updated']=='true' ? 0 : ($info['updated']=='false' ? 1 : 3));
|
||||
$composestack = isset($ct['ComposeProject']) ? $ct['ComposeProject'] : '';
|
||||
$updateStatus = substr($ct['NetworkMode'], -4) == ':???' ? 2 : ($info['updated'] == 'true' ? 0 : ($info['updated'] == 'false' ? 1 : 3));
|
||||
$template = $info['template']??'';
|
||||
$shell = $info['shell']??'';
|
||||
$webGui = html_entity_decode($info['url']??'');
|
||||
$TShostname = isset($ct['TSHostname']) ? $ct['TSHostname'] : '';
|
||||
$TSwebGui = html_entity_decode($info['TSurl']??'');
|
||||
$support = html_entity_decode($info['Support']??'');
|
||||
$project = html_entity_decode($info['Project']??'');
|
||||
$registry = html_entity_decode($info['registry']??'');
|
||||
$donateLink = html_entity_decode($info['DonateLink']??'');
|
||||
$readme = html_entity_decode($info['ReadMe']??'');
|
||||
$menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s', '%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project),addslashes($registry),addslashes($donateLink),addslashes($readme));
|
||||
$menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s','%s', '%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), addslashes($TSwebGui), $shell, $id, addslashes($support), addslashes($project),addslashes($registry),addslashes($donateLink),addslashes($readme));
|
||||
$docker[] = "docker.push({name:'$name',id:'$id',state:$running,pause:$paused,update:$updateStatus});";
|
||||
$shape = $running ? ($paused ? 'pause' : 'play') : 'square';
|
||||
$status = $running ? ($paused ? 'paused' : 'started') : 'stopped';
|
||||
$color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text');
|
||||
$update = $updateStatus==1 ? 'blue-text' : '';
|
||||
$update = $updateStatus==1 && !empty($compose) ? 'blue-text' : '';
|
||||
$icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png';
|
||||
$image = substr($icon,-4)=='.png' ? "<img src='$icon?".filemtime("$docroot{$info['icon']}")."' class='img' onerror=this.src='/plugins/dynamix.docker.manager/images/question.png';>" : (substr($icon,0,5)=='icon-' ? "<i class='$icon img'></i>" : "<i class='fa fa-$icon img'></i>");
|
||||
$wait = var_split($autostart[array_search($name,$names)]??'',1);
|
||||
@@ -119,12 +171,12 @@ foreach ($containers as $ct) {
|
||||
$paths[] = sprintf('%s<i class="fa fa-%s" style="margin:0 6px"></i>%s', htmlspecialchars($container_path), $access_mode=='ro'?'long-arrow-left':'arrows-h', htmlspecialchars($host_path));
|
||||
}
|
||||
echo "<tr class='sortable'><td class='ct-name' style='width:220px;padding:8px'><i class='fa fa-arrows-v mover orange-text'></i>";
|
||||
if ($template) {
|
||||
if ($template && empty($composestack)) {
|
||||
$appname = "<a class='exec' onclick=\"editContainer('".addslashes(htmlspecialchars($name))."','".addslashes(htmlspecialchars($template))."')\">".htmlspecialchars($name)."</a>";
|
||||
} else {
|
||||
$appname = htmlspecialchars($name);
|
||||
}
|
||||
echo "<span class='outer'><span id='$id' $menu class='hand'>$image</span><span class='inner'><span class='appname $update'>$appname</span><br><i id='load-$id' class='fa fa-$shape $status $color'></i><span class='state'>"._($status)."</span></span></span>";
|
||||
echo "<span class='outer'><span id='$id' $menu class='hand'>$image</span><span class='inner'><span class='appname $update'>$appname</span><br><i id='load-$id' class='fa fa-$shape $status $color'></i><span class='state'>"._($status).(!empty($composestack) ? '<br/>Compose Stack: ' . $composestack : '')."</span></span></span>";
|
||||
echo "<div class='advanced' style='margin-top:8px'>"._('Container ID').": $id<br>";
|
||||
if ($ct['BaseImage']) echo "<i class='fa fa-cubes' style='margin-right:5px'></i>".htmlspecialchars($ct['BaseImage'])."<br>";
|
||||
echo _('By').": ";
|
||||
@@ -137,27 +189,135 @@ foreach ($containers as $ct) {
|
||||
}
|
||||
echo "</div></td><td class='updatecolumn'>";
|
||||
switch ($updateStatus) {
|
||||
case 0:
|
||||
echo "<span class='green-text' style='white-space:nowrap;'><i class='fa fa-check fa-fw'></i> "._('up-to-date')."</span>";
|
||||
if ($ct['Manager'] == "dockerman")
|
||||
echo "<div class='advanced'><a class='exec' onclick=\"updateContainer('".addslashes(htmlspecialchars($name))."');\"><span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('force update')."</span></a></div>";
|
||||
break;
|
||||
case 0:
|
||||
if ($ct['Manager'] == "dockerman") {
|
||||
echo "<span class='green-text' style='white-space:nowrap;'><i class='fa fa-check fa-fw'></i> "._('up-to-date')."</span>";
|
||||
echo "<div class='advanced'><a class='exec' onclick=\"updateContainer('".addslashes(htmlspecialchars($name))."');\"><span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('force update')."</span></a></div>";
|
||||
} elseif (!empty($composestack)) {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> Compose</span></div>";
|
||||
echo "<span tyle='white-space:nowrap;'><i class='fa fa-check fa-fw'></i> "._('up-to-date')."</span>";
|
||||
} else {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> 3rd Party</span></div>";
|
||||
echo "<span tyle='white-space:nowrap;'><i class='fa fa-check fa-fw'></i> "._('up-to-date')."</span>";
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
echo "<div class='advanced'><span class='orange-text' style='white-space:nowrap;'><i class='fa fa-flash fa-fw'></i> "._('update ready')."</span></div>";
|
||||
if ($ct['Manager'] == "dockerman")
|
||||
echo "<a class='exec' onclick=\"updateContainer('".addslashes(htmlspecialchars($name))."');\"><span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('apply update')."</span></a>";
|
||||
else
|
||||
if ($ct['Manager'] == "dockerman") {
|
||||
echo "<a class='exec' onclick=\"updateContainer('".addslashes(htmlspecialchars($name))."');\"><span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('apply update')."</span></a>";
|
||||
} elseif (!empty($composestack)) {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> Compose</span></a></div>";
|
||||
echo "<span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('update available')."</span>";
|
||||
} else {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> 3rd Party</span></div>";
|
||||
echo "<span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('update available')."</span>";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
echo "<div class='advanced'><span class='orange-text' style='white-space:nowrap;'><i class='fa fa-flash fa-fw'></i> "._('rebuild ready')."</span></div>";
|
||||
echo "<a class='exec'><span style='white-space:nowrap;'><i class='fa fa-recycle fa-fw'></i> "._('rebuilding')."</span></a>";
|
||||
break;
|
||||
default:
|
||||
echo "<span class='orange-text' style='white-space:nowrap;'><i class='fa fa-unlink'></i> "._('not available')."</span>";
|
||||
if ($ct['Manager'] == "dockerman")
|
||||
if ($ct['Manager'] == "dockerman") {
|
||||
echo "<span class='orange-text' style='white-space:nowrap;'><i class='fa fa-unlink'></i> "._('not available')."</span>";
|
||||
echo "<div class='advanced'><a class='exec' onclick=\"updateContainer('".addslashes(htmlspecialchars($name))."');\"><span style='white-space:nowrap;'><i class='fa fa-cloud-download fa-fw'></i> "._('force update')."</span></a></div>";
|
||||
} elseif (!empty($composestack)) {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> Compose</span></div>";
|
||||
echo "<span style='white-space:nowrap;'><i class='fa fa-unlink'></i> "._('not available')."</span>";
|
||||
} else {
|
||||
echo "<div><span><i class='fa fa-docker fa-fw'/></i> 3rd Party</span></div>";
|
||||
echo "<span style='white-space:nowrap;'><i class='fa fa-unlink'></i> "._('not available')."</span>";
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Check if Tailscale for container is enabled by checking if TShostname is set
|
||||
if (!empty($TShostname)) {
|
||||
if ($running) {
|
||||
// Get stats from container and check if they are not empty
|
||||
$TSstats = tailscale_stats($name);
|
||||
if (!empty($TSstats)) {
|
||||
// Construct TSinfo from TSstats
|
||||
$TSinfo = '';
|
||||
if (!$TSstats["Self"]["Online"]) {
|
||||
$TSinfo .= "Online:\t\t❌\nPlease check the logs!";
|
||||
} else {
|
||||
$TS_version = explode('-', $TSstats["Version"])[0];
|
||||
if (!empty($TS_version)) {
|
||||
if (!empty($TS_latest_version)) {
|
||||
if ($TS_version !== $TS_latest_version) {
|
||||
$TSinfo .= "Version:\t\t" . $TS_version . " ➔ " . $TS_latest_version . " available!\n";
|
||||
} else {
|
||||
$TSinfo .= "Version:\t\t" . $TS_version . "\n";
|
||||
}
|
||||
} else {
|
||||
$TSinfo .= "Version:\t\t" . $TS_version . "\n";
|
||||
}
|
||||
}
|
||||
$TSinfo .= "Online:\t\t✅\n";
|
||||
$TS_DNSName = $TSstats["Self"]["DNSName"];
|
||||
$TS_HostNameActual = substr($TS_DNSName, 0, strpos($TS_DNSName, '.'));
|
||||
if (strcasecmp($TS_HostNameActual, $TShostname) !== 0 && !empty($TS_DNSName)) {
|
||||
$TSinfo .= "Hostname:\tReal Hostname ➔ " . $TS_HostNameActual . "\n";
|
||||
} else {
|
||||
$TSinfo .= "Hostname:\t" . $TShostname . "\n";
|
||||
}
|
||||
// Map region relay code to cleartext region if TS_derp_list is available
|
||||
if (!empty($TS_derp_list)) {
|
||||
foreach ($TS_derp_list['Regions'] as $region) {
|
||||
if ($region['RegionCode'] === $TSstats["Self"]["Relay"]) {
|
||||
$TSregion = $region['RegionName'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($TSregion)) {
|
||||
$TSinfo .= "Main Relay:\t" . $TSregion . "\n";
|
||||
} else {
|
||||
$TSinfo .= "Main Relay:\t" . $TSstats["Self"]["Relay"] . "\n";
|
||||
}
|
||||
} else {
|
||||
$TSinfo .= "Main Relay:\t" . $TSstats["Self"]["Relay"] . "\n";
|
||||
}
|
||||
if (!empty($TSstats["Self"]["TailscaleIPs"])) {
|
||||
$TSinfo .= "Addresses:\t" . implode("\n\t\t\t", $TSstats["Self"]["TailscaleIPs"]) . "\n";
|
||||
}
|
||||
if (!empty($TSstats["Self"]["PrimaryRoutes"])) {
|
||||
$TSinfo .= "Routes:\t\t" . implode("\n\t\t\t", $TSstats["Self"]["PrimaryRoutes"]) . "\n";
|
||||
}
|
||||
if ($TSstats["Self"]["ExitNodeOption"]) {
|
||||
$TSinfo .= "Is Exit Node:\t✅\n";
|
||||
} else {
|
||||
if (!empty($TSstats["ExitNodeStatus"])) {
|
||||
$TS_exit_node_status = ($TSstats["ExitNodeStatus"]["Online"]) ? "✅" : "❌";
|
||||
$TSinfo .= "Exit Node:\t" . strstr($TSstats["ExitNodeStatus"]["TailscaleIPs"][0], '/', true) . " | Status: " . $TS_exit_node_status ."\n";
|
||||
} else {
|
||||
$TSinfo .= "Is Exit Node:\t❌\n";
|
||||
}
|
||||
}
|
||||
if (!empty($TSwebGui)) {
|
||||
$TSinfo .= "URL:\t\t" . $TSwebGui . "\n";
|
||||
}
|
||||
if (!empty($TSstats["Self"]["KeyExpiry"])) {
|
||||
$TS_expiry = new DateTime($TSstats["Self"]["KeyExpiry"]);
|
||||
$current_Date = new DateTime();
|
||||
$TS_expiry_formatted = $TS_expiry->format('Y-m-d');
|
||||
$TS_expiry_diff = $current_Date->diff($TS_expiry);
|
||||
if ($TS_expiry_diff->invert) {
|
||||
$TSinfo .= "Key Expiry:\t❌ Expired! Renew/Disable key expiry!\n";
|
||||
} else {
|
||||
$TSinfo .= "Key Expiry:\t" . $TS_expiry_formatted . " (" . $TS_expiry_diff->days . " days)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Display message to refresh page if Tailscale in the container wasn't maybe ready to get the data
|
||||
} else {
|
||||
echo "<div title='Error gathering Tailscale information from container.\nPlease check the logs and refresh the page.'><img src='/plugins/dynamix.docker.manager/images/tailscale.png' style='height: 16px;'> Tailscale</div></td>";
|
||||
}
|
||||
// Display TSinfo if data was fetched correctly
|
||||
echo "<div title='" . $TSinfo . "'><img src='/plugins/dynamix.docker.manager/images/tailscale.png' style='height: 16px;'> Tailscale</div>";
|
||||
// Display message that container isn't running
|
||||
} else {
|
||||
echo "<div title='Container not runnig'><img src='/plugins/dynamix.docker.manager/images/tailscale.png' style='height: 16px;'> Tailscale</div></td>";
|
||||
}
|
||||
}
|
||||
echo "<div class='advanced'><i class='fa fa-info-circle fa-fw'></i> ".compress(_($version),12,0)."</div></td>";
|
||||
echo "<td style='white-space:nowrap'><span class='docker_readmore'> ".implode('<br>',$networks)."</span></td>";
|
||||
@@ -167,7 +327,15 @@ foreach ($containers as $ct) {
|
||||
echo "<td style='word-break:break-all'><span class='docker_readmore'>".implode('<br>',$paths)."</span></td>";
|
||||
echo "<td class='advanced'><span class='cpu-$id'>0%</span><div class='usage-disk mm'><span id='cpu-$id' style='width:0'></span><span></span></div>";
|
||||
echo "<br><span class='mem-$id'>0 / 0</span></td>";
|
||||
echo "<td><input type='checkbox' id='$id-auto' class='autostart' container='".htmlspecialchars($name)."'".($info['autostart'] ? ' checked':'').">";
|
||||
if (empty($composestack)) {
|
||||
if ($ct['Manager'] == "dockerman") {
|
||||
echo "<td><input type='checkbox' id='$id-auto' class='autostart' container='".htmlspecialchars($name)."'".($info['autostart'] ? ' checked':'').">";
|
||||
} else {
|
||||
echo "<td><i class='fa fa-docker fa-fw'/></i> 3rd Party";
|
||||
}
|
||||
} else {
|
||||
echo "<td><i class='fa fa-docker'/></i> Compose";
|
||||
}
|
||||
echo "<span id='$id-wait' style='float:right;display:none'>"._('wait')."<input class='wait' container='".htmlspecialchars($name)."' type='number' value='$wait' placeholder='0' title=\""._('seconds')."\"></span></td>";
|
||||
echo "<td><div style='white-space:nowrap'>".htmlspecialchars(str_replace('Up',_('Uptime').':',my_lang_log($ct['Status'])))."<div style='margin-top:4px'>"._('Created').": ".htmlspecialchars(my_lang_time($ct['Created']))."</div></div></td></tr>";
|
||||
}
|
||||
@@ -182,5 +350,4 @@ foreach ($images as $image) {
|
||||
echo "</td><td>"._('Created')." ".htmlspecialchars(_($image['Created'],0))."</td></tr>";
|
||||
}
|
||||
echo "\0".implode($docker)."\0".(pgrep('rc.docker')!==false ? 1:0);
|
||||
?>
|
||||
|
||||
?>
|
@@ -32,33 +32,65 @@ function xml_decode($string) {
|
||||
return strval(html_entity_decode($string, ENT_XML1, 'UTF-8'));
|
||||
}
|
||||
|
||||
function generateTSwebui($url, $serve, $webUI) {
|
||||
if (!isset($webUI)) {
|
||||
return '';
|
||||
}
|
||||
$webui_url = isset($webUI) ? parse_url($webUI) : '';
|
||||
$webui_port = (preg_match('/\[PORT:(\d+)\]/', $webUI, $matches)) ? ':' . $matches[1] : '';
|
||||
$webui_path = $webui_url['path'] ?? '';
|
||||
$webui_query = isset($webui_url['query']) ? '?' . $webui_url['query'] : '';
|
||||
if (!empty($url)) {
|
||||
if (strpos($url, '[hostname]') !== false || strpos($url, '[noserve]') !== false) {
|
||||
if ($serve === 'serve' || $serve === 'funnel') {
|
||||
return 'https://[hostname][magicdns]' . $webui_path . $webui_query;
|
||||
} elseif ($serve === 'no') {
|
||||
return 'http://[noserve]' . $webui_port . $webui_path . $webui_query;
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
} else {
|
||||
if (!empty($webUI)) {
|
||||
if ($serve === 'serve' || $serve === 'funnel') {
|
||||
return 'https://[hostname][magicdns]' . $webui_path . $webui_query;
|
||||
} elseif ($serve === 'no') {
|
||||
return 'http://[noserve]' . $webui_port . $webui_path . $webui_query;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function postToXML($post, $setOwnership=false) {
|
||||
$dom = new domDocument;
|
||||
$dom->appendChild($dom->createElement("Container"));
|
||||
$xml = simplexml_import_dom($dom);
|
||||
$xml['version'] = 2;
|
||||
$xml->Name = xml_encode(preg_replace('/\s+/', '', $post['contName']));
|
||||
$xml->Repository = xml_encode(trim($post['contRepository']));
|
||||
$xml->Registry = xml_encode(trim($post['contRegistry']));
|
||||
$xml->Network = xml_encode($post['contNetwork']);
|
||||
$xml->MyIP = xml_encode($post['contMyIP']);
|
||||
$xml->Shell = xml_encode($post['contShell']);
|
||||
$xml->Privileged = strtolower($post['contPrivileged']??'')=='on' ? 'true' : 'false';
|
||||
$xml->Support = xml_encode($post['contSupport']);
|
||||
$xml->Project = xml_encode($post['contProject']);
|
||||
$xml->Overview = xml_encode($post['contOverview']);
|
||||
$xml->Category = xml_encode($post['contCategory']);
|
||||
$xml->WebUI = xml_encode(trim($post['contWebUI']));
|
||||
$xml->TemplateURL = xml_encode($post['contTemplateURL']);
|
||||
$xml->Icon = xml_encode(trim($post['contIcon']));
|
||||
$xml->ExtraParams = xml_encode($post['contExtraParams']);
|
||||
$xml->PostArgs = xml_encode($post['contPostArgs']);
|
||||
$xml->CPUset = xml_encode($post['contCPUset']);
|
||||
$xml->DateInstalled = xml_encode(time());
|
||||
$xml->DonateText = xml_encode($post['contDonateText']);
|
||||
$xml->DonateLink = xml_encode($post['contDonateLink']);
|
||||
$xml->Requires = xml_encode($post['contRequires']);
|
||||
|
||||
$xml['version'] = 2;
|
||||
$xml->Name = xml_encode(preg_replace('/\s+/', '', $post['contName']));
|
||||
$xml->Repository = xml_encode(trim($post['contRepository']));
|
||||
$xml->Registry = xml_encode(trim($post['contRegistry']));
|
||||
if (isset($post['netCONT']) && !empty(trim($post['netCONT']))) {
|
||||
$xml->Network = xml_encode($post['contNetwork'].':'.$post['netCONT']);
|
||||
} else {
|
||||
$xml->Network = xml_encode($post['contNetwork']);
|
||||
}
|
||||
$xml->MyIP = xml_encode($post['contMyIP']);
|
||||
$xml->Shell = xml_encode($post['contShell']);
|
||||
$xml->Privileged = strtolower($post['contPrivileged']??'')=='on' ? 'true' : 'false';
|
||||
$xml->Support = xml_encode($post['contSupport']);
|
||||
$xml->Project = xml_encode($post['contProject']);
|
||||
$xml->Overview = xml_encode($post['contOverview']);
|
||||
$xml->Category = xml_encode($post['contCategory']);
|
||||
$xml->WebUI = xml_encode(trim($post['contWebUI']));
|
||||
$xml->TemplateURL = xml_encode($post['contTemplateURL']);
|
||||
$xml->Icon = xml_encode(trim($post['contIcon']));
|
||||
$xml->ExtraParams = xml_encode($post['contExtraParams']);
|
||||
$xml->PostArgs = xml_encode($post['contPostArgs']);
|
||||
$xml->CPUset = xml_encode($post['contCPUset']);
|
||||
$xml->DateInstalled = xml_encode(time());
|
||||
$xml->DonateText = xml_encode($post['contDonateText']);
|
||||
$xml->DonateLink = xml_encode($post['contDonateLink']);
|
||||
$xml->Requires = xml_encode($post['contRequires']);
|
||||
$size = is_array($post['confName']??null) ? count($post['confName']) : 0;
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$Type = $post['confType'][$i];
|
||||
@@ -73,6 +105,31 @@ function postToXML($post, $setOwnership=false) {
|
||||
$config['Required'] = xml_encode($post['confRequired'][$i]);
|
||||
$config['Mask'] = xml_encode($post['confMask'][$i]);
|
||||
}
|
||||
if (isset($post['contTailscale']) && strtolower($post['contTailscale']) == 'on') {
|
||||
$xml->TailscaleEnabled = 'true';
|
||||
$xml->TailscaleIsExitNode = xml_encode($post['TSisexitnode']);
|
||||
$xml->TailscaleHostname = xml_encode($post['TShostname']);
|
||||
$xml->TailscaleExitNodeIP = xml_encode($post['TSexitnodeip']);
|
||||
$xml->TailscaleSSH = xml_encode($post['TSssh']);
|
||||
$xml->TailscaleUserspaceNetworking = xml_encode($post['TSuserspacenetworking']);
|
||||
$xml->TailscaleLANAccess = xml_encode($post['TSallowlanaccess']);
|
||||
$xml->TailscaleServe = xml_encode($post['TSserve']);
|
||||
$xml->TailscaleWebUI = xml_encode(generateTSwebui($post['TSwebui'], $post['TSserve'], $post['contWebUI']));
|
||||
if (isset($post['TSserve']) && strtolower($post['TSserve']) !== 'no') {
|
||||
$xml->TailscaleServePort = xml_encode($post['TSserveport']);
|
||||
$xml->TailscaleServeLocalPath = xml_encode($post['TSservelocalpath']);
|
||||
$xml->TailscaleServeProtocol = xml_encode($post['TSserveprotocol']);
|
||||
$xml->TailscaleServeProtocolPort = xml_encode($post['TSserveprotocolport']);
|
||||
$xml->TailscaleServePath = xml_encode($post['TSservepath']);
|
||||
}
|
||||
$xml->TailscaleDParams = xml_encode($post['TSdaemonparams']);
|
||||
$xml->TailscaleParams = xml_encode($post['TSextraparams']);
|
||||
$xml->TailscaleStateDir = xml_encode($post['TSstatedir']);
|
||||
$xml->TailscaleRoutes = xml_encode($post['TSroutes']);;
|
||||
if (isset($post['TStroubleshooting']) && strtolower($post['TStroubleshooting']) === 'on') {
|
||||
$xml->TailscaleTroubleshooting = 'true';
|
||||
}
|
||||
}
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
@@ -82,29 +139,48 @@ function postToXML($post, $setOwnership=false) {
|
||||
|
||||
function xmlToVar($xml) {
|
||||
global $subnet;
|
||||
$xml = is_file($xml) ? simplexml_load_file($xml) : simplexml_load_string($xml);
|
||||
$out = [];
|
||||
$out['Name'] = preg_replace('/\s+/', '', xml_decode($xml->Name));
|
||||
$out['Repository'] = xml_decode($xml->Repository);
|
||||
$out['Registry'] = xml_decode($xml->Registry);
|
||||
$out['Network'] = xml_decode($xml->Network);
|
||||
$out['MyIP'] = xml_decode($xml->MyIP ?? '');
|
||||
$out['Shell'] = xml_decode($xml->Shell ?? 'sh');
|
||||
$out['Privileged'] = xml_decode($xml->Privileged);
|
||||
$out['Support'] = xml_decode($xml->Support);
|
||||
$out['Project'] = xml_decode($xml->Project);
|
||||
$out['Overview'] = stripslashes(xml_decode($xml->Overview));
|
||||
$out['Category'] = xml_decode($xml->Category);
|
||||
$out['WebUI'] = xml_decode($xml->WebUI);
|
||||
$out['TemplateURL'] = xml_decode($xml->TemplateURL);
|
||||
$out['Icon'] = xml_decode($xml->Icon);
|
||||
$out['ExtraParams'] = xml_decode($xml->ExtraParams);
|
||||
$out['PostArgs'] = xml_decode($xml->PostArgs);
|
||||
$out['CPUset'] = xml_decode($xml->CPUset);
|
||||
$out['DonateText'] = xml_decode($xml->DonateText);
|
||||
$out['DonateLink'] = xml_decode($xml->DonateLink);
|
||||
$out['Requires'] = xml_decode($xml->Requires);
|
||||
$out['Config'] = [];
|
||||
$xml = is_file($xml) ? simplexml_load_file($xml) : simplexml_load_string($xml);
|
||||
$out = [];
|
||||
$out['Name'] = preg_replace('/\s+/', '', xml_decode($xml->Name));
|
||||
$out['Repository'] = xml_decode($xml->Repository);
|
||||
$out['Registry'] = xml_decode($xml->Registry);
|
||||
$out['Network'] = xml_decode($xml->Network);
|
||||
$out['MyIP'] = xml_decode($xml->MyIP ?? '');
|
||||
$out['Shell'] = xml_decode($xml->Shell ?? 'sh');
|
||||
$out['Privileged'] = xml_decode($xml->Privileged);
|
||||
$out['Support'] = xml_decode($xml->Support);
|
||||
$out['Project'] = xml_decode($xml->Project);
|
||||
$out['Overview'] = stripslashes(xml_decode($xml->Overview));
|
||||
$out['Category'] = xml_decode($xml->Category);
|
||||
$out['WebUI'] = xml_decode($xml->WebUI);
|
||||
$out['TemplateURL'] = xml_decode($xml->TemplateURL);
|
||||
$out['Icon'] = xml_decode($xml->Icon);
|
||||
$out['ExtraParams'] = xml_decode($xml->ExtraParams);
|
||||
$out['PostArgs'] = xml_decode($xml->PostArgs);
|
||||
$out['CPUset'] = xml_decode($xml->CPUset);
|
||||
$out['DonateText'] = xml_decode($xml->DonateText);
|
||||
$out['DonateLink'] = xml_decode($xml->DonateLink);
|
||||
$out['Requires'] = xml_decode($xml->Requires);
|
||||
$out['TailscaleEnabled'] = xml_decode($xml->TailscaleEnabled ?? '');
|
||||
$out['TailscaleIsExitNode'] = xml_decode($xml->TailscaleIsExitNode ?? '');
|
||||
$out['TailscaleHostname'] = xml_decode($xml->TailscaleHostname ?? '');
|
||||
$out['TailscaleExitNodeIP'] = xml_decode($xml->TailscaleExitNodeIP ?? '');
|
||||
$out['TailscaleSSH'] = xml_decode($xml->TailscaleSSH ?? '');
|
||||
$out['TailscaleLANAccess'] = xml_decode($xml->TailscaleLANAccess ?? '');
|
||||
$out['TailscaleUserspaceNetworking'] = xml_decode($xml->TailscaleUserspaceNetworking ?? '');
|
||||
$out['TailscaleServe'] = xml_decode($xml->TailscaleServe ?? '');
|
||||
$out['TailscaleServePort'] = xml_decode($xml->TailscaleServePort ?? '');
|
||||
$out['TailscaleServeLocalPath'] = xml_decode($xml->TailscaleServeLocalPath ?? '');
|
||||
$out['TailscaleServeProtocol'] = xml_decode($xml->TailscaleServeProtocol ?? '');
|
||||
$out['TailscaleServeProtocolPort'] = xml_decode($xml->TailscaleServeProtocolPort ?? '');
|
||||
$out['TailscaleServePath'] = xml_decode($xml->TailscaleServePath ?? '');
|
||||
$out['TailscaleWebUI'] = xml_decode($xml->TailscaleWebUI ?? '');
|
||||
$out['TailscaleRoutes'] = xml_decode($xml->TailscaleRoutes ?? '');
|
||||
$out['TailscaleDParams'] = xml_decode($xml->TailscaleDParams ?? '');
|
||||
$out['TailscaleParams'] = xml_decode($xml->TailscaleParams ?? '');
|
||||
$out['TailscaleStateDir'] = xml_decode($xml->TailscaleStateDir ?? '');
|
||||
$out['TailscaleTroubleshooting'] = xml_decode($xml->TailscaleTroubleshooting ?? '');
|
||||
$out['Config'] = [];
|
||||
if (isset($xml->Config)) {
|
||||
foreach ($xml->Config as $config) {
|
||||
$c = [];
|
||||
@@ -132,7 +208,11 @@ function xmlToVar($xml) {
|
||||
$out['Network'] = xml_decode($xml->Networking->Mode);
|
||||
}
|
||||
// check if network exists
|
||||
if (!key_exists($out['Network'],$subnet)) $out['Network'] = 'none';
|
||||
if (preg_match('/^container:(.*)/', $out['Network'])) {
|
||||
$out['Network'] = $out['Network'];
|
||||
} elseif (!key_exists($out['Network'],$subnet)) {
|
||||
$out['Network'] = 'none';
|
||||
}
|
||||
// V1 compatibility
|
||||
if ($xml['version'] != '2') {
|
||||
if (isset($xml->Description)) {
|
||||
@@ -241,7 +321,11 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
$xml = xmlToVar($xml);
|
||||
$cmdName = strlen($xml['Name']) ? '--name='.escapeshellarg($xml['Name']) : '';
|
||||
$cmdPrivileged = strtolower($xml['Privileged'])=='true' ? '--privileged=true' : '';
|
||||
$cmdNetwork = preg_match('/\-\-net(work)?=/',$xml['ExtraParams']) ? "" : '--net='.escapeshellarg(strtolower($xml['Network']));
|
||||
if (preg_match('/^container:(.*)/', $xml['Network'])) {
|
||||
$cmdNetwork = preg_match('/\-\-net(work)?=/',$xml['ExtraParams']) ? "" : '--net='.escapeshellarg($xml['Network']);
|
||||
} else {
|
||||
$cmdNetwork = preg_match('/\-\-net(work)?=/',$xml['ExtraParams']) ? "" : '--net='.escapeshellarg(strtolower($xml['Network']));
|
||||
}
|
||||
$cmdMyIP = '';
|
||||
foreach (explode(' ',str_replace(',',' ',$xml['MyIP'])) as $myIP) if ($myIP) $cmdMyIP .= (strpos($myIP,':')?'--ip6=':'--ip=').escapeshellarg($myIP).' ';
|
||||
$cmdCPUset = strlen($xml['CPUset']) ? '--cpuset-cpus='.escapeshellarg($xml['CPUset']) : '';
|
||||
@@ -254,7 +338,7 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
$Variables[] = 'TZ="'.$var['timeZone'].'"';
|
||||
// Add HOST_OS variable
|
||||
$Variables[] = 'HOST_OS="Unraid"';
|
||||
// Add HOST_HOSTNAME variable
|
||||
// Add HOST_HOSTNAME variable
|
||||
$Variables[] = 'HOST_HOSTNAME="'.$var['NAME'].'"';
|
||||
// Add HOST_CONTAINERNAME variable
|
||||
$Variables[] = 'HOST_CONTAINERNAME="'.$xml['Name'].'"';
|
||||
@@ -263,6 +347,68 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
if (strlen($xml['WebUI'])) $Labels[] = 'net.unraid.docker.webui='.escapeshellarg($xml['WebUI']);
|
||||
if (strlen($xml['Icon'])) $Labels[] = 'net.unraid.docker.icon='.escapeshellarg($xml['Icon']);
|
||||
|
||||
// Initialize Tailscale variables
|
||||
$TS_entrypoint = '';
|
||||
$TS_hook = '';
|
||||
$TS_hostname = '';
|
||||
$TS_hostname_label = '';
|
||||
$TS_ssh = '';
|
||||
$TS_tundev = '';
|
||||
$TS_cap = '';
|
||||
$TS_exitnode = '';
|
||||
$TS_exitnode_ip = '';
|
||||
$TS_lan_access = '';
|
||||
$TS_userspace_networking = '';
|
||||
$TS_daemon_params = '';
|
||||
$TS_extra_params = '';
|
||||
$TS_state_dir = '';
|
||||
$TS_serve_funnel = '';
|
||||
$TS_serve_port = '';
|
||||
$TS_serve_local_path = '';
|
||||
$TS_serve_protocol = '';
|
||||
$TS_serve_protocol_port = '';
|
||||
$TS_serve_path = '';
|
||||
$TS_web_ui = '';
|
||||
$TS_troubleshooting = '';
|
||||
$TS_routes = '';
|
||||
$TS_postargs = '';
|
||||
// Get all information from xml and create variables for cmd
|
||||
if ($xml['TailscaleEnabled'] == 'true') {
|
||||
$TS_entrypoint = '--entrypoint=\'/opt/unraid/tailscale\'';
|
||||
$TS_hook = '-v \'/usr/local/share/docker/tailscale_container_hook\':\'/opt/unraid/tailscale\'';
|
||||
$TS_hostname = !empty($xml['TailscaleHostname']) ? '-e TAILSCALE_HOSTNAME=' . escapeshellarg($xml['TailscaleHostname']) : '';
|
||||
$TS_hostname_label = !empty($xml['TailscaleHostname']) ? '-l net.unraid.docker.tailscale.hostname=' . escapeshellarg($xml['TailscaleHostname']) : '';
|
||||
$TS_ssh = !empty($xml['TailscaleSSH']) ? '-e TAILSCALE_USE_SSH=' . escapeshellarg($xml['TailscaleSSH']) : '';
|
||||
$TS_daemon_params = !empty($xml['TailscaleDParams']) ? '-e TAILSCALED_PARAMS=' . escapeshellarg($xml['TailscaleDParams']) : '';
|
||||
$TS_extra_params = !empty($xml['TailscaleParams']) ? '-e TAILSCALE_PARAMS=' . escapeshellarg($xml['TailscaleParams']) : '';
|
||||
$TS_state_dir = !empty($xml['TailscaleStateDir']) ? '-e TAILSCALE_STATE_DIR=' . escapeshellarg($xml['TailscaleStateDir']) : '';
|
||||
$TS_userspace_networking = !empty($xml['TailscaleUserspaceNetworking']) ? '-e TAILSCALE_USERSPACE_NETWORKING=' . escapeshellarg($xml['TailscaleUserspaceNetworking']) : '';
|
||||
// Only add tun, cap and specific vairables to containers which are defined as Exit Nodes and Userspace Networking disabled
|
||||
if (_var($xml,'TailscaleIsExitNode') == 'true') {
|
||||
$TS_tundev = preg_match('/--d(evice)?[= ](\'?\/dev\/net\/tun\'?)/', $xml['ExtraParams']) ? "" : "--device='/dev/net/tun'";
|
||||
$TS_cap = preg_match('/--cap\-add=NET_ADMIN/', $xml['ExtraParams']) ? "" : "--cap-add=NET_ADMIN";
|
||||
$TS_exitnode = '-e TAILSCALE_EXIT_NODE=true';
|
||||
} elseif (_var($xml,'TailscaleUserspaceNetworking') == 'false') {
|
||||
$TS_tundev = preg_match('/--d(evice)?[= ](\'?\/dev\/net\/tun\'?)/', $xml['ExtraParams']) ? "" : "--device='/dev/net/tun'";
|
||||
$TS_cap = preg_match('/--cap\-add=NET_ADMIN/', $xml['ExtraParams']) ? "" : "--cap-add=NET_ADMIN";
|
||||
$TS_lan_access = '-e TAILSCALE_ALLOW_LAN_ACCESS=' . escapeshellarg($xml['TailscaleLANAccess']);
|
||||
$TS_exitnode_ip = !empty($xml['TailscaleExitNodeIP']) ? '-e TAILSCALE_EXIT_NODE_IP=' . escapeshellarg($xml['TailscaleExitNodeIP']) : '';
|
||||
}
|
||||
$TS_serve_funnel = ($xml['TailscaleServe'] == 'funnel') ? '-e TAILSCALE_FUNNEL=true' : '';
|
||||
$TS_serve_port = !empty($xml['TailscaleServePort']) ? '-e TAILSCALE_SERVE_PORT=' . escapeshellarg($xml['TailscaleServePort']) : '';
|
||||
$TS_serve_local_path = !empty($xml['TailscaleServeLocalPath']) ? '-e TAILSCALE_SERVE_LOCALPATH=' . escapeshellarg($xml['TailscaleServeLocalPath']) : '';
|
||||
$TS_serve_protocol = !empty($xml['TailscaleServeProtocol']) ? '-e TAILSCALE_SERVE_PROTOCOL=' . escapeshellarg($xml['TailscaleServeProtocol']) : '';
|
||||
$TS_serve_protocol_port = !empty($xml['TailscaleServeProtocolPort']) ? '-e TAILSCALE_SERVE_PROTOCOL_PORT=' . escapeshellarg($xml['TailscaleServeProtocolPort']) : '';
|
||||
$TS_serve_path = !empty($xml['TailscaleServePath']) ? '-e TAILSCALE_SERVE_PATH=' . escapeshellarg($xml['TailscaleServePath']) : '';
|
||||
$TS_web_ui = !empty($xml['TailscaleWebUI']) ? '-l net.unraid.docker.tailscale.webui=' . escapeshellarg($xml['TailscaleWebUI']) : '';
|
||||
$TS_troubleshooting = !empty($xml['TailscaleTroubleshooting']) ? '-e TAILSCALE_TROUBLESHOOTING=' . escapeshellarg($xml['TailscaleTroubleshooting']) : '';
|
||||
$TS_routes = !empty($xml['TailscaleRoutes']) ? '-e TAILSCALE_ADVERTISE_ROUTES=' . escapeshellarg($xml['TailscaleRoutes']) : '';
|
||||
if (!empty($xml['PostArgs'])) {
|
||||
$TS_postargs = '-e ORG_POSTARGS=' . escapeshellarg($xml['PostArgs']);
|
||||
$xml['PostArgs'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($xml['Config'] as $key => $config) {
|
||||
$confType = strtolower(strval($config['Type']));
|
||||
$hostConfig = strlen($config['Value']) ? $config['Value'] : $config['Default'];
|
||||
@@ -320,8 +466,8 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
$pid_limit = "";
|
||||
}
|
||||
|
||||
$cmd = sprintf($docroot.'/plugins/dynamix.docker.manager/scripts/docker create %s %s %s %s %s %s %s %s %s %s %s %s %s %s',
|
||||
$cmdName, $cmdNetwork, $cmdMyIP, $cmdCPUset, $pid_limit, $cmdPrivileged, implode(' -e ', $Variables), implode(' -l ', $Labels), implode(' -p ', $Ports), implode(' -v ', $Volumes), implode(' --device=', $Devices), $xml['ExtraParams'], escapeshellarg($xml['Repository']), $xml['PostArgs']);
|
||||
$cmd = sprintf($docroot.'/plugins/dynamix.docker.manager/scripts/docker create %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s',
|
||||
$cmdName, $TS_entrypoint, $cmdNetwork, $cmdMyIP, $cmdCPUset, $pid_limit, $cmdPrivileged, implode(' -e ', $Variables), $TS_hostname, $TS_exitnode, $TS_exitnode_ip, $TS_lan_access, $TS_routes, $TS_ssh, $TS_userspace_networking, $TS_serve_funnel, $TS_serve_port, $TS_serve_local_path, $TS_serve_protocol, $TS_serve_protocol_port, $TS_serve_path, $TS_daemon_params, $TS_extra_params, $TS_state_dir, $TS_troubleshooting, $TS_postargs, implode(' -l ', $Labels), $TS_web_ui, $TS_hostname_label, implode(' -p ', $Ports), implode(' -v ', $Volumes), $TS_hook, $TS_cap, $TS_tundev, implode(' --device=', $Devices), $xml['ExtraParams'], escapeshellarg($xml['Repository']), $xml['PostArgs']);
|
||||
return [preg_replace('/\s\s+/', ' ', $cmd), $xml['Name'], $xml['Repository']];
|
||||
}
|
||||
function stopContainer($name, $t=false, $echo=true) {
|
||||
@@ -508,7 +654,7 @@ function setXmlVal(&$xml, $value, $el, $attr=null, $pos=0) {
|
||||
|
||||
function getAllocations() {
|
||||
global $DockerClient, $host;
|
||||
|
||||
|
||||
$ports = [];
|
||||
foreach ($DockerClient->getDockerContainers() as $ct) {
|
||||
$list = $port = [];
|
||||
|
@@ -1,10 +1,11 @@
|
||||
var eventURL = '/plugins/dynamix.docker.manager/include/Events.php';
|
||||
|
||||
function addDockerContainerContext(container, image, template, started, paused, update, autostart, webui, shell, id, Support, Project, Registry, donateLink, ReadMe) {
|
||||
function addDockerContainerContext(container, image, template, started, paused, update, autostart, webui, tswebui, shell, id, Support, Project, Registry, donateLink, ReadMe) {
|
||||
var opts = [];
|
||||
context.settings({right:false,above:false});
|
||||
if (started && !paused) {
|
||||
if (webui !== '' && webui != '#') opts.push({text:_('WebUI'), icon:'fa-globe', href:webui, target:'_blank'});
|
||||
if (tswebui !== '' && tswebui != '#') opts.push({text:_('Tailscale WebUI'), icon:'fa-globe', href:tswebui, target:'_blank'});
|
||||
opts.push({text:_('Console'), icon:'fa-terminal', action:function(e){e.preventDefault(); openTerminal('docker',container,shell);}});
|
||||
opts.push({divider:true});
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ $_SERVER['REQUEST_URI'] = "scripts";
|
||||
$login_locale = _var($display,'locale');
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
exec("pgrep docker", $pid);
|
||||
exec('pgrep --ns $$ docker', $pid);
|
||||
if (count($pid) == 1) exit(0);
|
||||
|
||||
$DockerClient = new DockerClient();
|
||||
|
@@ -170,6 +170,7 @@ foreach (explode('*',rawurldecode($argv[1])) as $value) {
|
||||
$xml = file_get_contents($tmpl);
|
||||
[$cmd, $Name, $Repository] = xmlToCommand($tmpl);
|
||||
$Registry = getXmlVal($xml, "Registry");
|
||||
$TS_Enabled = getXmlVal($xml, "TailscaleEnabled");
|
||||
$oldImageID = $DockerClient->getImageID($Repository);
|
||||
// pull image
|
||||
if (!pullImage_nchan($Name, $Repository)) continue;
|
||||
@@ -182,14 +183,25 @@ foreach (explode('*',rawurldecode($argv[1])) as $value) {
|
||||
// attempt graceful stop of container first
|
||||
stopContainer_nchan($Name);
|
||||
}
|
||||
if ( ($argv[2]??null) == "ca_docker_run_override" )
|
||||
if ( ($argv[2]??null) == "ca_docker_run_override" )
|
||||
$startContainer = true;
|
||||
|
||||
if ( $startContainer )
|
||||
$cmd = str_replace('/docker create ', '/docker run -d ', $cmd);
|
||||
|
||||
// force kill container if still running after 10 seconds
|
||||
if (empty($_GET['communityApplications'])) removeContainer_nchan($Name);
|
||||
// Extract real Entrypoint and Cmd from container for Tailscale
|
||||
if ($TS_Enabled == 'true') {
|
||||
// Create preliminary base container but don't run it
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker create --name '" . escapeshellarg($Name) . "' '" . escapeshellarg($Repository) . "'");
|
||||
// Get Entrypoint and Cmd from docker inspect
|
||||
$containerInfo = $DockerClient->getContainerDetails($Name);
|
||||
$ts_env = isset($containerInfo['Config']['Entrypoint']) ? '-e ORG_ENTRYPOINT="' . implode(' ', $containerInfo['Config']['Entrypoint']) . '" ' : '';
|
||||
$ts_env .= isset($containerInfo['Config']['Cmd']) ? '-e ORG_CMD="' . implode(' ', $containerInfo['Config']['Cmd']) . '" ' : '';
|
||||
// Insert Entrypoint and Cmd to docker command
|
||||
$cmd = str_replace('-l net.unraid.docker.managed=dockerman', $ts_env . '-l net.unraid.docker.managed=dockerman' , $cmd);
|
||||
// Remove preliminary container
|
||||
exec("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker rm '" . escapeshellarg($Name) . "'");
|
||||
}
|
||||
execCommand_nchan($cmd);
|
||||
if ($startContainer) addRoute($Name); // add route for remote WireGuard access
|
||||
$DockerClient->flushCaches();
|
||||
|
@@ -19,7 +19,7 @@ Code="e944"
|
||||
?>
|
||||
<?
|
||||
// Remove stale /tmp/plugin/*.plg entries (check that script 'plugin' is not running to avoid clashes)
|
||||
if (!exec("pgrep -f $docroot/plugins/dynamix.plugin.manager/scripts/plugin")) {
|
||||
if (!exec('pgrep --ns $$ -f '."$docroot/plugins/dynamix.plugin.manager/scripts/plugin")) {
|
||||
foreach (glob("/tmp/plugins/*.{plg,txt}", GLOB_NOSORT+GLOB_BRACE) as $entry) if (!file_exists("/var/log/plugins/".basename($entry))) @unlink($entry);
|
||||
}
|
||||
$check = $notify['version'] ? 0 : 1;
|
||||
|
@@ -910,9 +910,9 @@
|
||||
}
|
||||
|
||||
if ($gpu['multi'] == "on"){
|
||||
$newgpu_bus= 0x10;
|
||||
$newgpu_bus= 0x07;
|
||||
if (!isset($multibus[$newgpu_bus])) {
|
||||
$multibus[$newgpu_bus] = 0x10;
|
||||
$multibus[$newgpu_bus] = 0x07;
|
||||
} else {
|
||||
#Get next bus
|
||||
$newgpu_bus = end($multibus) + 0x01;
|
||||
@@ -2004,8 +2004,17 @@
|
||||
if (is_file($cfg)) unlink($cfg);
|
||||
if (is_file($xml)) unlink($xml);
|
||||
if (is_dir($dir) && $this->is_dir_empty($dir)) {
|
||||
$error = my_rmdir($dir);
|
||||
qemu_log("$domain","delete empty $dir $error");
|
||||
$result= my_rmdir($dir);
|
||||
if ($result['type'] == "zfs") {
|
||||
qemu_log("$domain","delete empty zfs $dir {$result['rtncode']}");
|
||||
if (isset($result['dataset'])) qemu_log("$domain","dataset {$result['dataset']} ");
|
||||
if (isset($result['cmd'])) qemu_log("$domain","Command {$result['cmd']} ");
|
||||
if (isset($result['output'])) {
|
||||
$outputlogs = implode(" ",$result['output']);
|
||||
qemu_log("$domain","Output $outputlogs end");
|
||||
}
|
||||
}
|
||||
else qemu_log("$domain","delete empty $dir {$result['rtncode']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1115,6 +1115,7 @@ private static $encoding = 'UTF-8';
|
||||
$arrValidVNCModels = [
|
||||
'cirrus' => 'Cirrus',
|
||||
'qxl' => 'QXL (best)',
|
||||
'virtio' => 'Virtio(2d)',
|
||||
'vmvga' => 'vmvga'
|
||||
];
|
||||
|
||||
|
@@ -80,8 +80,8 @@ while (true) {
|
||||
$echodata .= my_scale($vmdata['mem']*1024,$unit)."$unit / ".my_scale($vmdata['curmem']*1024,$unit)."$unit";
|
||||
if ($vmdata['curmem'] === $vmdata['maxmem']) $echodata .= " </td><td>";
|
||||
else $echodata .= " / " .my_scale($vmdata['maxmem']*1024,$unit)."$unit </td><td>";
|
||||
$echodata .= _("Read").": ".my_scale($vmdata['rdrate'],$unit)."$unit/s<br>"._("Write").": ".my_scale($vmdata['wrrate'],$unit)."$unit/s</td><td>";
|
||||
$echodata .= _("RX").": ".my_scale($vmdata['rxrate'],$unit)."$unit/s<br>"._("TX").": ".my_scale($vmdata['txrate'],$unit)."$unit/s</td></tr>";
|
||||
$echodata .= _("Read").": ".my_scale($vmdata['rdrate']/$timer,$unit)."$unit/s<br>"._("Write").": ".my_scale($vmdata['wrrate']/$timer,$unit)."$unit/s</td><td>";
|
||||
$echodata .= _("RX").": ".my_scale($vmdata['rxrate']/$timer,$unit)."$unit/s<br>"._("TX").": ".my_scale($vmdata['txrate']/$timer,$unit)."$unit/s</td></tr>";
|
||||
}
|
||||
$echo = $echodata ;
|
||||
}
|
||||
|
@@ -27,7 +27,9 @@
|
||||
}
|
||||
# Check if options file exists. Each option should be on a new line.
|
||||
if (is_file($file)) $options = explode("\n",file_get_contents($file)) ; else $options = ['--syslog','--inode-file-handles=mandatory','--announce-submounts'];
|
||||
$options[] = "--fd=".$argoptions['fd'];
|
||||
if (isset($argoptions['fd'])) {
|
||||
$options[] = "--fd=".$argoptions['fd'];
|
||||
}
|
||||
|
||||
if (isset($argoptions['o'])) {
|
||||
$virtiofsoptions = explode(',',$argoptions["o"]);
|
||||
|
@@ -317,6 +317,18 @@
|
||||
}
|
||||
if ($usertemplate == 1) unset($arrConfig['domain']['uuid']);
|
||||
$xml2 = build_xml_templates($strXML);
|
||||
#disable rename if snapshots exist
|
||||
$snapshots = getvmsnapshots($arrConfig['domain']['name']) ;
|
||||
if ($snapshots != null && count($snapshots) && !$boolNew)
|
||||
{
|
||||
$snaprenamehidden = "";
|
||||
$namedisable = "disabled";
|
||||
$snapcount = count($snapshots);
|
||||
} else {
|
||||
$snaprenamehidden = "hidden";
|
||||
$namedisable = "";
|
||||
$snapcount = "0";
|
||||
};
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="<?autov('/plugins/dynamix.vm.manager/scripts/codemirror/lib/codemirror.css')?>">
|
||||
@@ -336,10 +348,12 @@
|
||||
<input type="hidden" name="domain[memoryBacking]" id="domain_memorybacking" value="<?=htmlspecialchars($arrConfig['domain']['memoryBacking'])?>">
|
||||
|
||||
<table>
|
||||
<tr><td></td><td><span hidden id="zfs-name" class="orange-text"><i class="fa fa-warning"></i> _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location<br>Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_</span></td></tr>
|
||||
<tr><td></td><td>
|
||||
<span <?=$snaprenamehidden?> id="snap-rename" class="orange-text"><i class="fa fa-warning"></i> _(Rename disabled, <?=$snapcount?> snapshot(s) exists.)_</span>
|
||||
<span hidden id="zfs-name" class="orange-text"><i class="fa fa-warning"></i> _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location<br>Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_</span></td></tr>
|
||||
<tr>
|
||||
<td>_(Name)_:</td>
|
||||
<td><input type="text" name="domain[name]" id="domain_name" oninput="checkName(this.value)" class="textTemplate" title="_(Name of virtual machine)_" placeholder="_(e.g.)_ _(My Workstation)_" value="<?=htmlspecialchars($arrConfig['domain']['name'])?>" required /></td>
|
||||
<td><input <?=$namedisable?> type="text" name="domain[name]" id="domain_name" oninput="checkName(this.value)" class="textTemplate" title="_(Name of virtual machine)_" placeholder="_(e.g.)_ _(My Workstation)_" value="<?=htmlspecialchars($arrConfig['domain']['name'])?>" required /></td>
|
||||
<td><textarea class="xml" id="xmlname" rows=1 disabled ><?=htmlspecialchars($xml2['name'])."\n".htmlspecialchars($xml2['uuid'])."\n".htmlspecialchars($xml2['metadata'])?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@@ -23,7 +23,7 @@ function installPlugin(file) {
|
||||
<div class="notice">_(Click **Install** to download and install the **Community Applications** plugin)_</div>
|
||||
|
||||
<form markdown="1" name="ca_install" method="POST" target="progressFrame">
|
||||
<input type="hidden" name="file" value="https://raw.githubusercontent.com/Squidly271/community.applications/master/plugins/community.applications.plg">
|
||||
<input type="hidden" name="file" value="https://ca.unraid.net/dl/https://raw.githubusercontent.com/Squidly271/community.applications/master/plugins/community.applications.plg">
|
||||
|
||||
|
||||
: <input type="button" value="_(Install)_" onclick="installPlugin(this.form.file.value)">
|
||||
|
@@ -69,7 +69,7 @@ $cache_type = $cache_rate = [];
|
||||
|
||||
$parity = _var($var,'mdResync');
|
||||
$mover = file_exists('/var/run/mover.pid');
|
||||
$btrfs = exec('pgrep -cf /sbin/btrfs');
|
||||
$btrfs = exec('pgrep --ns $$ -cf /sbin/btrfs');
|
||||
$vdisk = exec("grep -Pom1 '^DOCKER_IMAGE_TYPE=\"\\K[^\"]+' /boot/config/docker.cfg 2>/dev/null")!='folder' ? _('Docker vdisk') : _('Docker folder');
|
||||
$dot = _var($display,'number','.,')[0];
|
||||
$zfs = count(array_filter(array_column($disks,'fsType'),function($fs){return str_replace('luks:','',$fs??'')=='zfs';}));
|
||||
|
@@ -17,7 +17,6 @@ Tag="hdd-o"
|
||||
<?
|
||||
require_once "$docroot/webGui/include/Preselect.php";
|
||||
|
||||
$subpool_name = isSubpool($name) ? isSubpool($name) : '';
|
||||
$unassigned = array_key_exists($name,$devs);
|
||||
$disk = $disks[$name] ?? $devs[$name] ?? [];
|
||||
$dev = _var($disk,'device');
|
||||
@@ -27,6 +26,22 @@ $days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Satu
|
||||
$sheets = [];
|
||||
$i = $n = 0;
|
||||
|
||||
function hasSubpools($name) {
|
||||
global $disks, $subpools;
|
||||
foreach ($subpools as $subpool) {
|
||||
$index = "$name~$subpool";
|
||||
if (isset($disks[$index])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!isSubpool($name)) {
|
||||
$fsTypeImmutable = !(_var($var,'fsState')=='Stopped' && !hasSubpools($name) && (empty(_var($disk,'uuid')) || _var($disk,'slots',1)==1));
|
||||
$fsProfileImmutable = $fsTypeImmutable;
|
||||
} else {
|
||||
$fsTypeImmutable = true;
|
||||
$fsProfileImmutable = !(_var($var,'fsState')=='Stopped' && empty(_var($disk,'fsGroups','1')));
|
||||
}
|
||||
|
||||
foreach ($disks as $sheet) {
|
||||
if (_var($sheet,'type')=="Flash" || _var($sheet,'color')=="grey-off" || empty($sheet['name'])) continue;
|
||||
$sheets[] = $sheet['name'];
|
||||
@@ -45,7 +60,6 @@ $prev = $i>0 ? $sheets[$i-1] : $sheets[$end];
|
||||
$next = $i<$end ? $sheets[$i+1] : $sheets[0];
|
||||
$textErase = isPool($name) ? _('This will ERASE content of ALL devices in the pool') : _('This will ERASE ALL device content');
|
||||
$textDelete = _('This will unassign all devices from the pool but will NOT modify any device contents');
|
||||
$fsTypeImmutable = !(_var($var,'fsState')=='Stopped' && (empty(_var($disk,'uuid')) || _var($disk,'slots',1)==1));
|
||||
|
||||
function disabled_if($condition) {
|
||||
if ($condition !== false) echo ' disabled';
|
||||
@@ -200,7 +214,7 @@ function prepareZFS(form) {
|
||||
}
|
||||
<?endif;?>
|
||||
|
||||
function selectDiskFsWidth(slots) {
|
||||
function setDiskFsWidth(slots) {
|
||||
$('#diskFsWidth').empty();
|
||||
$('#diskFsWidth').append($('<option>', {value: slots, text:''}));
|
||||
$('#diskFsWidth').val(slots);
|
||||
@@ -210,9 +224,15 @@ function selectDiskFsProfileAuto() {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: '', text:''}));
|
||||
$('#diskFsProfile').val('');
|
||||
selectDiskFsWidth('');
|
||||
setDiskFsWidth('');
|
||||
}
|
||||
function selectDiskFsProfileBTRFS(slots,set_default) {
|
||||
function selectDiskFsProfileXFS() {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: '', text:''}));
|
||||
$('#diskFsProfile').val('');
|
||||
setDiskFsWidth(1);
|
||||
}
|
||||
function selectDiskFsProfileBTRFS(slots,init) {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: 'single', text:_('single')}));
|
||||
if (slots >= 2) $('#diskFsProfile').append($('<option>', {value: 'raid0', text:_('raid0')}));
|
||||
@@ -222,15 +242,16 @@ function selectDiskFsProfileBTRFS(slots,set_default) {
|
||||
if (slots >= 4) $('#diskFsProfile').append($('<option>', {value: 'raid10', text:_('raid10')}));
|
||||
if (slots >= 3) $('#diskFsProfile').append($('<option>', {value: 'raid5', text:_('raid5')}));
|
||||
if (slots >= 4) $('#diskFsProfile').append($('<option>', {value: 'raid6', text:_('raid6')}));
|
||||
if (set_default) {
|
||||
if (slots == 1) $('#diskFsProfile').val('');
|
||||
if (slots > 1) $('#diskFsProfile').val('raid1');
|
||||
} else {
|
||||
if (init) {
|
||||
$('#diskFsProfile').val("<?=_var($disk,'fsProfile')?>");
|
||||
} else {
|
||||
if (slots == 1) $('#diskFsProfile').val('');
|
||||
if (slots >= 2) $('#diskFsProfile').val('raid1');
|
||||
}
|
||||
selectDiskFsWidth(slots);
|
||||
setDiskFsWidth(slots);
|
||||
}
|
||||
function selectDiskFsWidthZFS(slots) {
|
||||
function selectDiskFsWidthZFS(slots,init) {
|
||||
var selected_width = init ? Number("<?=_var($disk,'fsWidth')?>") : 0;
|
||||
$('#diskFsWidth').empty();
|
||||
if ($('#diskFsProfile').val() == '') {
|
||||
var label = (slots == 1) ? "device" : "devices";
|
||||
@@ -238,16 +259,18 @@ function selectDiskFsWidthZFS(slots) {
|
||||
value: 1,
|
||||
text: _(sprintf('%s '+label,slots))
|
||||
}));
|
||||
if (selected_width == 0) selected_width = 1;
|
||||
} else if ($('#diskFsProfile').val() == 'mirror') {
|
||||
var width;
|
||||
for (width=2; width<=Math.min(slots,4); width++) {
|
||||
if ((slots % width) == 0) {
|
||||
var groups = slots / width;
|
||||
var label = (groups == 1) ? "group" : "groups";
|
||||
var label = (groups == 1) ? "vdev" : "vdevs";
|
||||
$('#diskFsWidth').append($('<option>', {
|
||||
value: width,
|
||||
text: _(sprintf('%s '+label+' of %s devices',groups,width)),
|
||||
}));
|
||||
if (selected_width == 0) selected_width = width;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -258,20 +281,22 @@ function selectDiskFsWidthZFS(slots) {
|
||||
for (width=min_width; width<=slots; width++) {
|
||||
if ((slots % width) == 0) {
|
||||
var groups = slots / width;
|
||||
var label = (groups == 1) ? "group" : "groups";
|
||||
var label = (groups == 1) ? "vdev" : "vdevs";
|
||||
$('#diskFsWidth').append($('<option>', {
|
||||
value: width,
|
||||
text: _(sprintf('%s '+label+' of %s devices',groups,width)),
|
||||
}));
|
||||
if (selected_width == 0) selected_width = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#diskFsWidth').val(selected_width);
|
||||
}
|
||||
function selectDiskFsProfileZFS(slots,set_default,subpool) {
|
||||
function selectDiskFsProfileZFS(slots,init,subpool) {
|
||||
$('#diskFsProfile').empty();
|
||||
if (slots == 1) $('#diskFsProfile').append($('<option>', {value: '', text: _('single')}));
|
||||
if (slots >= 2) $('#diskFsProfile').append($('<option>', {value: '', text: _('stripe')}));
|
||||
if (subpool != 'cache' && subpool != 'spare') {
|
||||
if (subpool != 'cache' && subpool != 'spares') {
|
||||
if (slots%2 == 0 || slots%3 == 0 || slots%4 == 0) $('#diskFsProfile').append($('<option>', {value: 'mirror', text: _('mirror')}));
|
||||
if (subpool == '') {
|
||||
if (slots >= 3 && subpool == '') $('#diskFsProfile').append($('<option>', {value: 'raidz1', text: _('raidz1')}));
|
||||
@@ -279,47 +304,33 @@ function selectDiskFsProfileZFS(slots,set_default,subpool) {
|
||||
if (slots >= 4 && subpool == '') $('#diskFsProfile').append($('<option>', {value: 'raidz3', text: _('raidz3')}));
|
||||
}
|
||||
}
|
||||
if (set_default) {
|
||||
if (init) {
|
||||
$('#diskFsProfile').val("<?=_var($disk,'fsProfile')?>");
|
||||
} else {
|
||||
if (slots == 1) $('#diskFsProfile').val('');
|
||||
if (slots == 2) $('#diskFsProfile').val('mirror');
|
||||
if (slots > 2) $('#diskFsProfile').val('raidz1');
|
||||
selectDiskFsWidthZFS(slots);
|
||||
$('#diskFsWidth').val(slots);
|
||||
} else {
|
||||
$('#diskFsProfile').val("<?=_var($disk,'fsProfile')?>");
|
||||
selectDiskFsWidthZFS(slots);
|
||||
$('#diskFsWidth').val(<?=_var($disk,'fsWidth')?>);
|
||||
if (slots >= 3) $('#diskFsProfile').val('raidz1');
|
||||
}
|
||||
selectDiskFsWidthZFS(slots,init);
|
||||
$('#diskFsProfile').on('change', function() {
|
||||
selectDiskFsWidthZFS(slots);
|
||||
selectDiskFsWidthZFS(slots,false);
|
||||
});
|
||||
}
|
||||
function selectDiskFsProfileXFS() {
|
||||
$('#diskFsProfile').empty();
|
||||
$('#diskFsProfile').append($('<option>', {value: '', text:''}));
|
||||
$('#diskFsProfile').val('');
|
||||
selectDiskFsWidth(1);
|
||||
}
|
||||
/* called upon page load (init==true) and when user changes file system type (init==false) */
|
||||
function selectDiskFsProfile(init) {
|
||||
var t = init ? null : 'slow';
|
||||
|
||||
/* for array disks, 'slots', 'fsWidth', and 'fsGroups' is not defined so assume value 1 for all three */
|
||||
<?if ($fsTypeImmutable):?>
|
||||
var slots = <?=_var($disk,'fsWidth',1) * _var($disk,'fsGroups',1)?>;
|
||||
<?else:?>
|
||||
var slots = <?=_var($disk,'slots',1)?>;
|
||||
<?endif;?>
|
||||
/* for array disks, 'slots', 'fsWidth', and 'fsGroups' is not defined */
|
||||
var slots = Number("<?=_var($disk,'fsWidth',1)?>") * Number("<?=_var($disk,'fsGroups',1)?>");
|
||||
if (slots == 0) slots = <?=_var($disk,'slots',1)?>;
|
||||
|
||||
var subpool = "<?=$subpool_name?>";
|
||||
var subpool = "<?=isSubpool($name) ?: ''?>";
|
||||
var fsType;
|
||||
var set_default;
|
||||
|
||||
if (subpool == '') {
|
||||
fsType = init ? "<?=_var($disk,'fsType','')?>" : $('#diskFsType').val();
|
||||
set_default = fsType != "<?=_var($disk,'fsType','')?>";
|
||||
} else {
|
||||
fsType = 'zfs';
|
||||
set_default = false;
|
||||
}
|
||||
|
||||
if (slots == 1 || fsType == 'auto') {
|
||||
@@ -327,8 +338,14 @@ function selectDiskFsProfile(init) {
|
||||
} else {
|
||||
$('#profile').show(t);
|
||||
if (fsType.indexOf('zfs') != -1) {
|
||||
if (subpool != 'cache' && subpool != 'spares') {
|
||||
$('#diskFsProfile').show();
|
||||
} else {
|
||||
$('#diskFsProfile').hide();
|
||||
}
|
||||
$('#diskFsWidth').show();
|
||||
} else {
|
||||
$('#diskFsProfile').show();
|
||||
$('#diskFsWidth').hide()
|
||||
}
|
||||
}
|
||||
@@ -336,9 +353,9 @@ function selectDiskFsProfile(init) {
|
||||
if (fsType == 'auto') {
|
||||
selectDiskFsProfileAuto();
|
||||
} else if (fsType.indexOf('btrfs') != -1) {
|
||||
selectDiskFsProfileBTRFS(slots,set_default);
|
||||
selectDiskFsProfileBTRFS(slots,init);
|
||||
} else if (fsType.indexOf('zfs') != -1) {
|
||||
selectDiskFsProfileZFS(slots,set_default,subpool);
|
||||
selectDiskFsProfileZFS(slots,init,subpool);
|
||||
} else if (fsType.indexOf('xfs') != -1) {
|
||||
selectDiskFsProfileXFS();
|
||||
}
|
||||
@@ -614,7 +631,7 @@ function eraseDisk(name) {
|
||||
swal.close();
|
||||
$('#doneButton').prop('disabled',true);
|
||||
$('#eraseButton').prop('disabled',true);
|
||||
$('#deleteButton').prop('disabled',true);
|
||||
$('#removeButton').prop('disabled',true);
|
||||
$('div.spinner.fixed').show();
|
||||
$.post("/update.htm",{cmdWipefs:name},function(){
|
||||
$('div.spinner.fixed').hide();
|
||||
@@ -625,9 +642,9 @@ function eraseDisk(name) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function deletePool(name) {
|
||||
function removePool(name) {
|
||||
swal({
|
||||
title:"_(Delete pool)_?",
|
||||
title:"_(Remove pool)_?",
|
||||
text:"<?=$textDelete?>",
|
||||
html:true,
|
||||
type:'input',
|
||||
@@ -642,7 +659,7 @@ function deletePool(name) {
|
||||
swal.close();
|
||||
$('#doneButton').prop('disabled',true);
|
||||
$('#eraseButton').prop('disabled',true);
|
||||
$('#deleteButton').prop('disabled',true);
|
||||
$('#removeButton').prop('disabled',true);
|
||||
$('div.spinner.fixed').show();
|
||||
$.post("/update.htm",{changeSlots:"apply",poolName:name,poolSlots:0},function(){
|
||||
$('div.spinner.fixed').hide();
|
||||
@@ -735,9 +752,9 @@ _(File system type)_:
|
||||
<?if (diskType('Data') || isPool($tag)):?>
|
||||
<div markdown="1" id="profile">
|
||||
_(Allocation profile)_:
|
||||
: <select id="diskFsProfile" name="diskFsProfile.<?=_var($disk,'idx')?>" <?=disabled_if($fsTypeImmutable)?>>
|
||||
: <select id="diskFsProfile" name="diskFsProfile.<?=_var($disk,'idx')?>" <?=disabled_if($fsProfileImmutable)?>>
|
||||
</select>
|
||||
<select id="diskFsWidth" name="diskFsWidth.<?=_var($disk,'idx')?>" <?=disabled_if($fsTypeImmutable)?>>
|
||||
<select id="diskFsWidth" name="diskFsWidth.<?=_var($disk,'idx')?>" <?=disabled_if($fsProfileImmutable)?>>
|
||||
</select>
|
||||
|
||||
:info_profile_help:
|
||||
@@ -792,18 +809,17 @@ _(Critical disk utilization threshold)_ (%):
|
||||
|
||||
: <input type="submit" name="changeDisk" value="_(Apply)_" disabled><input type="button" id="doneButton" value="_(Done)_" onclick="done()">
|
||||
<?$erasable=false?>
|
||||
<?$removeable=false?>
|
||||
<?if (diskType('Parity','Data')):?>
|
||||
<?if (_var($var,'fsState')=="Stopped" && diskStatus('_NEW')): $erasable=true; endif;?>
|
||||
<?if (_var($var,'fsState')=="Started" && _var($var,'startMode')!="Normal" && diskType('Data')): $erasable=true; endif;?>
|
||||
<input type="button" id="eraseButton" value="_(Erase)_" onclick="eraseDisk('<?=$name?>')"<?=$erasable?'':' disabled'?>>
|
||||
<?endif;?>
|
||||
<?if (isPool($name) && strpos($name,$_tilde_)===false):?>
|
||||
<?if (isPool($name) && isSubpool($name)===false):?>
|
||||
<?if (_var($var,'fsState')=="Stopped" || (_var($var,'fsState')=="Started" && _var($var,'startMode')!="Normal")): $erasable=true; endif;?>
|
||||
<input type="button" id="eraseButton" value="_(Erase Pool)_" onclick="eraseDisk('<?=$name?>')"<?=$erasable?'':' disabled'?>>
|
||||
<?endif;?>
|
||||
<?if (isPool($name)):?>
|
||||
<?$deleteable=_var($var,'fsState')=="Stopped" && !isSubpool($name)?>
|
||||
<input type="button" id="deleteButton" value="_(Delete Pool)_" onclick="deletePool('<?=$name?>')"<?=$deleteable?'':' disabled'?>>
|
||||
<?if (_var($var,'fsState')=="Stopped"): $removeable=true; endif;?>
|
||||
<input type="button" id="removeButton" value="_(Remove Pool)_" onclick="removePool('<?=$name?>')"<?=$removeable?'':' disabled'?>>
|
||||
<?endif;?>
|
||||
</form>
|
||||
|
||||
@@ -1401,9 +1417,9 @@ _(SMART attribute notifications)_:
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame" onsubmit="return validate(this.poolName.value)">
|
||||
<input type="hidden" name="poolNameOrig" value="<?=$name?>">
|
||||
<input type="hidden" name="changeSlots" value="apply">
|
||||
<p>_(Caution)_: _(Renaming the pool will change the share storage allocations)_. _(After renaming the pool, check that your shares are assigned to the proper primary and secondary storage locations)_.</p>
|
||||
_(Name)_:
|
||||
: <input type="text" name="poolName" maxlength="40" value="<?=$name?>">
|
||||
<p>_(Caution)_: _(Renaming the pool will change the share storage allocations)_. _(After renaming the pool, check that your shares are assigned to the proper primary and secondary storage locations)_.</p>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
@@ -154,7 +154,7 @@ _(Enable spinup groups)_:
|
||||
|
||||
:disk_spinup_groups_help:
|
||||
|
||||
_(Default file system)_:
|
||||
_(Default file system for Array disks)_:
|
||||
: <select name="defaultFsType">
|
||||
<?=mk_option($var['defaultFsType'], "xfs", _('xfs'));?>
|
||||
<?=mk_option($var['defaultFsType'], "zfs", _('zfs'));?>
|
||||
|
@@ -60,8 +60,8 @@ foreach ($ports as $ethX) {
|
||||
}
|
||||
}
|
||||
// enable interface only when VMs and Docker are stopped
|
||||
$service = exec("pgrep libvirt") ? _('VM manager') : '';
|
||||
$service .= exec("pgrep docker") ? ($service ? ' '._('and').' ' : '')._('Docker service') : '';
|
||||
$service = exec('pgrep --ns $$ libvirt') ? _('VM manager') : '';
|
||||
$service .= exec('pgrep --ns $$ docker') ? ($service ? ' '._('and').' ' : '')._('Docker service') : '';
|
||||
|
||||
// eth0 port status
|
||||
$no_eth0 = exec("ip link show eth0|grep -Pom1 '(NO-CARRIER|state DOWN)'");
|
||||
|
@@ -117,51 +117,122 @@ if ($cert2Present) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tailscale LE cert
|
||||
$cert3File = "/boot/config/ssl/certs/ts_bundle.pem";
|
||||
$cert3Present = file_exists("$cert3File");
|
||||
if ($cert3Present) {
|
||||
$cert3Subject = exec("/usr/bin/openssl x509 -in $cert3File -noout -subject -nameopt multiline 2>/dev/null|sed -n 's/ *commonName *= //p'");
|
||||
$cert3Issuer = exec("/usr/bin/openssl x509 -in $cert3File -noout -text | sed -n -e 's/^.*Issuer: //p'");
|
||||
$cert3Expires = exec("/usr/bin/openssl x509 -in $cert3File -noout -text | sed -n -e 's/^.*Not After : //p'");
|
||||
}
|
||||
|
||||
// Note: this disables FQDN6 urls since they are not supported by myunraid.net DNS currently
|
||||
if (!empty($nginx['NGINX_LANFQDN6'])) unset($nginx['NGINX_LANFQDN6']);
|
||||
|
||||
$http_port = _var($var,'PORT','80') != '80' ? ":{$var['PORT']}" : '';
|
||||
$https_port = _var($var,'PORTSSL','443') != '443' ? ":{$var['PORTSSL']}" : '';
|
||||
$http_ip_url = "http://"._var($nginx,'NGINX_LANIP')."{$http_port}/";
|
||||
$https_ip_url = "https://"._var($nginx,'NGINX_LANIP')."{$https_port}/";
|
||||
$http_ip6_url = "http://["._var($nginx,'NGINX_LANIP6')."]{$http_port}/";
|
||||
$https_ip6_url = "https://["._var($nginx,'NGINX_LANIP6')."]{$https_port}/";
|
||||
$http_mdns_url = "http://"._var($nginx,'NGINX_LANMDNS')."{$http_port}/";
|
||||
$https_mdns_url = "https://"._var($nginx,'NGINX_LANMDNS')."{$https_port}/";
|
||||
$https_fqdn_url = "https://"._var($nginx,'NGINX_LANFQDN')."{$https_port}/";
|
||||
$https_fqdn6_url = "https://"._var($nginx,'NGINX_LANFQDN6')."{$https_port}/";
|
||||
$http_ip_url = 'http://'._var($nginx,'NGINX_LANIP').$http_port.'/';
|
||||
$https_ip_url = 'https://'._var($nginx,'NGINX_LANIP').$https_port.'/';
|
||||
// bare IPv6 addresses need to be surrounded in brackets
|
||||
$http_ip6_url = 'http://'.'['._var($nginx,'NGINX_LANIP6').']'.$http_port.'/';
|
||||
$https_ip6_url = 'https://'.'['._var($nginx,'NGINX_LANIP6').']'.$https_port.'/';
|
||||
$http_mdns_url = 'http://'._var($nginx,'NGINX_LANMDNS').$http_port.'/';
|
||||
$https_mdns_url = 'https://'._var($nginx,'NGINX_LANMDNS').$https_port.'/';
|
||||
$https_fqdn_url = 'https://'._var($nginx,'NGINX_LANFQDN').$https_port.'/';
|
||||
$https_fqdn6_url = 'https://'._var($nginx,'NGINX_LANFQDN6').$https_port.'/';
|
||||
|
||||
$urls = [];
|
||||
// push an array of four values into the $urls array:
|
||||
// 0 - the url
|
||||
// 1 - the url it redirects to, or null
|
||||
// 2 - the certificate file used, or null
|
||||
// 3 - self-signed certificate, or false
|
||||
// push an array of five values into the $urls array:
|
||||
// 0 - type of url ['LAN','WAN','WG','TAILSCALE']
|
||||
// 1 - the url
|
||||
// 3 - the url it redirects to, or null
|
||||
// 4 - the certificate file used, or null
|
||||
// 5 - self-signed certificate, or false
|
||||
|
||||
// define LAN access urls and redirects that change based on USE_SSL setting
|
||||
switch(_var($var,'USE_SSL','no')) {
|
||||
case 'no':
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = [$http_ip_url, null, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = [$http_ip6_url, null, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = [$http_mdns_url, null, null, false];
|
||||
if (!empty($nginx['NGINX_LANFQDN'])) $urls[] = [$https_fqdn_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANFQDN6'])) $urls[] = [$https_fqdn6_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = ['LAN', $http_ip_url, null, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = ['LAN', $http_ip6_url, null, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = ['LAN', $http_mdns_url, null, null, false];
|
||||
break;
|
||||
case 'yes':
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = [$http_ip_url, $https_ip_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = [$https_ip_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = [$http_ip6_url, $https_ip6_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = [$https_ip6_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = [$http_mdns_url, $https_mdns_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = [$https_mdns_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
if (!empty($nginx['NGINX_LANFQDN'])) $urls[] = [$https_fqdn_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANFQDN6'])) $urls[] = [$https_fqdn6_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = ['LAN', $http_ip_url, $https_ip_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = ['LAN', $https_ip_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = ['LAN', $http_ip6_url, $https_ip6_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = ['LAN', $https_ip6_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = ['LAN', $http_mdns_url, $https_mdns_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = ['LAN', $https_mdns_url, null, "{$var['NAME']}_unraid_bundle.pem", $cert1SelfSigned];
|
||||
break;
|
||||
case 'auto': // aka strict
|
||||
if (!empty($nginx['NGINX_LANIP'])) $urls[] = [$http_ip_url, $https_fqdn_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6'])) $urls[] = [$http_ip6_url, $https_fqdn6_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS'])) $urls[] = [$http_mdns_url, $https_fqdn_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANFQDN'])) $urls[] = [$https_fqdn_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANFQDN6'])) $urls[] = [$https_fqdn6_url, null, "certificate_bundle.pem", false];
|
||||
if (!empty($nginx['NGINX_LANIP']) && !empty($nginx['NGINX_LANFQDN'])) $urls[] = ['LAN', $http_ip_url, $https_fqdn_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANIP6']) && !empty($nginx['NGINX_LANFQDN6'])) $urls[] = ['LAN', $http_ip6_url, $https_fqdn6_url, null, false];
|
||||
if (!empty($nginx['NGINX_LANMDNS']) && !empty($nginx['NGINX_LANFQDN'])) $urls[] = ['LAN', $http_mdns_url, $https_fqdn_url, null, false];
|
||||
break;
|
||||
}
|
||||
|
||||
// define FQDN urls for each interface
|
||||
// when multiple FQDN urls are available for a given interface, make sure they are sorted
|
||||
asort($nginx);
|
||||
foreach ($nginx as $key => $host) {
|
||||
if (!$host) continue;
|
||||
// Only process keys that include 'FQDN'
|
||||
if (strpos($key, 'FQDN') === false) continue;
|
||||
// Extract the interface from the key, e.g., 'NGINX_LANFQDN' -> 'LAN', 'NGINX_WANFQDN' -> 'WAN', NGINX_WG0FQDN -> WG, NGINX_TAILSCALE1FQDN -> TAILSCALE
|
||||
// Note: this specifically excludes FQDN6 urls since they are not supported by myunraid.net DNS currently
|
||||
if (preg_match('/^NGINX_([A-Z]+)(\d*)FQDN$/', $key, $matches)) {
|
||||
$interface = $matches[1]; // Interface type (LAN, WAN, WG, TAILSCALE, etc.)
|
||||
// ignore the WAN interface because we don't have access to the WANPORT here
|
||||
if ($interface == "WAN") continue;
|
||||
$pem = null;
|
||||
if (str_ends_with($host, '.myunraid.net')) $pem = 'certificate_bundle.pem';
|
||||
elseif (str_ends_with($host, '.ts.net')) $pem = 'ts_bundle.pem';
|
||||
$url = 'https://'.$host.$https_port."/";
|
||||
$urls[] = [$interface, $url, null, $pem, false];
|
||||
}
|
||||
}
|
||||
|
||||
// determine whether there are urls for a given interface
|
||||
function has_urls($interface) {
|
||||
global $urls;
|
||||
foreach($urls as $url) {
|
||||
if ($url[0] == $interface) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// show all urls for a given interface
|
||||
function show_urls($interface) {
|
||||
global $urls;
|
||||
// 0 - type of url ['LAN','WAN','WG','TAILSCALE']
|
||||
// 1 - the url
|
||||
// 3 - the url it redirects to, or null
|
||||
// 4 - the certificate file used, or null
|
||||
// 5 - self-signed certificate, or false
|
||||
$output = "";
|
||||
$linestart = "<dt> </dt><dd>";
|
||||
$lineend = "</dd>\n";
|
||||
$first = true;
|
||||
foreach($urls as $url) {
|
||||
if ($url[0] == $interface) {
|
||||
$msg = "<a href='$url[1]'>$url[1]</a>";
|
||||
if ($url[2]) $msg .= " "._("redirects to")." <a href='$url[2]'>$url[2]</a>";
|
||||
if ($url[3]) $msg .= " "._("uses")." ".$url[3];
|
||||
if ($url[4]) $msg .= "<span class='warning'> <i class='fa fa-warning fa-fw'></i> "._("is a self-signed certificate, ignore the browser's warning and proceed to the GUI")."</span>";
|
||||
// 2nd+ urls need leading $linestart
|
||||
$output .= ($first ? "" : $linestart).$msg.$lineend;
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
if ($first) {
|
||||
$output = "none";
|
||||
} else {
|
||||
// strip final trailing $lineend as it will be added by markdown
|
||||
$output = substr($output, 0, strlen($lineend)*-1);
|
||||
}
|
||||
echo $output;
|
||||
}
|
||||
|
||||
$cert_time_format = $display['date'].($display['date']!='%c' ? ', '.str_replace(['%M','%R'],['%M:%S','%R:%S'],$display['time']):'');
|
||||
$provisionlabel = $isWildcardCert ? _('Renew') : _('Provision');
|
||||
$disabled_provision = $keyfile===false || ($isWildcardCert && $retval_expired===0) || !$addr ? 'disabled' : '';
|
||||
@@ -334,24 +405,34 @@ _(Local TLD)_:
|
||||
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
_(Local access URLs)_:
|
||||
: <?
|
||||
// url[0] = url
|
||||
// url[1] = redirect url or null
|
||||
// url[2] = certificate used or null
|
||||
// url[3] = is certificate self-signed T/F
|
||||
$n = 0;
|
||||
foreach($urls as $url) {
|
||||
$msg = "";
|
||||
if ($url[1]) $msg .= " "._("redirects to")." <a href='$url[1]'>$url[1]</a>";
|
||||
if ($url[2]) $msg .= " "._("uses")." ".$url[2];
|
||||
if ($url[3]) $msg .= "<span class='warning'> <i class='fa fa-warning fa-fw'></i> "._("is a self-signed certificate, ignore the browser's warning and proceed to the GUI")."</span>";
|
||||
echo ($n ? "<dt> </dt><dd>" : ""),"<a href='$url[0]'>$url[0]</a>$msg",($n++ ? "</dd>" : "");
|
||||
}?>
|
||||
: <? show_urls('LAN'); ?>
|
||||
|
||||
:mgmt_local_access_urls_help:
|
||||
|
||||
<?if (has_urls('WG')): ?>
|
||||
|
||||
_(WireGuard URLs)_:
|
||||
: <? show_urls('WG'); ?>
|
||||
|
||||
:mgmt_wg_access_urls_help:
|
||||
|
||||
<?endif;?>
|
||||
|
||||
<?if (has_urls('TAILSCALE')): ?>
|
||||
|
||||
_(Tailscale URLs)_:
|
||||
: <? show_urls('TAILSCALE'); ?>
|
||||
|
||||
:mgmt_tailscale_access_urls_help:
|
||||
|
||||
<?endif;?>
|
||||
|
||||
<?if ($cert1Present):?>
|
||||
<hr>
|
||||
|
||||
_(Self-signed or user-provided certificate)_:
|
||||
: <?=$cert1File?>
|
||||
|
||||
@@ -386,6 +467,9 @@ _(Self-signed certificate file)_:
|
||||
<input type="hidden" name="server_name" value="<?=strtok(_var($_SERVER,'HTTP_HOST'),":")?>">
|
||||
<input type="hidden" name="server_addr" value="<?=_var($_SERVER,'SERVER_ADDR')?>">
|
||||
<?if ($cert2Present):?>
|
||||
|
||||
<hr>
|
||||
|
||||
_(Unraid Let's Encrypt certificate)_:
|
||||
: <?=$cert2File?>
|
||||
|
||||
@@ -415,6 +499,31 @@ _(CA-signed certificate file)_:
|
||||
|
||||
: <button type="submit" name="changePorts" value="Provision" <?=$disabled_provision?>><?=$provisionlabel?></button><button type="submit" name="changePorts" value="Delete" <?=$disabled_delete?> >_(Delete)_</button><?=$disabled_provision_msg?>
|
||||
|
||||
|
||||
<?if ($cert3Present):?>
|
||||
|
||||
<hr>
|
||||
|
||||
_(Tailscale Let's Encrypt certificate)_:
|
||||
: <?=$cert3File?>
|
||||
|
||||
_(Certificate URL)_:
|
||||
: <?="<a href='https://$cert3Subject$https_port'>$cert3Subject</a>"?>
|
||||
|
||||
_(Certificate issuer)_:
|
||||
: <?=$cert3Issuer?>
|
||||
|
||||
_(Certificate expiration)_:
|
||||
: <?=_(my_date($cert_time_format, strtotime($cert3Expires)),0)?>
|
||||
|
||||
<?endif;?>
|
||||
|
||||
:mgmt_certificate_expiration_help:
|
||||
|
||||
</form>
|
||||
|
||||
<?if (has_urls('WG')): ?>
|
||||
|
||||
<small>"WireGuard" and the "WireGuard" logo are registered trademarks of Jason A. Donenfeld</small>
|
||||
|
||||
<?endif;?>
|
||||
|
@@ -541,14 +541,10 @@ _(Mover action)_:
|
||||
|
||||
: <input type="submit" name="cmdEditShare" value="_(Add Share)_" onclick="this.value='Add Share'"><input type="button" value="_(Done)_" onclick="done()">
|
||||
<?else:?>
|
||||
<div markdown="1" class="empty">
|
||||
_(Delete)_<input type="checkbox" name="confirmDelete" onchange="chkDelete(this.form, document.getElementById('cmdEditShare'));">
|
||||
<div markdown="1">
|
||||
<label id="deleteLabel" title="">_(Delete)_</label><input type="checkbox" name="confirmDelete" onchange="chkDelete(this.form, document.getElementById('cmdEditShare'));" title="" disabled>
|
||||
: <input type="submit" id="cmdEditShare" name="cmdEditShare" value="_(Apply)_" onclick="if (this.value=='_(Delete)_') this.value='Delete'; else this.value='Apply'; return handleDeleteClick(this)" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</div>
|
||||
<div markdown="1" class="full">
|
||||
|
||||
: <input type="submit" name="cmdEditShare" value="_(Apply)_" onclick="this.value='Apply'" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</div>
|
||||
<?endif;?>
|
||||
</form>
|
||||
|
||||
@@ -644,6 +640,7 @@ function updateScreen(cache, slow) {
|
||||
secondaryDropdown.options[i].disabled = true;
|
||||
}
|
||||
secondaryDropdown.selectedIndex = 0;
|
||||
checkRequiredSecondary = false;
|
||||
|
||||
if (poolsOnly) {
|
||||
$('#moverDirection2').hide();
|
||||
@@ -1297,13 +1294,24 @@ function handleDeleteClick(button) {
|
||||
|
||||
$(function() {
|
||||
<?if ($name):?>
|
||||
<?
|
||||
$tooltip_enabled = _('Share is empty and is safe to delete');
|
||||
$tooltip_disabled = _('Share must be empty to be deleted');
|
||||
?>
|
||||
|
||||
$.post('/webGui/include/ShareList.php', { scan: "<?=$name?>" }, function(e) {
|
||||
if (e == 1) {
|
||||
$('.empty').show();
|
||||
$('.full').hide();
|
||||
/* Enable delete checkbox and update tooltip. */
|
||||
$('input[name="confirmDelete"]').prop('disabled', false).attr('title', '<?= $tooltip_enabled ?>');
|
||||
$('#deleteLabel').attr('title', '<?= $tooltip_enabled ?>');
|
||||
} else {
|
||||
$('.full1').hide();
|
||||
$('.full2').show();
|
||||
/* Disable delete checkbox and update tooltip. */
|
||||
$('input[name="confirmDelete"]').prop('disabled', true).attr('title', '<?= $tooltip_disabled ?>');
|
||||
$('#deleteLabel').attr('title', '<?= $tooltip_disabled ?>');
|
||||
}
|
||||
});
|
||||
<?endif;?>
|
||||
|
@@ -48,12 +48,13 @@ if ($_POST['docker']) {
|
||||
$template = $info['template'];
|
||||
$shell = $info['shell'];
|
||||
$webGui = html_entity_decode($info['url']);
|
||||
$TSwebGui = html_entity_decode($info['TSurl']);
|
||||
$support = html_entity_decode($info['Support']);
|
||||
$project = html_entity_decode($info['Project']);
|
||||
$registry = html_entity_decode($info['registry']);
|
||||
$donateLink = html_entity_decode($info['DonateLink']);
|
||||
$readme = html_entity_decode($info['ReadMe']);
|
||||
$menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project), addslashes($registry), addslashes($donateLink), addslashes($readme));
|
||||
$menu = sprintf("onclick=\"addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), addslashes($TSwebGui), $shell, $id, addslashes($support), addslashes($project), addslashes($registry), addslashes($donateLink), addslashes($readme));
|
||||
$shape = $running ? ($paused ? 'pause' : 'play') : 'square';
|
||||
$status = $running ? ($paused ? 'paused' : 'started') : 'stopped';
|
||||
$color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text');
|
||||
|
@@ -40,9 +40,9 @@ default:
|
||||
$file = "/var/lib/$dir/check.status.$id";
|
||||
if (file_exists($file)) {
|
||||
switch ($cmd) {
|
||||
case 'btrfs-check': $pgrep = "pgrep -f '/sbin/btrfs check .*$dev'"; break;
|
||||
case 'rfs-check': $pgrep = "pgrep -f '/sbin/reiserfsck $dev'"; break;
|
||||
case 'xfs-check': $pgrep = "pgrep -f '/sbin/xfs_repair.*$dev'"; break;
|
||||
case 'btrfs-check': $pgrep = 'pgrep --ns $$ -f '."'/sbin/btrfs check .*$dev'"; break;
|
||||
case 'rfs-check': $pgrep = 'pgrep --ns $$ -f '."'/sbin/reiserfsck $dev'"; break;
|
||||
case 'xfs-check': $pgrep = 'pgrep --ns $$ -f '."'/sbin/xfs_repair.*$dev'"; break;
|
||||
}
|
||||
echo file_get_contents($file);
|
||||
if (!exec($pgrep)) echo "\0";
|
||||
|
@@ -263,7 +263,7 @@ function urlencode_path($path) {
|
||||
return str_replace("%2F", "/", urlencode($path));
|
||||
}
|
||||
function pgrep($process_name, $escape_arg=true) {
|
||||
$pid = exec("pgrep ".($escape_arg?escapeshellarg($process_name):$process_name), $output, $retval);
|
||||
$pid = exec('pgrep --ns $$ '.($escape_arg?escapeshellarg($process_name):$process_name), $output, $retval);
|
||||
return $retval==0 ? $pid : false;
|
||||
}
|
||||
function is_block($path) {
|
||||
@@ -345,27 +345,46 @@ function my_mkdir($dirname,$permissions = 0777,$recursive = false,$own = "nobody
|
||||
return($rtncode);
|
||||
}
|
||||
function my_rmdir($dirname) {
|
||||
if (!is_dir($dirname)) return(false);
|
||||
if (!is_dir("$dirname")) {
|
||||
$return = [
|
||||
'rtncode' => "false",
|
||||
'type' => "NoDir",
|
||||
];
|
||||
return($return);
|
||||
}
|
||||
if (strpos($dirname,'/mnt/user/')===0) {
|
||||
$realdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($dirname)." 2>/dev/null"));
|
||||
if (!empty($realdisk)) {
|
||||
$dirname = str_replace('/mnt/user/', "/mnt/$realdisk/", $dirname);
|
||||
$dirname = str_replace('/mnt/user/', "/mnt/$realdisk/", "$dirname");
|
||||
}
|
||||
}
|
||||
$fstype = trim(shell_exec(" stat -f -c '%T' $dirname"));
|
||||
$fstype = trim(shell_exec(" stat -f -c '%T' ".escapeshellarg($dirname)));
|
||||
$rtncode = false;
|
||||
switch ($fstype) {
|
||||
case "zfs":
|
||||
$zfsoutput = array();
|
||||
$zfsdataset = trim(shell_exec("zfs list -H -o name \"$dirname\"")) ;
|
||||
exec("zfs destroy \"$zfsdataset\"",$zfsoutput,$rtncode);
|
||||
$zfsdataset = trim(shell_exec("zfs list -H -o name ".escapeshellarg($dirname))) ;
|
||||
$cmdstr = "zfs destroy \"$zfsdataset\" 2>&1 ";
|
||||
$error = exec($cmdstr,$zfsoutput,$rtncode);
|
||||
$return = [
|
||||
'rtncode' => $rtncode,
|
||||
'output' => $zfsoutput,
|
||||
'dataset' => $zfsdataset,
|
||||
'type' => $fstype,
|
||||
'cmd' => $cmdstr,
|
||||
'error' => $error,
|
||||
];
|
||||
break;
|
||||
case "btrfs":
|
||||
default:
|
||||
$rtncode = rmdir($dirname);
|
||||
$return = [
|
||||
'rtncode' => $rtncode,
|
||||
'type' => $fstype,
|
||||
];
|
||||
break;
|
||||
}
|
||||
return($rtncode);
|
||||
return($return);
|
||||
}
|
||||
function get_realvolume($path) {
|
||||
if (strpos($path,"/mnt/user/",0) === 0)
|
||||
|
@@ -44,10 +44,10 @@ switch ($_GET['tag']) {
|
||||
case 'ttyd':
|
||||
// check if ttyd already running
|
||||
$sock = "/var/run/ttyd.sock";
|
||||
exec("pgrep -f '$sock'", $ttyd_pid, $retval);
|
||||
exec('pgrep --ns $$ -f '."'$sock'", $ttyd_pid, $retval);
|
||||
if ($retval == 0) {
|
||||
// check if there are any child processes, ie, curently open tty windows
|
||||
exec("pgrep -P ".$ttyd_pid[0], $output, $retval);
|
||||
exec('pgrep --ns $$ -P '.$ttyd_pid[0], $output, $retval);
|
||||
// no child processes, restart ttyd to pick up possible font size change
|
||||
if ($retval != 0) exec("kill ".$ttyd_pid[0]);
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ function tab_title($title,$path,$tag) {
|
||||
if (!$tag || substr($tag,-4)=='.png') {
|
||||
$file = "$path/icons/".($tag ?: strtolower(str_replace(' ','',$title)).".png");
|
||||
if (file_exists("$docroot/$file")) {
|
||||
return "<img src='/$file' class='icon'>$title";
|
||||
return "<img src='/$file' class='icon' style='max-width: 18px; max-height: 18px; width: auto; height: auto; object-fit: contain;'>$title";
|
||||
} else {
|
||||
return "<i class='fa fa-th title'></i>$title";
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@ case 'Add Route':
|
||||
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_{$metric}_add"));
|
||||
break;
|
||||
default:
|
||||
exec("ip -4 route show|grep -v '^127.0.0.0'",$ipv4);
|
||||
exec("ip -6 route show|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|expires'",$ipv6);
|
||||
exec("ip -4 route show table all|grep -Pv '^(127\\.0\\.0\\.0)|table local'",$ipv4);
|
||||
exec("ip -6 route show table all|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|expires|table local'",$ipv6);
|
||||
foreach ($ipv4 as $info) {
|
||||
$cell = explode(' ',$info);
|
||||
$route = $cell[0];
|
||||
|
@@ -37,7 +37,7 @@ if (isset($_POST['scan'])) {
|
||||
/* Iterate over each item in the directory and its subdirectories */
|
||||
foreach ($iterator as $fileinfo) {
|
||||
/* Check if the current item is a file and not a .DS_Store file */
|
||||
if ($fileinfo->isFile() && $fileinfo->getFilename() !== '.DS_Store') {
|
||||
if ($fileinfo->isFile() && !preg_match('/\.DS_Store$/i', $fileinfo->getFilename())) {
|
||||
$hasFiles = true;
|
||||
break;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ function removeDSStoreFilesAndEmptyDirs($dir) {
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile() && $file->getFilename() === '.DS_Store') {
|
||||
if ($file->isFile() && preg_match('/\.DS_Store$/i', $file->getFilename())) {
|
||||
unlink($file->getRealPath());
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,6 @@ if (isset($_POST['cleanup'])) {
|
||||
$n = 0;
|
||||
// active shares
|
||||
$shares = array_map('strtolower',array_keys(parse_ini_file('state/shares.ini',true)));
|
||||
|
||||
// stored shares
|
||||
foreach (glob("/boot/config/shares/*.cfg",GLOB_NOSORT) as $name) {
|
||||
if (!in_array(strtolower(basename($name,'.cfg')),$shares)) {
|
||||
@@ -214,12 +213,9 @@ foreach ($shares as $name => $share) {
|
||||
$share_valid = true;
|
||||
}
|
||||
|
||||
/* Check if poolsOnly is true. */
|
||||
if ($poolsOnly) {
|
||||
/* If useCache is set to 'yes' or 'prefer', change it to 'only'. */
|
||||
if ((($share['useCache'] == 'yes') || ($share['useCache'] == 'prefer')) && (!$share['cachePool2'])) {
|
||||
$share['useCache'] = 'only';
|
||||
}
|
||||
/* When there is no array, all pools are treated as 'only' cache. */
|
||||
if (($poolsOnly) && (! $share['cachePool2'])) {
|
||||
$share['useCache'] = 'only';
|
||||
}
|
||||
|
||||
$row++;
|
||||
|
@@ -15,7 +15,7 @@ $docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Secure.php";
|
||||
|
||||
function pgrep($proc) {
|
||||
return exec("pgrep -f $proc");
|
||||
return exec('pgrep --ns $$ -f '."$proc");
|
||||
}
|
||||
|
||||
if (isset($_POST['kill']) && $_POST['kill'] > 1) {
|
||||
|
@@ -75,9 +75,11 @@ case 't1':
|
||||
foreach ($devicelist as $line) {
|
||||
if (!empty($line)) {
|
||||
exec('udevadm info --path=$(udevadm info -q path /dev/'.$line.' | cut -d / -f 1-7) --query=path',$linereturn);
|
||||
preg_match_all($DBDF_PARTIAL_REGEX, $linereturn[0], $inuse);
|
||||
foreach ($inuse[0] as $line) {
|
||||
$lines[] = $line;
|
||||
if(isset($linereturn[0])) {
|
||||
preg_match_all($DBDF_PARTIAL_REGEX, $linereturn[0], $inuse);
|
||||
foreach ($inuse[0] as $line) {
|
||||
$lines[] = $line;
|
||||
}
|
||||
}
|
||||
unset($inuse);
|
||||
unset($linereturn);
|
||||
@@ -92,9 +94,11 @@ case 't1':
|
||||
foreach ($nics as $line) {
|
||||
if (!empty($line)) {
|
||||
exec('readlink /sys/class/net/'.$line,$linereturn);
|
||||
preg_match_all($DBDF_PARTIAL_REGEX, $linereturn[0], $inuse);
|
||||
foreach ($inuse[0] as $line) {
|
||||
$lines[] = $line;
|
||||
if(isset($linereturn[0])) {
|
||||
preg_match_all($DBDF_PARTIAL_REGEX, $linereturn[0], $inuse);
|
||||
foreach ($inuse[0] as $line) {
|
||||
$lines[] = $line;
|
||||
}
|
||||
}
|
||||
unset($inuse);
|
||||
unset($linereturn);
|
||||
|
@@ -184,7 +184,8 @@ function array_offline(&$disk, $pool='') {
|
||||
$text = "<span class='red-text'><em>"._('All existing data on this device will be OVERWRITTEN when array is Started')."</em></span>";
|
||||
if (_var($disk,'type')=='Cache') {
|
||||
if (!str_contains(_var($disks[$pool],'state'),'ERROR:')) {
|
||||
if (!empty(_var($disks[$pool],'uuid'))) {
|
||||
$_pool = (strpos($pool, '~') !== false) ? substr($pool, 0, strpos($pool, '~')) : $pool;
|
||||
if (!empty(_var($disks[$_pool],'uuid'))) {
|
||||
if (in_array(_var($disk,'status'),$status) || _var($disk['status'])=='DISK_NEW') $warning = $text;
|
||||
}
|
||||
}
|
||||
@@ -267,7 +268,7 @@ function array_online(&$disk, $fstype='') {
|
||||
$sum['count']++;
|
||||
$sum['temp'] += $disk['temp'];
|
||||
}
|
||||
$sum['power'] += _var($disk,'power',0);
|
||||
$sum['power'] += intval(_var($disk,'power',0));
|
||||
$sum['numReads'] += _var($disk,'numReads',0);
|
||||
$sum['numWrites'] += _var($disk,'numWrites',0);
|
||||
$sum['numErrors'] += _var($disk,'numErrors',0);
|
||||
@@ -507,11 +508,7 @@ while (true) {
|
||||
if ($zfsPool) {
|
||||
$current_subpools = array_filter($pools, function($element) use ($pool,$_tilde_) {return str_contains($element,"{$pool}{$_tilde_}");});
|
||||
$current_subpools_list = str_replace("{$pool}{$_tilde_}","", implode(',', $current_subpools));
|
||||
if (!empty(_var($Cache[$pool],'uuid'))) {
|
||||
$echo[$a][] = "<input type='button' value='"._('Add Subpool')."' class='subpool' onclick='addSubpoolPopup(\"$pool\",\"$current_subpools_list\")'".(count($current_subpools)<count($subpools)?'':' disabled').">";
|
||||
} else {
|
||||
$echo[$a][] = "<input type='button' value='"._('Add Subpool')."' class='subpool' disabled>";
|
||||
}
|
||||
$echo[$a][] = "<input type='button' value='"._('Add Subpool')."' class='subpool' onclick='addSubpoolPopup(\"$pool\",\"$current_subpools_list\")'".(count($current_subpools)<count($subpools)?'':' disabled').">";
|
||||
}
|
||||
$echo[$a][] = "</span></td><td></td></tr>";
|
||||
} else {
|
||||
|
@@ -18,6 +18,7 @@ $log = '/boot/config/parity-checks.log';
|
||||
$stamps = '/var/tmp/stamps.ini';
|
||||
$resync = '/var/tmp/resync.ini';
|
||||
$md5_old = $spot_old = $fs_old = $proc_old = -1;
|
||||
$remove_resync_files = false;
|
||||
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/publish.php";
|
||||
@@ -106,10 +107,15 @@ while (true) {
|
||||
/* Save the result in the parity history log. */
|
||||
file_put_contents($log, "$timestamp|$duration|$speed|$status|$error|$action|$size\n", FILE_APPEND);
|
||||
|
||||
delete_file($stamps, $resync);
|
||||
/* Remove the resync files after the history file has been updated. */
|
||||
$remove_resync_files = true;
|
||||
|
||||
/* Parity check is completed. */
|
||||
$echo = "";
|
||||
} elseif ($remove_resync_files) {
|
||||
delete_file($stamps, $resync);
|
||||
|
||||
$remove_resync_files = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +161,6 @@ while (true) {
|
||||
$proc_old = publish('mymonitor', $process) !== false ? $process : -1;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
sleep(3);
|
||||
}
|
||||
?>
|
||||
|
@@ -78,8 +78,8 @@ while (true) {
|
||||
$echo[$vmencode ]['mem'] = "<span>Mem: ".my_scale($vmdata['mem']*1024,$unit)."$unit / ".my_scale($vmdata['curmem']*1024,$unit)."$unit";
|
||||
if ($vmdata['maxmem'] == $vmdata['curmem']) $echo[$vmencode ]['mem'] .="  </span>";
|
||||
else $echo[$vmencode ]['mem'] .= " / ".my_scale($vmdata['maxmem']*1024,$unit)."$unit  </span>";
|
||||
$echo[$vmencode ]['disk'] = "<span>Disk: "._("Rd").": ".my_scale($vmdata['rdrate'],$unit)."$unit/s "._("Wr").": ".my_scale($vmdata['wrrate'],$unit)."$unit/s  </span>";
|
||||
$echo[$vmencode ]['net'] = "<span>Net: "._("RX").": ".my_scale($vmdata['rxrate'],$unit)."$unit/s "._("TX").": ".my_scale($vmdata['txrate'],$unit)."$unit/s  </span>";
|
||||
$echo[$vmencode ]['disk'] = "<span>Disk: "._("Rd").": ".my_scale($vmdata['rdrate']/$timer,$unit)."$unit/s "._("Wr").": ".my_scale($vmdata['wrrate']/$timer,$unit)."$unit/s  </span>";
|
||||
$echo[$vmencode ]['net'] = "<span>Net: "._("RX").": ".my_scale($vmdata['rxrate']/$timer,$unit)."$unit/s "._("TX").": ".my_scale($vmdata['txrate']/$timer,$unit)."$unit/s  </span>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -440,7 +440,6 @@ run("lsscsi -vgl 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsscsi.txt")
|
||||
run("lspci -knn 2>/dev/null|todos >".escapeshellarg("/$diag/system/lspci.txt"));
|
||||
run("lsusb 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsusb.txt"));
|
||||
run("free -mth 2>/dev/null|todos >".escapeshellarg("/$diag/system/memory.txt"));
|
||||
run("ps -auxf --sort=-pcpu 2>/dev/null|todos >".escapeshellarg("/$diag/system/ps.txt"));
|
||||
run("lsof -Pni 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsof.txt"));
|
||||
run("lsmod|sort 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsmod.txt"));
|
||||
run("df -h 2>/dev/null|todos >".escapeshellarg("/$diag/system/df.txt"));
|
||||
@@ -723,6 +722,7 @@ newline("/$diag/system/sshd.txt");
|
||||
copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt");
|
||||
maskIP("/$diag/system/servers.conf.txt");
|
||||
run("sed -Ei 's/[01234567890abcdef]+\.((my)?unraid\.net)/hash.\\1/gm;t' ".escapeshellarg("/$diag/system/servers.conf.txt")." 2>/dev/null");
|
||||
run("sed -Ei 's/\.[^\.]*\.ts\.net/\.magicdns\.ts\.net/gm' ".escapeshellarg("/$diag/system/servers.conf.txt")." 2>/dev/null");
|
||||
newline("/$diag/system/servers.conf.txt");
|
||||
|
||||
// BEGIN - third party plugins diagnostics
|
||||
|
@@ -12,11 +12,10 @@
|
||||
|
||||
# With corrections suggested by forum member Stokkes
|
||||
|
||||
# Here's a breakdown of chmod "u-x,go-rwx,go+u,ugo+X"
|
||||
# u-x Clear the 'x' bit in the user permissions (leaves rw as-is)
|
||||
# Here's a breakdown of chmod "go-rwx,u-x,go+u"
|
||||
# go-rwx Clear the 'rwx' bits in both the group and other permissions
|
||||
# u-x Clear the 'x' bit in the user permissions (leaves rw as-is)
|
||||
# go+u Copy the user permissions to group and other
|
||||
# ugo+X Set the 'x' bit for directories in user, group, and other
|
||||
|
||||
$nchan = $argv[$argc-1] == 'nchan'; // console or nchan output
|
||||
if ($nchan) unset($argv[$argc-1]); // remove nchan parameter
|
||||
@@ -45,10 +44,13 @@ function process($path) {
|
||||
$owner = $argv[2] ?? 'nobody';
|
||||
$group = $argv[3] ?? 'users';
|
||||
if (is_dir($path) && preg_match('/^\/mnt\/.+/',$path)) {
|
||||
write("Processing: $path\n", "... chmod -R u-x,go-rwx,go+u,ugo+X $path\n");
|
||||
exec("chmod -R u-x,go-rwx,go+u,ugo+X ".escapeshellarg($path));
|
||||
write("... chown -R $owner:$group $path\n");
|
||||
write("Processing: $path\n");
|
||||
write("... chown -R $owner:$group\n");
|
||||
exec("chown -R $owner:$group ".escapeshellarg($path));
|
||||
write("... chmod -R go-rwx,u-x,go+u\n");
|
||||
exec("chmod -R go-rwx,u-x,go+u ".escapeshellarg($path));
|
||||
write("... find -type d -exec chmod 777 {} \\;\n");
|
||||
exec("find ".escapeshellarg($path)." -type d -exec chmod 777 {} \\;");
|
||||
write("... sync\n");
|
||||
exec("sync");
|
||||
write("\n");
|
||||
|
@@ -224,7 +224,7 @@ case 'add':
|
||||
$entity = $overrule===false ? $notify[$importance] : $overrule;
|
||||
if (!$mailtest) file_put_contents($archive,"timestamp=$timestamp\nevent=$event\nsubject=$subject\ndescription=$description\nimportance=$importance\n".($message ? "message=".str_replace('\n','<br>',$message)."\n" : ""));
|
||||
if (($entity & 1)==1 && !$mailtest && !$noBrowser) file_put_contents($unread,"timestamp=$timestamp\nevent=$event\nsubject=$subject\ndescription=$description\nimportance=$importance\nlink=$link\n");
|
||||
if (($entity & 2)==2 || $mailtest) if (!generate_email($event, clean_subject($subject), str_replace('<br>','. ',$description), $importance, $message, $recipients, $fqdnlink)) exit(1);
|
||||
if (($entity & 2)==2 || $mailtest) generate_email($event, clean_subject($subject), str_replace('<br>','. ',$description), $importance, $message, $recipients, $fqdnlink);
|
||||
if (($entity & 4)==4 && !$mailtest) { if (is_array($agents)) {foreach ($agents as $agent) {exec("TIMESTAMP='$timestamp' EVENT=".escapeshellarg($event)." SUBJECT=".escapeshellarg(clean_subject($subject))." DESCRIPTION=".escapeshellarg($description)." IMPORTANCE=".escapeshellarg($importance)." CONTENT=".escapeshellarg($message)." LINK=".escapeshellarg($fqdnlink)." bash ".$agent);};}};
|
||||
break;
|
||||
|
||||
|
@@ -16,7 +16,7 @@ case "$1" in
|
||||
else
|
||||
echo "Not available"
|
||||
fi;
|
||||
pgrep -f "/sbin/reiserfsck $2" >/dev/null
|
||||
pgrep --ns $$ -f "/sbin/reiserfsck $2" >/dev/null
|
||||
;;
|
||||
'cancel')
|
||||
pkill -f "/sbin/reiserfsck $2"
|
||||
|
@@ -99,7 +99,7 @@ if [[ -x /etc/rc.d/rc.acpid && -r /var/run/acpid.pid ]]; then # quit
|
||||
fi
|
||||
|
||||
# Kill all processes.
|
||||
OMITPIDS="$(for P in $(pgrep mdmon); do echo -o $P; done)" # Don't kill mdmon
|
||||
OMITPIDS="$(for P in $(pgrep --ns $$ mdmon); do echo -o $P; done)" # Don't kill mdmon
|
||||
log "Sending all processes the SIGHUP signal."
|
||||
run killall5 -1 $OMITPIDS
|
||||
log "Waiting for processes to hang up"
|
||||
|
@@ -79,7 +79,7 @@ abort() {
|
||||
/bin/umount -a
|
||||
read -p "$1 - press ENTER key to reboot..."
|
||||
/bin/echo
|
||||
/sbin/reboot
|
||||
/sbin/reboot -fd
|
||||
}
|
||||
|
||||
find_device() {
|
||||
|
@@ -69,6 +69,8 @@ if /bin/grep -wq cgroup /proc/filesystems; then
|
||||
# See https://docs.kernel.org/admin-guide/cgroup-v2.html (section Mounting)
|
||||
# Mount cgroup2 filesystem
|
||||
/sbin/mount -t cgroup2 -o rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot cgroup2 /sys/fs/cgroup
|
||||
# Start cgroup2 cleanup daemon
|
||||
/etc/rc.d/rc.cgroup2unraid start
|
||||
else
|
||||
# Display message if /sys/fs/cgroup does not exist
|
||||
echo "/sys/fs/cgroup does not exist. cgroup2 cannot be mounted."
|
||||
|
@@ -40,7 +40,7 @@ acpid_stop(){
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
run kill $(cat /var/run/acpid.pid 2>/dev/null)
|
||||
run killall acpid
|
||||
run killall --ns $$ acpid
|
||||
if ! acpid_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
|
@@ -42,11 +42,13 @@ bind_start() {
|
||||
mkdir -p /var/run/named
|
||||
# Make sure that /var/run/named has correct ownership:
|
||||
chown -R ${NAMED_USER}:${NAMED_GROUP} /var/run/named
|
||||
# Make sure that /var/named has correct ownership:
|
||||
chown -R ${NAMED_USER}:${NAMED_GROUP} /var/named
|
||||
if [ -r /etc/rndc.key ]; then
|
||||
# Make sure that /etc/rndc.key has correct ownership:
|
||||
chown ${NAMED_USER}:${NAMED_GROUP} /etc/rndc.key
|
||||
if [ "$NAMED_CHOWN" = "YES" ]; then
|
||||
# Make sure that /var/named has correct ownership:
|
||||
chown -R ${NAMED_USER}:${NAMED_GROUP} /var/named
|
||||
if [ -r /etc/rndc.key ]; then
|
||||
# Make sure that /etc/rndc.key has correct ownership:
|
||||
chown ${NAMED_USER}:${NAMED_GROUP} /etc/rndc.key
|
||||
fi
|
||||
fi
|
||||
# Start named:
|
||||
if [ -x /usr/sbin/named ]; then
|
||||
@@ -94,7 +96,7 @@ bind_stop() {
|
||||
fi
|
||||
# Kill named processes if there are any running:
|
||||
if ps axco command | grep -q -e "^named$"; then
|
||||
echo "Stopping all named processes in this namespace: /bin/killall -SIGTERM --ns \$\$ named"
|
||||
echo "Stopping all named processes in this namespace: /bin/killall -SIGTERM --ns $$ named"
|
||||
/bin/killall -SIGTERM --ns $$ named 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
75
etc/rc.d/rc.cgroup2unraid
Executable file
75
etc/rc.d/rc.cgroup2unraid
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# script: rc.cgroup2unraid
|
||||
#
|
||||
# start/stop/status/restart/run Unraid cgroup2 cleanup:
|
||||
#
|
||||
# LimeTech - created for Unraid OS
|
||||
# /etc/rc.d/rc.cgroup2unraid
|
||||
|
||||
DAEMON="Unraid cgroup2 cleanup daemon"
|
||||
CGROUP2="/usr/libexec/unraid/cgroup2-unraid"
|
||||
PID="/var/run/cgroup2-unraid.pid"
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
|
||||
|
||||
cgroup2daemon_running(){
|
||||
sleep 0.1
|
||||
[[ $(pgrep -cf $CGROUP2) -gt 0 ]]
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if cgroup2daemon_running ; then
|
||||
REPLY="Already started"
|
||||
else
|
||||
$CGROUP2 --daemon
|
||||
echo $(pgrep -f $CGROUP2) > $PID
|
||||
if cgroup2daemon_running; then
|
||||
REPLY="Started"
|
||||
else
|
||||
REPLY="Failed"
|
||||
fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
;;
|
||||
stop)
|
||||
if ! cgroup2daemon_running ; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
log "Stopping $DAEMON..."
|
||||
kill $(cat $PID)
|
||||
if cgroup2daemon_running; then
|
||||
REPLY="Failed"
|
||||
else
|
||||
REPLY="Stopped"
|
||||
fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
;;
|
||||
status)
|
||||
if cgroup2daemon_running ; then
|
||||
echo "$DAEMON running"
|
||||
else
|
||||
echo "$DAEMON not running"
|
||||
if [ -f $PID ]; then
|
||||
rm -f $PID
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
run)
|
||||
echo "Cleaning up cgroups..."
|
||||
$CGROUP2
|
||||
echo "Done!"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $BASENAME start|stop|status|restart|run"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
@@ -15,7 +15,7 @@ PIDFILE="/var/run/dnsmasq.pid"
|
||||
|
||||
dnsmasq_running(){
|
||||
sleep 0.1
|
||||
pgrep -l -F $PIDFILE 2>/dev/null | grep -q dnsmasq
|
||||
pgrep --ns $$ -l -F $PIDFILE 2>/dev/null | grep -q dnsmasq
|
||||
}
|
||||
|
||||
dnsmasq_start(){
|
||||
|
@@ -127,7 +127,7 @@ all_containers(){
|
||||
|
||||
# Running containers
|
||||
running_containers(){
|
||||
docker ps --format='{{.Names}}' 2>/dev/null
|
||||
docker ps --format='{{.Names}} {{.Labels}}' 2>/dev/null | grep 'net.unraid.docker.managed=' | awk '{print $1}'
|
||||
}
|
||||
|
||||
# Network driver
|
||||
@@ -264,15 +264,19 @@ docker_network_start(){
|
||||
USER_NETWORKS=$(docker inspect --format='{{range $key,$value:=.NetworkSettings.Networks}}{{$key}};{{if $value.IPAMConfig}}{{if $value.IPAMConfig.IPv4Address}}{{$value.IPAMConfig.IPv4Address}}{{end}}{{if $value.IPAMConfig.IPv6Address}},{{$value.IPAMConfig.IPv6Address}}{{end}}{{end}} {{end}}' $CONTAINER)
|
||||
for ROW in $USER_NETWORKS; do
|
||||
ROW=(${ROW/;/ })
|
||||
MY_NETWORK=${ROW[0]}
|
||||
MY_IP=${ROW[1]/,/;}
|
||||
if [[ -n $MY_NETWORK && $MY_NETWORK != $MY_NETWORK ]]; then
|
||||
LABEL=${MY_NETWORK//[0-9.]/}
|
||||
if [[ $STOCK =~ $LABEL && $LABEL != ${PORT:0:-1} ]]; then
|
||||
MY_NETWORK=${MY_NETWORK/$LABEL/${PORT:0:-1}}
|
||||
USER_NETWORK=${ROW[0]}
|
||||
USER_IP=${ROW[1]/,/;}
|
||||
if [[ -n $USER_NETWORK && $USER_NETWORK != $MY_NETWORK ]]; then
|
||||
LABEL=${USER_NETWORK//[0-9.]/}
|
||||
IF_NO_PARTS=${USER_NETWORK#"$LABEL"}
|
||||
IF_NO=${IF_NO_PARTS%%.*}
|
||||
if [[ $STOCK =~ $LABEL && $IF_NO -gt 0 ]]; then
|
||||
USER_NETWORK=$USER_NETWORK
|
||||
elif [[ $STOCK =~ $LABEL && $LABEL != ${PORT:0:-1} ]]; then
|
||||
USER_NETWORK=${USER_NETWORK/$LABEL/${PORT:0:-1}}
|
||||
fi
|
||||
log "container $CONTAINER has an additional network that will be restored: $MY_NETWORK"
|
||||
NETRESTORE[$MY_NETWORK]="$CONTAINER,$MY_IP ${NETRESTORE[$MY_NETWORK]}"
|
||||
log "container $CONTAINER has an additional network that will be restored: $USER_NETWORK"
|
||||
NETRESTORE[$USER_NETWORK]="$CONTAINER,$USER_IP ${NETRESTORE[$USER_NETWORK]}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
@@ -527,9 +531,7 @@ docker_container_stop(){
|
||||
log "Stopping containers..."
|
||||
if ! docker_running; then return 1; fi
|
||||
[[ -n $(running_containers) ]] && docker stop --time=${DOCKER_TIMEOUT:-10} $(running_containers) >/dev/null
|
||||
# Kill containers if still running
|
||||
docker kill $(docker ps -q) 2>/dev/null
|
||||
log "Containers stopped."
|
||||
log "Unraid managed containers stopped."
|
||||
}
|
||||
|
||||
docker_service_start(){
|
||||
@@ -564,7 +566,9 @@ docker_service_stop(){
|
||||
if [[ -r $DOCKER_PIDFILE ]]; then
|
||||
# Try to stop dockerd gracefully
|
||||
kill $(docker_pid) 2>/dev/null
|
||||
TIMER=15
|
||||
# show waiting message
|
||||
echo "Waiting 30 seconds for $DAEMON to die."
|
||||
TIMER=30
|
||||
# must ensure daemon has exited
|
||||
while [[ $TIMER -gt 0 ]]; do
|
||||
sleep 1
|
||||
@@ -579,8 +583,6 @@ docker_service_stop(){
|
||||
# signal successful stop
|
||||
TIMER=-1
|
||||
else
|
||||
# show waiting message
|
||||
echo "$DAEMON... Waiting to die."
|
||||
((TIMER--))
|
||||
fi
|
||||
done
|
||||
|
@@ -29,7 +29,7 @@ PIDFILE="/run/elogind.pid"
|
||||
|
||||
elogind_running(){
|
||||
sleep 0.1
|
||||
pgrep -l -F $PIDFILE 2>/dev/null | grep -q elogind
|
||||
pgrep --ns $$ -l -F $PIDFILE 2>/dev/null | grep -q elogind
|
||||
}
|
||||
|
||||
elogind_start(){
|
||||
|
@@ -35,7 +35,7 @@ inetd_stop() {
|
||||
if ! inetd_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
run killall inetd
|
||||
run killall --ns $$ inetd
|
||||
if ! inetd_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
|
@@ -60,6 +60,9 @@ vmlist(){
|
||||
waitfor(){
|
||||
local C=0
|
||||
while [[ $C -lt $TIMEOUT && $(virsh list --state-$1 | awk "NR>2 && /${2:-^.+$}/" | wc -l) -gt 0 ]]; do
|
||||
if [ $C -eq 0 ]; then # echo Timeout info just one time and only if virsh returned something
|
||||
log "Waiting $TIMEOUT seconds for VMs with state: $1"
|
||||
fi
|
||||
((C++))
|
||||
sleep 1
|
||||
done
|
||||
|
@@ -74,7 +74,7 @@ mcelog_stop(){
|
||||
if ! mcelog_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
killall -TERM $MCELOG
|
||||
killall --ns $$ -TERM $MCELOG
|
||||
if ! mcelog_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
elif [[ $MCELOG_MODE == trigger && -f $TRIGGER ]]; then
|
||||
|
@@ -52,7 +52,7 @@ dbus_stop(){
|
||||
else
|
||||
run kill $(cat $PIDFILE)
|
||||
# Just in case:
|
||||
run killall dbus-daemon
|
||||
run killall --ns $$ dbus-daemon
|
||||
rm -f $PIDFILE
|
||||
if ! dbus_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
@@ -65,7 +65,7 @@ dbus_reload(){
|
||||
pid=$(cat $PIDFILE)
|
||||
run kill -HUP $pid
|
||||
else
|
||||
run killall -HUP dbus-daemon
|
||||
run killall --ns $$ -HUP dbus-daemon
|
||||
fi
|
||||
log "$DAEMON... Reloaded."
|
||||
}
|
||||
|
@@ -104,11 +104,11 @@ nfsd_stop(){
|
||||
if ! nfsd_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
killall rpc.mountd 2>/dev/null
|
||||
killall nfsd 2>/dev/null
|
||||
killall --ns $$ rpc.mountd 2>/dev/null
|
||||
killall --ns $$ nfsd 2>/dev/null
|
||||
sleep 1
|
||||
killall -9 nfsd 2>/dev/null
|
||||
killall rpc.rquotad 2>/dev/null
|
||||
killall --ns $$ -9 nfsd 2>/dev/null
|
||||
killall --ns $$ rpc.rquotad 2>/dev/null
|
||||
run $EXPORTFS -au
|
||||
if ! nfsd_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
|
@@ -18,6 +18,7 @@
|
||||
DAEMON="Nginx server daemon"
|
||||
CALLER="nginx"
|
||||
NGINX="/usr/sbin/nginx"
|
||||
TS="/usr/local/sbin/tailscale"
|
||||
PID="/var/run/nginx.pid"
|
||||
SSL="/boot/config/ssl"
|
||||
CONF="/etc/nginx/nginx.conf"
|
||||
@@ -26,7 +27,13 @@ SERVERS="/etc/nginx/conf.d/servers.conf"
|
||||
LOCATIONS="/etc/nginx/conf.d/locations.conf"
|
||||
INI="/var/local/emhttp/nginx.ini.new"
|
||||
CERTPATH="$SSL/certs/certificate_bundle.pem"
|
||||
TSCERTPATH="$SSL/certs/ts_bundle.pem"
|
||||
MYSERVERS="/boot/config/plugins/dynamix.my.servers/myservers.cfg"
|
||||
DEFAULTS="/etc/default/nginx"
|
||||
|
||||
# Load defaults
|
||||
# Defines NGINX_CUSTOMFA for custom Content-Security-Policy frame-ancestors url
|
||||
[[ -r $DEFAULTS ]] && . $DEFAULTS
|
||||
|
||||
# hold server names
|
||||
SERVER_NAMES=()
|
||||
@@ -105,6 +112,7 @@ redirect(){
|
||||
[[ $(ipv $ADDR) == 6 ]] && HOST="[$ADDR]"
|
||||
[[ -n $HOST ]] && echo "${T}listen $HOST:$*; # $(show $ADDR)"
|
||||
done
|
||||
echo "${T}add_header Content-Security-Policy \"frame-ancestors 'self' $NGINX_CUSTOMFA\";"
|
||||
echo "${T}return 302 https://\$host:$PORTSSL\$request_uri;"
|
||||
echo "}"
|
||||
;;
|
||||
@@ -116,6 +124,7 @@ redirect(){
|
||||
if [[ -n $HOST ]]; then
|
||||
echo "server {"
|
||||
echo "${T}listen $HOST:$*; # $(show $ADDR)"
|
||||
echo "${T}add_header Content-Security-Policy \"frame-ancestors 'self' $NGINX_CUSTOMFA\";"
|
||||
echo "${T}return 302 https://$(fqdn $ADDR)$PORTSSL_URL\$request_uri;"
|
||||
echo "}"
|
||||
fi
|
||||
@@ -154,6 +163,7 @@ build_servers(){
|
||||
server {
|
||||
$(listen lo)
|
||||
#
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $NGINX_CUSTOMFA";
|
||||
include /etc/nginx/conf.d/locations.conf;
|
||||
}
|
||||
EOF
|
||||
@@ -169,6 +179,7 @@ build_servers(){
|
||||
server {
|
||||
$(listen $PORT default_server)
|
||||
#
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $NGINX_CUSTOMFA";
|
||||
location ~ /wsproxy/$PORT/ { return 403; }
|
||||
include /etc/nginx/conf.d/locations.conf;
|
||||
}
|
||||
@@ -182,6 +193,7 @@ build_servers(){
|
||||
server {
|
||||
$(listen $PORTSSL ssl default_server)
|
||||
http2 on;
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $SELFCERTFA $NGINX_CUSTOMFA";
|
||||
# Ok to use concatenated pem files; nginx will do the right thing.
|
||||
ssl_certificate $SELFCERTPATH;
|
||||
ssl_certificate_key $SELFCERTPATH;
|
||||
@@ -227,6 +239,7 @@ build_servers(){
|
||||
server {
|
||||
$(listen $PORTSSL ssl default_server)
|
||||
http2 on;
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $SELFCERTFA $NGINX_CUSTOMFA";
|
||||
# Ok to use concatenated pem files; nginx will do the right thing.
|
||||
ssl_certificate $SELFCERTPATH;
|
||||
ssl_certificate_key $SELFCERTPATH;
|
||||
@@ -248,6 +261,7 @@ build_servers(){
|
||||
server {
|
||||
$(listen $PORTSSL ssl default_server)
|
||||
http2 on;
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $SELFCERTFA $NGINX_CUSTOMFA";
|
||||
# Ok to use concatenated pem files; nginx will do the right thing.
|
||||
ssl_certificate $SELFCERTPATH;
|
||||
ssl_certificate_key $SELFCERTPATH;
|
||||
@@ -270,6 +284,7 @@ build_servers(){
|
||||
$(listen $PORTSSL ssl)
|
||||
http2 on;
|
||||
server_name ${SERVER_NAMES[@]};
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $CERTFA $NGINX_CUSTOMFA";
|
||||
# Ok to use concatenated pem files; nginx will do the right thing.
|
||||
ssl_certificate $CERTPATH;
|
||||
ssl_certificate_key $CERTPATH;
|
||||
@@ -285,6 +300,39 @@ build_servers(){
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
if [[ -n $TSFQDN ]]; then
|
||||
cat <<- EOF >>$SERVERS
|
||||
#
|
||||
# Redirect Tailscale http requests to https
|
||||
# ex: http://tower.magicDNS.ts.net -> https://tower.magicDNS.ts.net
|
||||
#
|
||||
server {
|
||||
$(listen $PORT)
|
||||
server_name $TSFQDN;
|
||||
return 302 https://$TSFQDN$PORTSSL_URL$request_uri;
|
||||
}
|
||||
#
|
||||
# Port settings for https using Tailscale cert
|
||||
# ex: https://tower.magicDNS.ts.net
|
||||
#
|
||||
server {
|
||||
$(listen $PORTSSL ssl http2)
|
||||
server_name $TSFQDN;
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' $TSFA $NGINX_CUSTOMFA";
|
||||
# Ok to use concatenated pem files; nginx will do the right thing.
|
||||
ssl_certificate $TSCERTPATH;
|
||||
ssl_certificate_key $TSCERTPATH;
|
||||
ssl_trusted_certificate $TSCERTPATH;
|
||||
#
|
||||
# OCSP stapling
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
#
|
||||
location ~ /wsproxy/$PORTSSL/ { return 403; }
|
||||
include /etc/nginx/conf.d/locations.conf;
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
# build our locations
|
||||
@@ -386,7 +434,9 @@ build_locations(){
|
||||
#
|
||||
# pass PHP scripts to FastCGI server listening on unix:/var/run/php-fpm.sock
|
||||
#
|
||||
location ~ \.php$ {
|
||||
location ~ ^(.+\.php)(.*)$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(.*)$;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
include fastcgi_params;
|
||||
}
|
||||
#
|
||||
@@ -493,11 +543,15 @@ build_ssl(){
|
||||
fi
|
||||
# determine if OCSP stapling should be enabled for this cert
|
||||
[[ -n $(openssl x509 -noout -ocsp_uri -in "$SELFCERTPATH") ]] && SELFCERTSTAPLE=on || SELFCERTSTAPLE=off
|
||||
# define CSP frame-ancestors for the self-signed cert
|
||||
[[ -n $LOCAL_TLD ]] && [[ "$LOCAL_TLD" != "local" ]] && SELFCERTFA="https://*.$LOCAL_TLD/"
|
||||
|
||||
# handle Certificate Authority signed cert if present
|
||||
if [[ -f $CERTPATH ]]; then
|
||||
# extract common name from cert
|
||||
CERTNAME=$(openssl x509 -noout -subject -nameopt multiline -in $CERTPATH | sed -n 's/ *commonName *= //p')
|
||||
# define CSP frame-ancestors for cert
|
||||
CERTFA="https://*.${CERTNAME#*.}/"
|
||||
# check if Remote Access is enabled and fetch WANIP
|
||||
if [[ -L /usr/local/sbin/unraid-api ]] && grep -qs 'wanaccess="yes"' $MYSERVERS && ! grep -qs 'username=""' $MYSERVERS; then
|
||||
WANACCESS=yes
|
||||
@@ -506,6 +560,8 @@ build_ssl(){
|
||||
fi
|
||||
if [[ $CERTNAME == *\.myunraid\.net ]]; then
|
||||
# wildcard LE certificate
|
||||
# add Unraid Connect to CSP frame-ancestors for a myunraid.net cert
|
||||
CERTFA+=" https://connect.myunraid.net/"
|
||||
[[ -n $LANIP ]] && LANFQDN=$(fqdn $LANIP) SERVER_NAMES+=($LANFQDN)
|
||||
[[ -n $LANIP6 ]] && LANFQDN6=$(fqdn $LANIP6) SERVER_NAMES+=($LANFQDN6)
|
||||
# check if remote access enabled
|
||||
@@ -526,7 +582,7 @@ build_ssl(){
|
||||
done
|
||||
fi
|
||||
else
|
||||
# custom certificate
|
||||
# custom certificate, this would be better as SELFCERTPATH
|
||||
LANFQDN=${CERTNAME/\*/$LANNAME} # support wildcard custom certs
|
||||
SERVER_NAMES+=($LANFQDN)
|
||||
fi
|
||||
@@ -534,6 +590,23 @@ build_ssl(){
|
||||
[[ -n $(openssl x509 -noout -ocsp_uri -in "$CERTPATH") ]] && CERTSTAPLE=on || CERTSTAPLE=off
|
||||
fi
|
||||
|
||||
# handle TS cert if present
|
||||
if [[ -f "$TSCERTPATH" ]]; then
|
||||
# confirm TS is intalled and running
|
||||
if [[ -x $TS ]] && $TS status &>/dev/null; then
|
||||
# extract common name from cert
|
||||
TSFQDN1=$(openssl x509 -noout -subject -nameopt multiline -in "$TSCERTPATH" | sed -n 's/ *commonName *= //p')
|
||||
# get tailscale domain
|
||||
TSFQDN2=$($TS status -json | jq ' .Self.DNSName' | tr -d '"' | sed 's/.$//')
|
||||
if [[ -n "$TSFQDN1" ]] && [[ "$TSFQDN1" == "$TSFQDN2" ]]; then
|
||||
# common name and tailscale domain are equal and not empty, the cert is valid, use it
|
||||
TSFQDN=$TSFQDN1
|
||||
# define CSP frame-ancestors for TS cert
|
||||
TSFA="https://*.${TSFQDN#*.}/"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# build servers configuration file
|
||||
build_servers
|
||||
# build locations configuration file
|
||||
@@ -570,6 +643,8 @@ build_ssl(){
|
||||
echo "NGINX_WANIP6=\"$WANIP6\"" >>$INI
|
||||
echo "NGINX_WANFQDN=\"$WANFQDN\"" >>$INI
|
||||
echo "NGINX_WANFQDN6=\"$WANFQDN6\"" >>$INI
|
||||
# defined if ts_bundle.pem present:
|
||||
echo "NGINX_TAILSCALEFQDN=\"$TSFQDN\"" >>$INI
|
||||
# add included interfaces
|
||||
for NET in ${!NET_FQDN[@]}; do
|
||||
echo "NGINX_${NET^^}FQDN=\"${NET_FQDN[$NET]}\"" >>$INI
|
||||
|
@@ -35,7 +35,7 @@ ntpd_build(){
|
||||
[[ $IPV6 == no ]] && echo "interface ignore ipv6" >>$CONF
|
||||
# add listen interfaces
|
||||
for NET in $BIND; do
|
||||
echo "interface listen $NET # $(show $NET)" >>$CONF
|
||||
echo "interface listen $(show $NET) # $NET" >>$CONF
|
||||
done
|
||||
fi
|
||||
# add configured NTP servers
|
||||
@@ -76,7 +76,7 @@ ntpd_stop(){
|
||||
kill -HUP $(cat /var/run/ntpd.pid)
|
||||
rm -f /var/run/ntpd.pid
|
||||
else
|
||||
killall -HUP -q ntpd
|
||||
killall --ns $$ -HUP -q ntpd
|
||||
fi
|
||||
if ! ntpd_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
@@ -93,7 +93,7 @@ ntpd_restart(){
|
||||
}
|
||||
|
||||
ntpd_reload(){
|
||||
killall -HUP -q ntpd
|
||||
killall --ns $$ -HUP -q ntpd
|
||||
. <(fromdos <$IDENT)
|
||||
ntpd_build
|
||||
$NTPD $OPTIONS 2>/dev/null
|
||||
@@ -101,11 +101,8 @@ ntpd_reload(){
|
||||
|
||||
ntpd_update(){
|
||||
# 0 = update needed, 1 = no action
|
||||
# if ! ntpd_running; then exit 1; fi
|
||||
# if check && [[ "$(this 'interface listen')" == "$BIND" ]]; then exit 1; else exit 0; fi
|
||||
# upon network change always return 'update needed' - subsequent reload stops ntp complaining
|
||||
# when multiple interfaces have same IP address (such as shim-br0).
|
||||
if ntpd_running; then exit 0; else exit 1; fi
|
||||
if ! ntpd_running; then exit 1; fi
|
||||
if check && [[ "$(this 'interface listen')" == "$BIND" ]]; then exit 1; else exit 0; fi
|
||||
}
|
||||
|
||||
ntpd_status(){
|
||||
|
@@ -80,13 +80,13 @@ rpc_stop(){
|
||||
if ! rpc_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
killall rpc.statd 2>/dev/null
|
||||
killall --ns $$ rpc.statd 2>/dev/null
|
||||
sleep 1
|
||||
killall rpcbind 2>/dev/null
|
||||
killall --ns $$ rpcbind 2>/dev/null
|
||||
sleep 1
|
||||
killall -9 rpc.statd 2>/dev/null # make sure :)
|
||||
killall --ns $$ -9 rpc.statd 2>/dev/null # make sure :)
|
||||
sleep 1
|
||||
killall -9 rpcbind 2>/dev/null # make sure :)
|
||||
killall --ns $$ -9 rpcbind 2>/dev/null # make sure :)
|
||||
if ! rpc_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
|
@@ -13,7 +13,7 @@
|
||||
# Bergware - modified for Unraid OS, October 2023
|
||||
|
||||
DAEMON="Syslog server daemon"
|
||||
PIDFILE=/var/run/rsyslogd.pid # native rsyslogd pid file
|
||||
PIDFILE="/var/run/rsyslogd.pid" # native rsyslogd pid file
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
@@ -29,7 +29,14 @@ create_xconsole(){
|
||||
|
||||
rsyslogd_running(){
|
||||
sleep 0.1
|
||||
ps axc | grep -q ' rsyslogd'
|
||||
if pgrep --ns $$ -x rsyslogd &>/dev/null; then
|
||||
# Daemon is alive
|
||||
return 0
|
||||
else
|
||||
# Daemon is dead (remove stale PID file)
|
||||
[[ -f $PIDFILE ]] && rm -f "$PIDFILE"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
rsyslogd_start(){
|
||||
@@ -38,7 +45,7 @@ rsyslogd_start(){
|
||||
if rsyslogd_running; then
|
||||
REPLY="Already started"
|
||||
else
|
||||
run /usr/sbin/rsyslogd -i $PIDFILE
|
||||
run /usr/sbin/rsyslogd -i "$PIDFILE"
|
||||
if rsyslogd_running; then REPLY="Started"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
@@ -50,8 +57,8 @@ rsyslogd_stop(){
|
||||
if ! rsyslogd_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
run killall rsyslogd
|
||||
rm -f $PIDFILE
|
||||
run killall --ns $$ rsyslogd
|
||||
sleep 2
|
||||
if ! rsyslogd_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
@@ -67,8 +74,12 @@ rsyslogd_restart(){
|
||||
rsyslogd_reload(){
|
||||
log "Reloading $DAEMON..."
|
||||
local REPLY
|
||||
REPLY="Reloaded"
|
||||
[[ -f $PIDFILE ]] && run kill -HUP $(cat $PIDFILE) || REPLY="Failed"
|
||||
if ! rsyslogd_running; then
|
||||
REPLY="Not running"
|
||||
else
|
||||
REPLY="Reloaded"
|
||||
run killall -HUP --ns $$ rsyslogd || REPLY="Failed"
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,14 @@ PRIVATE="/var/lib/samba/private"
|
||||
|
||||
samba_running(){
|
||||
sleep 0.1
|
||||
[[ $(pgrep -cf $SMBD) -gt 0 ]]
|
||||
[[ $(pgrep --ns $$ -cf $SMBD) -gt 0 ]]
|
||||
}
|
||||
|
||||
samba_waitfor_shutdown(){
|
||||
for i in {1..5}; do
|
||||
if ! samba_running; then break; fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
samba_settings(){
|
||||
@@ -146,9 +153,17 @@ samba_stop(){
|
||||
if ! samba_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
run killall smbd nmbd wsdd2 winbindd
|
||||
REPLY="Stopped"
|
||||
# stop gracefully with SIGTERM
|
||||
run killall --ns $$ smbd nmbd wsdd2 winbindd
|
||||
samba_waitfor_shutdown
|
||||
if samba_running; then
|
||||
REPLY="Killed"
|
||||
# stop forcibly with SIGKILL
|
||||
run killall --ns $$ -SIGKILL smbd nmbd wsdd2 winbindd
|
||||
samba_waitfor_shutdown
|
||||
fi
|
||||
if ! samba_running; then
|
||||
REPLY="Stopped"
|
||||
# save samba 'secrets' file if changed
|
||||
if [[ -e $PRIVATE/secrets.tdb ]]; then
|
||||
rm -f /tmp/emhttp/secrets.tdb
|
||||
@@ -171,14 +186,12 @@ samba_restart(){
|
||||
}
|
||||
|
||||
samba_reload(){
|
||||
killall smbd nmbd wsdd2 winbindd 2>/dev/null
|
||||
killall --ns $$ wsdd2 2>/dev/null
|
||||
# update settings
|
||||
samba_settings
|
||||
# restart services
|
||||
$SMBD -D 2>/dev/null
|
||||
[[ $USE_NETBIOS == yes ]] && $NMBD -D 2>/dev/null
|
||||
# reload services with smbcontrol
|
||||
smbcontrol all reload-config 2>/dev/null
|
||||
[[ $USE_WSD == yes ]] && $WSDD2 -d ${WSD2_OPT## } 2>/dev/null
|
||||
$WINBINDD -D 2>/dev/null
|
||||
}
|
||||
|
||||
samba_update(){
|
||||
|
@@ -25,7 +25,7 @@ smart_stop() {
|
||||
if [ -r /run/smartd.pid ]; then
|
||||
kill $(cat /run/smartd.pid)
|
||||
else
|
||||
killall smartd
|
||||
killall --ns $$ smartd
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,8 @@ SSH_ETC="/etc/ssh"
|
||||
|
||||
sshd_running(){
|
||||
sleep 0.1
|
||||
[[ $(pgrep -cf $SSHD) -gt 0 ]]
|
||||
# get all pids from sshd
|
||||
[[ $(pgrep --ns $$ -cf $SSHD) -gt 0 ]]
|
||||
}
|
||||
|
||||
sshd_build(){
|
||||
@@ -67,7 +68,7 @@ sshd_stop(){
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
log "Stopping $DAEMON..."
|
||||
killall sshd
|
||||
killall --ns $$ sshd
|
||||
if ! sshd_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
|
@@ -191,7 +191,7 @@ case "$1" in
|
||||
'force-stop')
|
||||
log "Stopping udevd"
|
||||
udevadm control --exit
|
||||
killall udevd 2>/dev/null
|
||||
killall --ns $$ udevd 2>/dev/null
|
||||
;;
|
||||
'force-restart')
|
||||
log "Restarting udevd"
|
||||
|
@@ -58,7 +58,7 @@ wsdd2_stop(){
|
||||
if ! wsdd2_running; then
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
killall wsdd2
|
||||
killall --ns $$ wsdd2
|
||||
if ! wsdd2_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
|
@@ -117,7 +117,7 @@ empty() {
|
||||
killtree() {
|
||||
local pid=$1 child
|
||||
|
||||
for child in $(pgrep -P $pid); do
|
||||
for child in $(pgrep --ns $$ -P $pid); do
|
||||
killtree $child
|
||||
done
|
||||
[ $pid -ne $$ ] && kill -TERM $pid
|
||||
|
313
share/docker/tailscale_container_hook
Executable file
313
share/docker/tailscale_container_hook
Executable file
@@ -0,0 +1,313 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2024, Lime Technology
|
||||
# Copyright 2024, Christoph Hummer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 2,
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
exec_entrypoint() {
|
||||
echo "Starting container..."
|
||||
echo
|
||||
echo "======================="
|
||||
echo
|
||||
eval "exec ${ORG_ENTRYPOINT} ${ORG_CMD} ${ORG_POSTARGS}"
|
||||
}
|
||||
|
||||
error_handler() {
|
||||
echo "ERROR: Unraid Docker Hook script throw an error!"
|
||||
echo " Starting container without Tailscale!"
|
||||
echo
|
||||
exec_entrypoint
|
||||
}
|
||||
|
||||
echo "======================="
|
||||
echo
|
||||
echo "Executing Unraid Docker Hook for Tailscale"
|
||||
echo
|
||||
|
||||
if [ ! -f /usr/bin/tailscale ] || [ ! -f /usr/bin/tailscaled ]; then
|
||||
if [ ! -z "${TAILSCALE_EXIT_NODE_IP}" ]; then
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
echo "ERROR: Device /dev/net/tun not found!"
|
||||
echo " Make sure to pass through /dev/net/tun to the container."
|
||||
error_handler
|
||||
fi
|
||||
INSTALL_IPTABLES="iptables "
|
||||
fi
|
||||
|
||||
echo "Detecting Package Manager..."
|
||||
if which apt-get >/dev/null 2>&1; then
|
||||
echo "Detected Advanced Package Tool!"
|
||||
PACKAGES_UPDATE="apt-get update"
|
||||
PACKAGES_INSTALL="apt-get -y install --no-install-recommends"
|
||||
elif which apk >/dev/null 2>&1; then
|
||||
echo "Detected Alpine Package Keeper!"
|
||||
PACKAGES_UPDATE="apk update"
|
||||
PACKAGES_INSTALL="apk add"
|
||||
elif which pacman >/dev/null 2>&1; then
|
||||
echo "Detected pacman Package Manager!"
|
||||
PACKAGES_INSTALL="pacman -Syu --noconfirm"
|
||||
else
|
||||
echo "ERROR: Detection from Package Manager failed!"
|
||||
error_handler
|
||||
fi
|
||||
|
||||
if [ "${TAILSCALE_TROUBLESHOOTING}" = "true" ]; then
|
||||
if which apt-get >/dev/null 2>&1; then
|
||||
PACKAGES_TROUBLESHOOTING="curl dnsutils iputils-ping "
|
||||
elif which apk >/dev/null 2>&1; then
|
||||
PACKAGES_TROUBLESHOOTING="curl bind-tools iputils-ping "
|
||||
elif which pacman >/dev/null 2>&1; then
|
||||
PACKAGES_TROUBLESHOOTING="curl dnsutils iputils "
|
||||
fi
|
||||
echo "Tailscale Troubleshooting enabled!"
|
||||
echo "Installing additional packages: $(echo "${PACKAGES_TROUBLESHOOTING}" | sed 's/[[:blank:]]*$//' | sed 's/ /, /g')"
|
||||
fi
|
||||
|
||||
echo "Installing packages..."
|
||||
echo "Please wait..."
|
||||
if [ ! -z "${PACKAGES_UPDATE}" ]; then
|
||||
UPDATE_LOG=$(${PACKAGES_UPDATE} 2>&1)
|
||||
fi
|
||||
INSTALL_LOG=$(${PACKAGES_INSTALL} jq wget ${INSTALL_IPTABLES}${PACKAGES_TROUBLESHOOTING} 2>&1)
|
||||
INSTALL_RESULT=$?
|
||||
|
||||
if [ "${INSTALL_RESULT}" -eq 0 ]; then
|
||||
echo "Packages installed!"
|
||||
unset INSTALL_LOG
|
||||
else
|
||||
echo "ERROR: Installing packages!"
|
||||
echo "${UPDATE_LOG}"
|
||||
echo "${INSTALL_LOG}"
|
||||
error_handler
|
||||
fi
|
||||
|
||||
if [ "${INSTALL_IPTABLES}" = "iptables " ]; then
|
||||
if ! iptables -L >/dev/null 2>&1; then
|
||||
echo "ERROR: Cap: NET_ADMIN not available!"
|
||||
echo " Make sure to add --cap-add=NET_ADMIN to the Extra Parameters"
|
||||
error_handler
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Tailscale not found, downloading..."
|
||||
echo "Please wait..."
|
||||
|
||||
TAILSCALE_VERSION=$(wget -qO- 'https://pkgs.tailscale.com/stable/?mode=json' | jq -r '.TarballsVersion')
|
||||
|
||||
if [ -z "${TAILSCALE_VERSION}" ]; then
|
||||
echo "ERROR: Can't get Tailscale JSON"
|
||||
error_handler
|
||||
fi
|
||||
|
||||
if [ ! -d /tmp/tailscale ]; then
|
||||
mkdir -p /tmp/tailscale
|
||||
fi
|
||||
|
||||
if wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/tailscale/tailscale.tgz "https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_amd64.tgz" ; then
|
||||
echo "Download from Tailscale version ${TAILSCALE_VERSION} successful!"
|
||||
else
|
||||
echo "ERROR: Download from Tailscale version ${TAILSCALE_VERSION} failed!"
|
||||
rm -rf /tmp/tailscale
|
||||
error_handler
|
||||
fi
|
||||
|
||||
tar -C /tmp/tailscale -xf /tmp/tailscale/tailscale.tgz
|
||||
cp /tmp/tailscale/tailscale_${TAILSCALE_VERSION}_amd64/tailscale /usr/bin/tailscale
|
||||
cp /tmp/tailscale/tailscale_${TAILSCALE_VERSION}_amd64/tailscaled /usr/bin/tailscaled
|
||||
rm -rf /tmp/tailscale
|
||||
|
||||
echo "Installation Done!"
|
||||
else
|
||||
echo "Tailscale found, continuing..."
|
||||
fi
|
||||
|
||||
unset TSD_PARAMS
|
||||
unset TS_PARAMS
|
||||
|
||||
if [ ! -z "${SERVER_DIR}" ]; then
|
||||
TSD_STATE_DIR="${SERVER_DIR}/.tailscale_state"
|
||||
echo "Settings Tailscale state dir to: ${TSD_STATE_DIR}"
|
||||
elif [ ! -z "${DATA_DIR}" ]; then
|
||||
TSD_STATE_DIR="${DATA_DIR}/.tailscale_state"
|
||||
echo "Settings Tailscale state dir to: ${TSD_STATE_DIR}"
|
||||
else
|
||||
if [ -z "${TAILSCALE_STATE_DIR}" ]; then
|
||||
TAILSCALE_STATE_DIR="/config/.tailscale_state"
|
||||
fi
|
||||
TSD_STATE_DIR="${TAILSCALE_STATE_DIR}"
|
||||
echo "Settings Tailscale state dir to: ${TSD_STATE_DIR}"
|
||||
fi
|
||||
|
||||
if [ ! -d "${TSD_STATE_DIR}" ]; then
|
||||
mkdir -p ${TSD_STATE_DIR}
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_EXIT_NODE_IP}" ]; then
|
||||
echo "Disabling userspace networking! Tailscale DNS available"
|
||||
echo "Using ${TAILSCALE_EXIT_NODE_IP} as Exit Node! See https://tailscale.com/kb/1103/exit-nodes"
|
||||
TS_PARAMS=" --exit-node=${TAILSCALE_EXIT_NODE_IP}"
|
||||
if [ "${TAILSCALE_ALLOW_LAN_ACCESS}" = "true" ]; then
|
||||
echo "Enabling local LAN Access to the container!"
|
||||
TS_PARAMS="${TS_PARAMS} --exit-node-allow-lan-access"
|
||||
fi
|
||||
else
|
||||
if [ -z "${TAILSCALE_USERSPACE_NETWORKING}" ] || [ "${TAILSCALE_USERSPACE_NETWORKING}" = "true" ]; then
|
||||
echo "Enabling userspace networking! Tailscale DNS not available"
|
||||
TSD_PARAMS="-tun=userspace-networking "
|
||||
else
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
echo "ERROR: Device /dev/net/tun not found!"
|
||||
echo " Make sure to pass through /dev/net/tun to the container and add the"
|
||||
echo " parameter --cap-add=NET_ADMIN to the Extra Parameters!"
|
||||
error_handler
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_ADVERTISE_ROUTES}" ]; then
|
||||
TAILSCALE_ADVERTISE_ROUTES="$(echo ${TAILSCALE_ADVERTISE_ROUTES} | sed 's/ //g')"
|
||||
echo "Advertising custom routes! See https://tailscale.com/kb/1019/subnets#advertise-subnet-routes"
|
||||
TS_PARAMS="${TS_PARAMS} --advertise-routes=${TAILSCALE_ADVERTISE_ROUTES}"
|
||||
fi
|
||||
|
||||
if [ "${TAILSCALE_USE_SSH}" = "true" ]; then
|
||||
echo "Enabling SSH! See https://tailscale.com/kb/1193/tailscale-ssh"
|
||||
TS_PARAMS="${TS_PARAMS} --ssh"
|
||||
fi
|
||||
|
||||
if [ "${TAILSCALE_LOG}" != "false" ]; then
|
||||
TSD_PARAMS="${TSD_PARAMS} >>/var/log/tailscaled 2>&1 "
|
||||
TSD_MSG=" with log file location: /var/log/tailscaled"
|
||||
else
|
||||
TSD_PARAMS="${TSD_PARAMS} >/dev/null 2>&1 "
|
||||
TSD_MSG=" with logging disabled"
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_HOSTNAME}" ]; then
|
||||
echo "Setting host name to \"${TAILSCALE_HOSTNAME}\""
|
||||
TAILSCALE_HOSTNAME="$(echo "$TAILSCALE_HOSTNAME" | tr -d ' ')"
|
||||
TS_PARAMS="${TS_PARAMS} --hostname=${TAILSCALE_HOSTNAME}"
|
||||
fi
|
||||
|
||||
if [ "${TAILSCALE_EXIT_NODE}" = "true" ]; then
|
||||
echo "Configuring container as Exit Node! See https://tailscale.com/kb/1103/exit-nodes"
|
||||
TS_PARAMS="${TS_PARAMS} --advertise-exit-node"
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALED_PARAMS}" ]; then
|
||||
TSD_PARAMS="${TAILSCALED_PARAMS} ${TSD_PARAMS}"
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_PARAMS}" ]; then
|
||||
TS_PARAMS="${TAILSCALE_PARAMS}${TS_PARAMS}"
|
||||
fi
|
||||
|
||||
echo "Starting tailscaled${TSD_MSG}"
|
||||
eval tailscaled -statedir=${TSD_STATE_DIR} ${TSD_PARAMS}&
|
||||
|
||||
echo "Starting tailscale"
|
||||
eval tailscale up ${TS_PARAMS} --reset
|
||||
EXIT_STATUS="$?"
|
||||
|
||||
if [ "${EXIT_STATUS}" != "0" ]; then
|
||||
echo "ERROR: Connecting to Tailscale not successful!"
|
||||
if [ -f /var/log/tailscaled ]; then
|
||||
echo "Please check the logs:"
|
||||
tail -20 /var/log/tailscaled
|
||||
fi
|
||||
error_handler
|
||||
fi
|
||||
unset EXIT_STATUS
|
||||
|
||||
if [ ! -z "${TAILSCALE_SERVE_PORT}" ] && [ "$(tailscale status --json | jq -r '.CurrentTailnet.MagicDNSEnabled')" = "false" ] ; then
|
||||
echo "ERROR: Enable HTTPS on your Tailscale account to use Tailscale Serve/Funnel."
|
||||
echo "See: https://tailscale.com/kb/1153/enabling-https"
|
||||
error_handler
|
||||
fi
|
||||
|
||||
if [ "${TAILSCALE_EXIT_NODE}" = "true" ]; then
|
||||
if [ "$(tailscale status --json | jq -r '.Self.ExitNodeOption')" = "false" ]; then
|
||||
TSIP=$(tailscale status --json | jq -r '.Self.TailscaleIPs[0]')
|
||||
echo "WARNING: Exit Node not yet approved."
|
||||
echo " Navigate to https://login.tailscale.com/admin/machines/${TSIP} and approve it."
|
||||
fi
|
||||
fi
|
||||
|
||||
KEY_EXPIRY=$(tailscale status --json | jq -r '.Self.KeyExpiry')
|
||||
if [ "${KEY_EXPIRY}" != "null" ]; then
|
||||
EXPIRY_EPOCH=$(date -d "${KEY_EXPIRY}" +"%s" 2>/dev/null)
|
||||
CUR_EPOCH=$(date -u +%s)
|
||||
DIFF_EPOCH=$((EXPIRY_EPOCH - CUR_EPOCH))
|
||||
DIFF_DAYS=$((DIFF_EPOCH / 86400))
|
||||
HOST=$(tailscale status --json | jq -r '.Self.HostName')
|
||||
if [ -n "${DIFF_DAYS}" ] && echo "${DIFF_DAYS}" | grep -Eq '^[0-9]+$'; then
|
||||
echo "WARNING: Tailscale Key will expire in ${DIFF_DAYS} days."
|
||||
echo " Navigate to https://login.tailscale.com/admin/machines and 'Disable Key Expiry' for ${HOST}"
|
||||
else
|
||||
echo "ERROR: Tailscale Key expired!"
|
||||
echo " Navigate to https://login.tailscale.com/admin/machines and Renew/Disable Key Expiry for ${HOST}"
|
||||
fi
|
||||
echo "See: https://tailscale.com/kb/1028/key-expiry"
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_ADVERTISE_ROUTES}" ]; then
|
||||
APPROVED_ROUTES="$(tailscale status --json | jq -r '.Self.PrimaryRoutes')"
|
||||
IFS=','
|
||||
set -- ${TAILSCALE_ADVERTISE_ROUTES}
|
||||
ROUTES="$@"
|
||||
for route in ${ROUTES}; do
|
||||
if ! echo "${APPROVED_ROUTES}" | grep -q "${route}"; then
|
||||
NOT_APPROVED="$NOT_APPROVED ${route}"
|
||||
fi
|
||||
done
|
||||
if [ ! -z "${NOT_APPROVED}" ]; then
|
||||
TSIP="$(tailscale status --json | jq -r '.Self.TailscaleIPs[0]')"
|
||||
echo "WARNING: The following route(s) are not approved:${NOT_APPROVED}"
|
||||
echo " Navigate to https://login.tailscale.com/admin/machines/${TSIP} and approve it."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${TAILSCALE_SERVE_PORT}" ]; then
|
||||
if [ ! -z "${TAILSCALE_SERVE_PATH}" ]; then
|
||||
TAILSCALE_SERVE_PATH="=${TAILSCALE_SERVE_PATH}"
|
||||
fi
|
||||
if [ -z "${TAILSCALE_SERVE_PROTOCOL}" ]; then
|
||||
TAILSCALE_SERVE_PROTOCOL="https"
|
||||
fi
|
||||
if [ -z "${TAILSCALE_SERVE_PROTOCOL_PORT}" ]; then
|
||||
TAILSCALE_SERVE_PROTOCOL_PORT="=443"
|
||||
fi
|
||||
if [ "${TAILSCALE_FUNNEL}" = "true" ]; then
|
||||
echo "Enabling Funnel! See https://tailscale.com/kb/1223/funnel"
|
||||
eval tailscale funnel --bg --"${TAILSCALE_SERVE_PROTOCOL}"${TAILSCALE_SERVE_PROTOCOL_PORT}${TAILSCALE_SERVE_PATH} http://localhost:"${TAILSCALE_SERVE_PORT}${TAILSCALE_SERVE_LOCALPATH}" | grep -v "To disable the proxy"
|
||||
else
|
||||
echo "Enabling Serve! See https://tailscale.com/kb/1312/serve"
|
||||
eval tailscale serve --bg --"${TAILSCALE_SERVE_PROTOCOL}"${TAILSCALE_SERVE_PROTOCOL_PORT}${TAILSCALE_SERVE_PATH} http://localhost:"${TAILSCALE_SERVE_PORT}${TAILSCALE_SERVE_LOCALPATH}" | grep -v "To disable the proxy"
|
||||
fi
|
||||
if [ "${TAILSCALE_SERVE_PROTOCOL}" = "https" ]; then
|
||||
TS_DNSNAME="$(tailscale status --json | jq -r '.Self.DNSName' | sed 's/\.$//')"
|
||||
if [ ! -f "${TSD_STATE_DIR}/certs/${TS_DNSNAME}.crt" ] || [ ! -f "${TSD_STATE_DIR}/certs/${TS_DNSNAME}.key" ]; then
|
||||
if [ ! -d "${TSD_STATE_DIR}/certs" ]; then
|
||||
mkdir -p "${TSD_STATE_DIR}/certs"
|
||||
fi
|
||||
echo "Generating Tailscale certs! This can take some time, please wait..."
|
||||
timeout 30 tailscale cert --cert-file="${TSD_STATE_DIR}/certs/${TS_DNSNAME}.crt" --key-file="${TSD_STATE_DIR}/certs/${TS_DNSNAME}.key" "${TS_DNSNAME}" >/dev/null 2>&1
|
||||
EXIT_STATUS="$?"
|
||||
if [ "${EXIT_STATUS}" != "0" ]; then
|
||||
echo "ERROR: Can't generate certificates!"
|
||||
echo "Please check the logs:"
|
||||
tail -10 /var/log/tailscaled
|
||||
else
|
||||
echo "Done!"
|
||||
fi
|
||||
unset EXIT_STATUS
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
exec_entrypoint
|
Reference in New Issue
Block a user