Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2557 → Rev 2558

/alcasar.sh
581,7 → 581,7
[ -e /etc/hosts.default ] || cp /etc/hosts /etc/hosts.default
cat <<EOF > /etc/hosts
127.0.0.1 localhost
$PRIVATE_IP $HOSTNAME.$DOMAIN $HOSTNAME
$PRIVATE_IP $HOSTNAME
EOF
# write EXTIF (Internet) config
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF ] || cp /etc/sysconfig/network-scripts/ifcfg-$EXTIF /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF
1503,10 → 1503,11
/usr/bin/vnstat -u -i $EXTIF
} # End of vnstat
 
################################################################
## Function "dnsmasq" ##
## - creation of the conf files of the 4 intances of dnsmasq ##
################################################################
##################################################################
## Function "dnsmasq" ##
## - creation of the conf files of the 4 intances of dnsmasq ##
## - creation of the file managing domain name (local & remote) ##
##################################################################
dnsmasq ()
{
[ -d /var/log/dnsmasq ] || mkdir /var/log/dnsmasq
1514,7 → 1515,7
[ -e /etc/dnsmasq.conf.default ] || cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
cat << EOF > /etc/dnsmasq.conf
# Configuration file for "dnsmasq in forward mode"
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local DNS resolutions
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local & remote DNS domain name resolutions
listen-address=$PRIVATE_IP
pid-file=/var/run/dnsmasq.pid
listen-address=127.0.0.1
1533,7 → 1534,6
#dhcp-range=$PRIVATE_FIRST_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h
#dhcp-option=option:router,$PRIVATE_IP
#dhcp-option=option:ntp-server,$PRIVATE_IP
#domain=$DOMAIN
 
# Exemple of static dhcp assignation : <@MAC>,<name>,<@IP>,<MASK>,<ttl bail>
#dhcp-host=11:22:33:44:55:66,ssic-test,192.168.182.20,255.255.255.0,45m
1542,7 → 1542,7
cat << EOF > /etc/dnsmasq-blacklist.conf
# Configuration file for "dnsmasq with blacklist"
# Add Toulouse University blacklist domains
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local DNS resolutions
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local & remote DNS domain name resolutions
conf-dir=$DIR_DEST_SHARE/dnsmasq-bl-enabled
pid-file=/var/run/dnsmasq-blacklist.pid
listen-address=$PRIVATE_IP
1565,7 → 1565,7
cat << EOF > /etc/dnsmasq-whitelist.conf
# Configuration file for "dnsmasq with whitelist"
# ADD Toulouse university whitelist domains
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local DNS resolutions
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local & remote DNS domain name resolutions
conf-dir=$DIR_DEST_SHARE/dnsmasq-wl-enabled
pid-file=/var/run/dnsmasq-whitelist.pid
listen-address=$PRIVATE_IP
1585,7 → 1585,7
# 4th dnsmasq listen on udp 56 ("blackhole")
cat << EOF > /etc/dnsmasq-blackhole.conf
# Configuration file for "dnsmasq as a blackhole"
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local DNS resolutions
conf-file=$DIR_DEST_ETC/alcasar-dns-name # local & remote DNS domain name resolutions
address=/#/$PRIVATE_IP # redirect all on ALCASAR IP address
pid-file=/var/run/dnsmasq-blackhole.pid
listen-address=$PRIVATE_IP
1600,7 → 1600,22
bogus-priv
filterwin2k
EOF
# file managing domain name resolution (local & remote)
cat << EOF > $DIR_DEST_ETC/alcasar-dns-name
# Vous pouvez définir ici votre nom de domain local ('localdomain' par défaut)
# Here you can define your local domain name ('localdomain' by default)
local=/$DOMAIN/
domain=$DOMAIN
 
## Ajouter une ligne pour chaque nom de domaine géré par un autre seveur DNS
## Add one line for each domain name managed by an other DNS server
## server=/<your_domain>/<@IP_domain_server>
## Exemple for an A.D. domain : server=/Your.Domain.AD/110.120.100.100
## Exemple for an other domain : server=/an_other_domain/10.20.30.40
 
## INFO : local hostnames are resolved in /etc/hosts file
EOF
 
# the main instance should start after network and chilli (which create tun0)
[ -e /lib/systemd/system/dnsmasq.service.default ] || cp -f /lib/systemd/system/dnsmasq.service /lib/systemd/system/dnsmasq.service.default
$SED "s?^After=.*?After=syslog.target network-online.target chilli.service?g" /lib/systemd/system/dnsmasq.service
/conf/etc/alcasar-dns-name
File deleted
Property changes:
Deleted: svn:keywords
-Id Date Author
\ No newline at end of property
/scripts/alcasar-sms.sh
381,12 → 381,12
exit 0
;;
--last_writeerror)
#Récupère la dernière ligne où SECURITYERROR est présent (error)
#Récupère la dernière ligne où DEVICEWRITEERROR est présent (error)
cat $logfile | grep -n "DEVICEWRITEERROR" | cut -d ':' -f1 | tail -n 1
exit 0
;;
--last_timeout)
# Récupère la dernière ligne où SECURITYERROR est présent (error)
# Récupère la dernière ligne où TIMEOUT est présent (error)
cat $logfile | grep -n "TIMEOUT" | cut -d ':' -f1 | tail -n 1
exit 0
;;
/web/acc/admin/network.php
9,7 → 9,7
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
define('DNS_LOCAL_FILE', '/usr/local/etc/alcasar-dns-name');
define('DNS_LOCAL_FILE', '/etc/hosts');
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
 
223,29 → 223,23
$tab = file(DNS_LOCAL_FILE);
if ($tab) { // the file isn't empty
$insert = true;
foreach ($tab as $line) { // verify that host or IP address doesn't exist
if (preg_match('/^address/', $line)) {
$field = explode('/', $line);
$host_name = trim($field[1]);
$ip_addr = trim($field[2]);
if (strcasecmp($add_host, $host_name) === 0) {
$insert = false;
break;
}
if (strcmp($add_ip, $ip_addr) === 0) {
$insert = false;
break;
}
foreach ($tab as $line) { // verify that host or IP address doesn't already exist
$field = explode('\t', $line);
$host_name = trim($field[1]);
$ip_addr = trim($field[2]);
if (strcasecmp($add_host, $host_name) === 0) {
$insert = false;
break;
}
}
if (strcmp($add_ip, $ip_addr) === 0) {
$insert = false;
break;
}
}
if ($insert) {
$line1 = 'address=/'.$add_host.'/'.$add_ip."\n";
$explode_ip = explode('.', $add_ip);
$reverse_ip = implode('.', array_reverse($explode_ip));
$line2 = 'ptr-record='.$reverse_ip.'.in-addr.arpa,'.$add_host."\n";
$line1 = $add_ip.'\t'.$add_host."\n";
$pointeur=fopen(DNS_LOCAL_FILE, 'a');
fwrite($pointeur, $line1);
fwrite($pointeur, $line2);
fclose($pointeur);
exec('sudo /usr/bin/systemctl restart dnsmasq');
exec('sudo /usr/bin/systemctl restart dnsmasq-blacklist');