Warn of port conflicts
This commit is contained in:
parent
3b2bd34263
commit
a0aee26e3f
BIN
archive/community.applications-2022.01.01-x86_64-1.txz
Normal file
BIN
archive/community.applications-2022.01.01-x86_64-1.txz
Normal file
Binary file not shown.
|
@ -110,6 +110,7 @@ if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var
|
|||
|
||||
getAllInfo(true);
|
||||
|
||||
|
||||
function tr($string,$ret=false) {
|
||||
$string = str_replace('"',""",str_replace("'","'",_($string)));
|
||||
if ( $ret )
|
||||
|
@ -118,6 +119,7 @@ function tr($string,$ret=false) {
|
|||
echo $string;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
@ -166,6 +168,7 @@ var repoBanner = false;
|
|||
var repoBannerTimer = false;
|
||||
var unRaidFontSize = $("html").css("font-size").replace("px","");
|
||||
var resizeTimer;
|
||||
var portsInUse = <? echo json_encode(getPortsInUse()); ?>;
|
||||
|
||||
$(function(){
|
||||
window.onerror = function(msg,url,lineNo,columnNo, error) {
|
||||
|
@ -227,7 +230,7 @@ $(function(){
|
|||
$(".sidebarClose").on("click",function(e) {
|
||||
closeSidebar();
|
||||
});
|
||||
$(".mainArea").on("click",".actionsButtonContext,.actionsButton,.supportButton,.supportButtonCardContext",function() {
|
||||
$(".mainArea").on("click",".actionsButtonContext,.actionsButton,.supportButton,.supportButtonCardContext,.ca_multiselect",function() {
|
||||
data.actions = true;
|
||||
});
|
||||
$("#searchBox").keydown(function(e) {
|
||||
|
@ -243,7 +246,7 @@ $(function(){
|
|||
closeSidebar();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('.caChangeLog').on("click",function() {disableSort();scrollToTop();caChangeLog();});
|
||||
$('.mainArea').on("click",'.ca_multiselect',function() {enableMultiInstall();});
|
||||
|
||||
|
@ -1910,9 +1913,24 @@ function setFavourite(button) {
|
|||
});
|
||||
}
|
||||
|
||||
function popupInstallXML(xml,type,comment="") {
|
||||
function popupInstallXML(xml,type,comment="",ports="") {
|
||||
event.stopPropagation();
|
||||
saveState();
|
||||
var flag = false;
|
||||
if ( ports ) {
|
||||
ports = JSON.parse(ports);
|
||||
if ( ports ) {
|
||||
ports.forEach(function(port){
|
||||
portsInUse.forEach(function(used) {
|
||||
if (port == used)
|
||||
flag = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (flag) {
|
||||
comment = comment.concat("<br><?tr("One or more ports used by this application are already in use by another service or app running on your server. You will need to adjust the host ports accordingly on the template")?>");
|
||||
}
|
||||
}
|
||||
if ( $.trim(comment) ) {
|
||||
swal({
|
||||
title: "<?tr("Attention")?>",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
ced7886f83dd7f77fcfbe9a214d35513 ./Apps.page
|
||||
93430cdb88eb296df5d5753f6c575ea8 ./Apps.page
|
||||
4e55f7483b661af21a25b677179baffe ./CA_notices.page
|
||||
c7c6da0a4a4a7ac33f387ea178319bae ./ca_settings.page
|
||||
ed2883d6c44c19304c431079596a1731 ./default.cfg
|
||||
abbcf04ea5f8780a9b7f1d392ea1e09c ./include/exec.php
|
||||
ba637f473f4f768f4c878d50a7ebc4cb ./include/helpers.php
|
||||
6f6f06e53087215df34c98bc3f1e531c ./include/paths.php
|
||||
afe60a2b41646f7904be1db8c836f851 ./include/exec.php
|
||||
192f3642aba7260d90e723d86a1fe257 ./include/helpers.php
|
||||
d827ebdf8c29aa6a9818df043a37721e ./include/paths.php
|
||||
532fffdf939594c143e679da02bd841e ./javascript/libraries.js
|
||||
b398273cf7daa62ab00d2de2336ca25f ./README.md
|
||||
79f3093f42415484944e6aa2863ee30a ./scripts/checkForUpdates.php
|
||||
|
@ -21,4 +21,4 @@ a1401a0bed89c182b69f0c7508282c1f ./scripts/pluginInstall.php
|
|||
34554a56611dfe625889c82afd5138de ./scripts/updatePluginSupport.php
|
||||
dec0ef21fb5bd704cd319e0a059a11ba ./skins/Narrow/css.php
|
||||
7d827147dc8ede3d518b2cacae1d385b ./skins/Narrow/skin.html
|
||||
cc60f849442f55cc26a94d0b636ce251 ./skins/Narrow/skin.php
|
||||
b31866f877bd4cd0a9be91b15ed9d0b8 ./skins/Narrow/skin.php
|
||||
|
|
|
@ -56,17 +56,17 @@ if ( !is_dir($caPaths['templates-community']) ) {
|
|||
@unlink($caPaths['community-templates-info']);
|
||||
}
|
||||
|
||||
if ( ! is_file($caPaths['logging']) ) {
|
||||
$caVersion = plugin("version","/var/log/plugins/community.applications.plg");
|
||||
if ( ! is_file($caPaths['logging']) ) {
|
||||
$caVersion = plugin("version","/var/log/plugins/community.applications.plg");
|
||||
|
||||
debug("Community Applications Version: $caVersion");
|
||||
debug("Unraid version: {$caSettings['unRaidVersion']}");
|
||||
debug("MD5's: \n".shell_exec("cd /usr/local/emhttp/plugins/community.applications && md5sum -c ca.md5"));
|
||||
$lingo = $_SESSION['locale'] ?: "en_US";
|
||||
debug("Language: $lingo");
|
||||
debug("Settings:\n".print_r($caSettings,true));
|
||||
}
|
||||
debug("POST CALLED ({$_POST['action']})\n".print_r($_POST,true));
|
||||
debug("Community Applications Version: $caVersion");
|
||||
debug("Unraid version: {$caSettings['unRaidVersion']}");
|
||||
debug("MD5's: \n".shell_exec("cd /usr/local/emhttp/plugins/community.applications && md5sum -c ca.md5"));
|
||||
$lingo = $_SESSION['locale'] ?: "en_US";
|
||||
debug("Language: $lingo");
|
||||
debug("Settings:\n".print_r($caSettings,true));
|
||||
}
|
||||
debug("POST CALLED ({$_POST['action']})\n".print_r($_POST,true));
|
||||
|
||||
|
||||
$sortOrder = readJsonFile($caPaths['sortOrder']);
|
||||
|
|
|
@ -302,7 +302,7 @@ function versionCheck($template) {
|
|||
###############################################
|
||||
# Function to read a template XML to an array #
|
||||
###############################################
|
||||
function readXmlFile($xmlfile,$generic=false) {
|
||||
function readXmlFile($xmlfile,$generic=false,$stats=true) {
|
||||
global $statistics;
|
||||
|
||||
if ( ! is_file($xmlfile) ) return false;
|
||||
|
@ -326,15 +326,16 @@ function readXmlFile($xmlfile,$generic=false) {
|
|||
if ( $o['Config']['@attributes'] )
|
||||
$o['Config'] = array('@attributes'=>$o['Config']['@attributes'],'value'=>$o['Config']['value']);
|
||||
|
||||
if ( $o['Plugin'] ) {
|
||||
$o['Author'] = $o['PluginAuthor'];
|
||||
$o['Repository'] = $o['PluginURL'];
|
||||
$o['SortAuthor'] = $o['Author'];
|
||||
$o['SortName'] = $o['Name'];
|
||||
$statistics['plugin']++;
|
||||
} else
|
||||
$statistics['docker']++;
|
||||
|
||||
if ( $stats) {
|
||||
if ( $o['Plugin'] ) {
|
||||
$o['Author'] = $o['PluginAuthor'];
|
||||
$o['Repository'] = $o['PluginURL'];
|
||||
$o['SortAuthor'] = $o['Author'];
|
||||
$o['SortName'] = $o['Name'];
|
||||
$statistics['plugin']++;
|
||||
} else
|
||||
$statistics['docker']++;
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
###################################################################
|
||||
|
@ -657,7 +658,71 @@ function debug($str) {
|
|||
if ( $caSettings['debugging'] == "yes" )
|
||||
file_put_contents($caPaths['logging'],date('Y-m-d H:i:s')." $str\n",FILE_APPEND);
|
||||
}
|
||||
########################################
|
||||
# Gets the default ports in a template #
|
||||
########################################
|
||||
function portsUsed($template) {
|
||||
if ( $template['Network'] !== "bridge" || ! is_array($template['Config']) )
|
||||
return;
|
||||
|
||||
$portsUsed = [];
|
||||
if ( $template['Config']['@attributes'] )
|
||||
$template['Config'] = ['@attributes'=>$template['Config']];
|
||||
|
||||
foreach ($template['Config'] as $config) {
|
||||
if ( $config['@attributes']['Type'] !== "Port" ) continue;
|
||||
$portsUsed[] = $config['value'] ?: $config['@attributes']['Default'];
|
||||
}
|
||||
|
||||
return json_encode($portsUsed);
|
||||
}
|
||||
|
||||
########################
|
||||
# Get the ports in use #
|
||||
########################
|
||||
function getPortsInUse() {
|
||||
global $var, $caPaths;
|
||||
|
||||
if ( !$var )
|
||||
$var = parse_ini_file($caPaths['unRaidVars']);
|
||||
|
||||
$portsInUse = [];
|
||||
exec("lsof -Pni|awk '/LISTEN/ && \$9!~/127.0.0.1/ && \$9!~/\\[::1\\]/{print \$9}'|sort -u", $output);
|
||||
|
||||
$bind = $var['BIND_MGT']=='yes';
|
||||
$list = is_array($addr) ? array_merge(['*'],$addr) : ['*',$addr];
|
||||
$addr = ipaddr("eth0");
|
||||
|
||||
foreach ($output as $line) {
|
||||
[$ip, $port] = my_explode(':', $line);
|
||||
if (!in_array($port,$portsInUse) && (!$bind || in_array(plain($ip),$list)))
|
||||
if ( is_numeric($port) )
|
||||
$portsInUse[] = $port;
|
||||
}
|
||||
|
||||
return $portsInUse;
|
||||
}
|
||||
####################################################
|
||||
# Define ipaddr if it doesn't already exist < 6.10 #
|
||||
####################################################
|
||||
if (!function_exists('ipaddr')) {
|
||||
function ipaddr($ethX='eth0') {
|
||||
global $caPaths;
|
||||
|
||||
$net = parse_ini_file($caPaths['network_ini'],true);
|
||||
$eth = $net[$ethX];
|
||||
switch ($eth['PROTOCOL:0']) {
|
||||
case 'ipv4':
|
||||
return $eth['IPADDR:0'];
|
||||
case 'ipv6':
|
||||
return $eth['IPADDR6:0'];
|
||||
case 'ipv4+ipv6':
|
||||
return [$eth['IPADDR:0'],$$ethX['IPADDR6:0']];
|
||||
default:
|
||||
return $eth['IPADDR:0'];
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @copyright Copyright 2006-2012, Miles Johnson - http://milesj.me
|
||||
* @license http://opensource.org/licenses/mit-license.php - Licensed under the MIT License
|
||||
|
|
|
@ -36,6 +36,7 @@ $caPaths['moderationURL'] = "https://raw.githubusercontent
|
|||
$caPaths['moderation'] = $caPaths['tempFiles']."/moderation.json"; /* json file that has all of the moderation */
|
||||
$caPaths['unRaidVersion'] = "/etc/unraid-version";
|
||||
$caPaths['unRaidVars'] = "/var/local/emhttp/var.ini";
|
||||
$caPaths['network_ini'] = "/var/local/emhttp/network.ini";
|
||||
$caPaths['docker_cfg'] = "/boot/config/docker.cfg";
|
||||
$caPaths['dockerUpdateStatus'] = "/var/lib/docker/unraid-update-status.json";
|
||||
$caPaths['pinnedV2'] = "{$caPaths['flashDrive']}/pinned_appsV2.json";
|
||||
|
|
|
@ -122,7 +122,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
|
|||
if ( $template['BranchID'] )
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"displayTags('{$template['ID']}',true);");
|
||||
else
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second');");
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second','','".portsUsed($template)."');");
|
||||
}
|
||||
$actionsContext[] = array("icon"=>"ca_fa-edit","text"=>tr("Edit"),"action"=>"popupInstallXML('".addslashes($info[$ind]['template'])."','edit');");
|
||||
$actionsContext[] = array("divider"=>true);
|
||||
|
@ -133,7 +133,8 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
|
|||
}
|
||||
} elseif ( ! $template['Blacklist'] || ! $template['Compatible']) {
|
||||
if ( $template['InstallPath'] ) {
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user');");
|
||||
$userTemplate = readXmlFile($template['InstallPath'],false,false);
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user','','".portsUsed($userTemplate)."');");
|
||||
$actionsContext[] = array("divider"=>true);
|
||||
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>tr("Remove from Previous Apps"),"action"=>"removeApp('{$template['InstallPath']}','{$template['Name']}');");
|
||||
} else {
|
||||
|
@ -144,15 +145,15 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
|
|||
if ( is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
|
||||
$test = readXmlFile("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml",true);
|
||||
if ( $template['Repository'] == $test['Repository'] ) {
|
||||
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"<span class='ca_red'>".tr("Reinstall From Previous Apps")."</span>","action"=>"popupInstallXML('".addslashes("{$caPaths['dockerManTemplates']}/my-{$template['Name']}").".xml','user');");
|
||||
$userTemplate = readXmlFile($template['InstallPath'],false,false);
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"<span class='ca_red'>".tr("Reinstall From Previous Apps")."</span>","action"=>"popupInstallXML('".addslashes("{$caPaths['dockerManTemplates']}/my-{$template['Name']}").".xml','user','','".portsUsed($userTemplate)."');");
|
||||
$actionsContext[] = array("divider"=>true);
|
||||
}
|
||||
}
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"popupInstallXML('".addslashes($template['Path'])."','default','".str_replace(" "," ",htmlspecialchars($installComment))."');");
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"popupInstallXML('".addslashes($template['Path'])."','default','".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');");
|
||||
} else {
|
||||
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"displayTags('{$template['ID']}',false,'".str_replace(" "," ",htmlspecialchars($installComment))."');");
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"displayTags('{$template['ID']}',false,'".str_replace(" "," ",htmlspecialchars($installComment))."','','".portsUsed($userTemplate)."');");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +522,7 @@ function getPopupDescriptionSkin($appNumber) {
|
|||
if ( $template['BranchID'] )
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"displayTags('{$template['ID']}',true);");
|
||||
else
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second');");
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second','','".portsUsed($template)."');");
|
||||
}
|
||||
$actionsContext[] = array("icon"=>"ca_fa-edit","text"=>tr("Edit"),"action"=>"popupInstallXML('".addslashes($info[$name]['template'])."','edit');");
|
||||
$actionsContext[] = array("divider"=>true);
|
||||
|
@ -529,14 +530,15 @@ function getPopupDescriptionSkin($appNumber) {
|
|||
|
||||
} elseif ( ! $template['Blacklist'] ) {
|
||||
if ( $template['InstallPath'] ) {
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user');");
|
||||
$userTemplate = readXmlFile($template['InstallPath'],false,false);
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user','','".portsUsed($userTemplate)."');");
|
||||
$actionsContext[] = array("divider"=>true);
|
||||
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>"<span class='ca_red'>".tr("Remove from Previous Apps")."</span>","action"=>"removeApp('{$template['InstallPath']}','{$template['Name']}');");
|
||||
} else {
|
||||
if ( ( $template['Compatible'] || $caSettings['hideIncompatible'] !== "true" ) ) {
|
||||
if ( !$template['Deprecated'] || $caSettings['hideDeprecated'] !== "true" ) {
|
||||
if ( ! $template['BranchID'] ) {
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default');");
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default','','".portsUsed($userTemplate)."');");
|
||||
} else {
|
||||
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"displayTags('{$template['ID']}');");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user