adding alternc-upnp for home hosted server, 1st step
This commit is contained in:
parent
591ba86425
commit
5be25b0945
|
@ -593,3 +593,9 @@ tools/top_ftp_users -text
|
||||||
tools/top_http_users -text
|
tools/top_http_users -text
|
||||||
tools/top_mysql_users -text
|
tools/top_mysql_users -text
|
||||||
/tx-to-repos.sh -text
|
/tx-to-repos.sh -text
|
||||||
|
upnp/Makefile -text
|
||||||
|
upnp/adminmenu_upnp.php -text
|
||||||
|
upnp/m_upnp.php -text
|
||||||
|
upnp/update_upnp.sh -text
|
||||||
|
upnp/upnp-cron -text
|
||||||
|
upnp/upnp.sql -text
|
||||||
|
|
|
@ -91,7 +91,7 @@ Description: Squirrelmail-Webmail plugin and configuration for AlternC
|
||||||
.
|
.
|
||||||
More information at http://www.alternc.com/
|
More information at http://www.alternc.com/
|
||||||
Homepage: http://www.alternc.com/
|
Homepage: http://www.alternc.com/
|
||||||
Description-fr.UTF-8: Suite logicielle d'hébergement mutualisé pour Debian
|
Description-fr.UTF-8: Webmail Squirrelmail pour AlternC
|
||||||
AlternC est un logiciel d'hébergement mutualisé pour serveur Linux.
|
AlternC est un logiciel d'hébergement mutualisé pour serveur Linux.
|
||||||
Il permet de gérer les sites web, domaines, ftp, emails, alias,
|
Il permet de gérer les sites web, domaines, ftp, emails, alias,
|
||||||
statistiques web, listes de discussions, comptes jabber, etc.
|
statistiques web, listes de discussions, comptes jabber, etc.
|
||||||
|
@ -122,7 +122,7 @@ Description: Roundcube-Webmail plugin and configuration for AlternC
|
||||||
.
|
.
|
||||||
More information at http://www.alternc.com/
|
More information at http://www.alternc.com/
|
||||||
Homepage: http://www.alternc.com/
|
Homepage: http://www.alternc.com/
|
||||||
Description-fr.UTF-8: Suite logicielle d'hébergement mutualisé pour Debian
|
Description-fr.UTF-8: Webmail Roundcube pour AlternC
|
||||||
AlternC est un logiciel d'hébergement mutualisé pour serveur Linux.
|
AlternC est un logiciel d'hébergement mutualisé pour serveur Linux.
|
||||||
Il permet de gérer les sites web, domaines, ftp, emails, alias,
|
Il permet de gérer les sites web, domaines, ftp, emails, alias,
|
||||||
statistiques web, listes de discussions, comptes jabber, etc.
|
statistiques web, listes de discussions, comptes jabber, etc.
|
||||||
|
@ -150,3 +150,32 @@ Description: Awstats statistics module for AlternC
|
||||||
managment to the virtual desktop.
|
managment to the virtual desktop.
|
||||||
.
|
.
|
||||||
More information on http://www.alternc.com/.
|
More information on http://www.alternc.com/.
|
||||||
|
|
||||||
|
Package: alternc-upnp
|
||||||
|
Architecture: all
|
||||||
|
Pre-depends: debconf (>= 0.5.00) | debconf-2.0
|
||||||
|
Depends: debianutils (>= 1.13.1), alternc (>= 1.1), miniupnpc
|
||||||
|
Description: UPnP client for AlternC
|
||||||
|
AlternC is a mutualized hosting software manager for Linux.
|
||||||
|
It allows you to manage your websites, domains, ftp, emails, aliases,
|
||||||
|
web statistics, mailing-lists, jabber accounts, etc.
|
||||||
|
.
|
||||||
|
This extension to AlternC is installing a UPnP IGD client and make it so
|
||||||
|
that your router required tcp and udp port are forwarded to AlternC.
|
||||||
|
You need that only if your AlternC's server is behind a NAT router.
|
||||||
|
.
|
||||||
|
More information at http://www.alternc.com/
|
||||||
|
Homepage: http://www.alternc.com/
|
||||||
|
Description-fr.UTF-8: Client UPnP pour AlternC
|
||||||
|
AlternC est un logiciel d'hébergement mutualisé pour serveur Linux.
|
||||||
|
Il permet de gérer les sites web, domaines, ftp, emails, alias,
|
||||||
|
statistiques web, listes de discussions, comptes jabber, etc.
|
||||||
|
.
|
||||||
|
Cette extension d'AlternC installe un client UPnP IGD et fait de telle
|
||||||
|
sorte que les ports udp et tcp nécessaire au fonctionnement de votre
|
||||||
|
serveur sous AlternC soient transmis depuis votre routeur.
|
||||||
|
Vous n'avez besoin de cette extension que si votre serveur AlternC est
|
||||||
|
situé derrière un routeur NAT.
|
||||||
|
.
|
||||||
|
Pour plus d'informations, consultez http://www.alternc.com/
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,9 @@ install: build
|
||||||
# alternc-squirrelmail:
|
# alternc-squirrelmail:
|
||||||
(cd squirrelmail && $(MAKE) install DESTDIR=$(CURDIR)/debian/alternc-squirrelmail)
|
(cd squirrelmail && $(MAKE) install DESTDIR=$(CURDIR)/debian/alternc-squirrelmail)
|
||||||
|
|
||||||
|
# alternc-upnp
|
||||||
|
(cd upnp && $(MAKE) install DESTDIR=$(CURDIR)/debian/alternc-upnp)
|
||||||
|
|
||||||
# alternc-awstats:
|
# alternc-awstats:
|
||||||
(cd awstats && $(MAKE) install DESTDIR=$(CURDIR)/debian/alternc-awstats)
|
(cd awstats && $(MAKE) install DESTDIR=$(CURDIR)/debian/alternc-awstats)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# AlternC - Web Hosting System
|
||||||
|
# Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||||
|
# https://alternc.org/
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License (GPL)
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Purpose of file: Install the files of alternc-upnp packages
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Desktop files
|
||||||
|
install -m 644 m_upnp.php $(DESTDIR)/var/alternc/bureau/class/
|
||||||
|
install -m 644 upnp_list.php upnp_change.php $(DESTDIR)/var/alternc/bureau/admin/
|
||||||
|
install -m 644 adminmenu_upnp.php $(DESTDIR)/var/alternc/bureau/admin/
|
||||||
|
# Cron
|
||||||
|
install -m 755 update_upnp.sh $(DESTDIR)/usr/lib/alternc/
|
||||||
|
# Install script
|
||||||
|
install -m 644 upnp.sql $(DESTDIR)/usr/share/alternc/install/
|
||||||
|
install -m 755 upnp-install $(DESTDIR)/usr/lib/alternc/install.d
|
|
@ -0,0 +1 @@
|
||||||
|
<a href="upnp_list.php"><?php __("Manage UPnP port forwarding"); ?></a>
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
AlternC - Web Hosting System
|
||||||
|
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||||
|
https://alternc.org/
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License (GPL)
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Purpose of file: Manage UPnP ports forwarding from router
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class handle UPnP forwarding from a IGD/UPnP compliant router
|
||||||
|
* you need this only when you are behind a IGD-compliant router
|
||||||
|
* each class may exports a hook that defined named port/protocol to
|
||||||
|
* forward to the local IP address of the server.
|
||||||
|
* this class manage the upnp table
|
||||||
|
* and its configuration from admin control panel
|
||||||
|
*/
|
||||||
|
class m_upnp {
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
|
/** get the list of current upnp forwards and their status
|
||||||
|
* @return array the attributes of all port-forwards
|
||||||
|
*/
|
||||||
|
function get_forward_list() {
|
||||||
|
global $db,$err;
|
||||||
|
$err->log("upnp","get_forward_list");
|
||||||
|
$db->query("SELECT * FROM upnp");
|
||||||
|
$res=array();
|
||||||
|
while ($db->next_record()) {
|
||||||
|
$res[]=$db->Record;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
|
/** enable a upnp port in the upnp table
|
||||||
|
* @param integer the id of the port to enable
|
||||||
|
* @return boolean TRUE if the port has been properly forwarded
|
||||||
|
* FALSE if an error occurred
|
||||||
|
*/
|
||||||
|
function enable_port($id) {
|
||||||
|
global $db,$err;
|
||||||
|
$id=intval($id);
|
||||||
|
$err->log("upnp","enable_port($id)");
|
||||||
|
$db->query("SELECT enabled FROM upnp WHERE id=$id;");
|
||||||
|
if (!$db->next_record()) {
|
||||||
|
$err->raise("upnp",_("The required port is not currently defined"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!$db->f("enabled")) {
|
||||||
|
$db->query("UPDATE upnp SET enabled=1 WHERE id=$id;");
|
||||||
|
$err->raise("upnp",_("The specified upnp port is now enabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$err->raise("upnp",_("The specified upnp port is already enabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
|
/** disable a upnp port in the upnp table
|
||||||
|
* @param integer the id of the port to disable
|
||||||
|
* @return boolean TRUE if the port has been properly forwarded
|
||||||
|
* FALSE if an error occurred
|
||||||
|
*/
|
||||||
|
function disable_port($id) {
|
||||||
|
global $db,$err;
|
||||||
|
$id=intval($id);
|
||||||
|
$err->log("upnp","disable_port($id)");
|
||||||
|
$db->query("SELECT enabled FROM upnp WHERE id=$id;");
|
||||||
|
if (!$db->next_record()) {
|
||||||
|
$err->raise("upnp",_("The required port is not currently defined"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($db->f("enabled")) {
|
||||||
|
$db->query("UPDATE upnp SET enabled=0 WHERE id=$id;");
|
||||||
|
$err->raise("upnp",_("The specified upnp port is now disabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$err->raise("upnp",_("The specified upnp port is already disabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This configures the upnp client for AlternC
|
||||||
|
#
|
||||||
|
|
||||||
|
CONFIG_FILE="/etc/alternc/local.sh"
|
||||||
|
|
||||||
|
if [ ! -r "$CONFIG_FILE" ]; then
|
||||||
|
echo "Can't access $CONFIG_FILE."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
. "$CONFIG_FILE"
|
||||||
|
|
||||||
|
# Some vars
|
||||||
|
umask 022
|
||||||
|
LOCK_FILE="/tmp/alternc-upnp.lock"
|
||||||
|
|
||||||
|
# Somes check before start operations
|
||||||
|
if [ `id -u` -ne 0 ]; then
|
||||||
|
log_error "must be launched as root"
|
||||||
|
elif [ -z "$INTERNAL_IP" -o -z "$PUBLIC_IP" ]; then
|
||||||
|
log_error "Bad configuration. Please use: dpkg-reconfigure alternc"
|
||||||
|
elif [ -f "$LOCK_FILE" ]; then
|
||||||
|
process=$(ps f -p `cat "$LOCK_FILE"|tail -1`|tail -1|awk '{print $NF;}')
|
||||||
|
if [ "$(basename $process)" = "$(basename "$0")" ] ; then
|
||||||
|
log_error "last cron unfinished or stale lock file ($LOCK_FILE)."
|
||||||
|
else
|
||||||
|
rm "$LOCK_FILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We lock the application
|
||||||
|
echo $$ > "$LOCK_FILE"
|
||||||
|
|
||||||
|
# Check the status of the router
|
||||||
|
upnpc -s
|
||||||
|
if [ "$?" != "0" ]
|
||||||
|
then
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rm -f "$LOCK_FILE"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
# This shell script configures the UPnP client if necessary:
|
||||||
|
* * * * * root /usr/lib/alternc/update_upnp.sh
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `upnp` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(128) NOT NULL,
|
||||||
|
`class` varchar(64) NOT NULL,
|
||||||
|
`protocol` varchar(3) NOT NULL,
|
||||||
|
`port` int(10) unsigned NOT NULL,
|
||||||
|
`mandatory` tinyint(3) unsigned NOT NULL,
|
||||||
|
`enabled` tinyint(3) unsigned NOT NULL,
|
||||||
|
`lastcheck` datetime NOT NULL,
|
||||||
|
`lastupdate` datetime NOT NULL,
|
||||||
|
`result` varchar(128) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM COMMENT='UPnP port forwards and their status.';
|
||||||
|
|
Loading…
Reference in New Issue