Benutzer-Werkzeuge

Webseiten-Werkzeuge

A PCRE internal error occured. This might be caused by a faulty plugin

openqrm_-_z-ip_s

====== openQRM - Z-IP's ====== Ziel ist es, dass die erstellten VM's bzw. Cloud's nicht nur eine NIC mit IP haben, sondern auch noch weitere NIC, von denen jede einzelne an ein anderes physikalisches Netz gebunden ist. In unserem Fall ist die "normale" NIC (eth0:op) mit einer IP konfiguriert, die von openQRM zur allgemeinen Verwaltung vergeben wird. Wir brauchen noch eine Verbindung in das Datenbanknetz und eine Verbindung ins Internet (Loadbalancer). Die Konfiguration dieser beiden NIC's soll von diesem Plugin übernommen werden. Wenn dieses Plugin installiert wurden, müssen die erforderlichen Anpassungen in der DNS-Konfiguration: [[openQRM - DNS]] noch vorgenommen werden, damit die DNS-Einträge für die zusätzlichen IP's auch automatisch beim anlegen der Appliance vorgenommen werden. ===== allgemeines über Plugin's ===== Ein Plugin wird immer erst gestartet, **nach** dem das gewünschte "/"-Dateisystem (aus dem "Image") gemountet ist. Soll eine Aktion **vor** dem mounten ausgeführt werden (also auch dann, wenn die "Appliance" gestoppt wurde), dann muss die Aktion über die entsprechenden HOOK's implementiert werden. Aber **Vorsicht**, die HOOK's gehören zum Basissystem und müssen mit allen möglichen Kombinationen der verschiedenen Plugins ohne Seiteneffekte zusammen arbeiten! Will man ein eigenes Plugin für openQRM bauen, dann geht das wie folgt. In diesem Beispiel wird das TFTP-Plugin als Vorlage verwendet: ===== das Z-IP-Plugin ===== # /usr/share/openqrm/bin/openqrm-create-plugin <SOURCE_PLUGIN> <DESTINATION_PLUGIN> # /usr/share/openqrm/bin/openqrm-create-plugin tftpd zips # cd /usr/share/openqrm/plugins/zips/ # rm -f web/.running ==== etc/init.d/openqrm-plugin-zips ==== ... function openqrm_plugin_zips_init() { echo "Initializing the openQRM zips-plugin" # linking the web dir ln -sf $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/web $OPENQRM_WEBSERVER_DOCUMENT_ROOT/openqrm/base/plugins/zips # linking the boot-service ln -sf $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/web/boot-service-zips.tgz $OPENQRM_WEBSERVER_DOCUMENT_ROOT/openqrm/boot-service/boot-service-zips.tgz # Kopieraktionen cp $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/bin/zipscfg.sh /usr/share/openqrm/web/boot-service/zipscfg.sh WWWDIR="$(echo "$(cat $(ls $(cat $(apache2 -V | egrep 'HTTPD_ROOT|SERVER_CONFIG_FILE' | awk -F'"' '{print $2}' | tr -s '\n' '/' | sed 's#/$##') | egrep '^Include' | fgrep -v '^$' | sed -e 's#^Include[ ]*##' -e 's#.*/$#&\*#')) | egrep -i 'DocumentRoot' | awk '{print $NF}' | sort | uniq | head -n1)")" CGIBIN="$(cat $(ls $(cat $($(which httpd;which apache2) -V | egrep 'HTTPD_ROOT|SERVER_CONFIG_FILE' | awk -F'"' '{print $2}' | tr -s '\n' '/' | sed 's#/$##') | egrep '^Include' | fgrep -v '^$' | sed -e 's#^Include[ ]*##' -e 's#.*/$#&\*#')) | egrep -v '^#|DirectoryMatch' | egrep '/cgi-bin[/]*$' | sed -e 's#"##g' -e 's#[<>]*##g' | awk '{sub("/$","");print $NF}' | sort | uniq | head -n1)" if [ -d "${CGIBIN}" ] ;then sed -e -i "s#WWWDIR=.*#WWWDIR='${WWWDIR}'#" $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg sed -e -i "s#CGIBIN=.*#CGIBIN='${CGIBIN}'#" $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg cp $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/cgi-bin/zimmer_netzcfg.cgi ${CGIBIN}/ cp $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/cgi-bin/zimmer_ip-machen.cgi ${CGIBIN}/ chmod 0755 ${CGIBIN}/zimmer_netzcfg.cgi fi } ... ==== web/openqrm-zips-resource-hook.php ==== ... function openqrm_zips_resource($cmd, $resource_fields) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $resource_id=$resource_fields["resource_id"]; $resource_ip=$resource_fields["resource_ip"]; $resource_mac=$resource_fields["resource_mac"]; $event->log("openqrm_new_resource", $_SERVER['REQUEST_TIME'], 5, "openqrm-zips-resource-hook.php", "Handling $cmd event $resource_id/$resource_ip/$resource_mac", "", "", 0, 0, $resource_id); $mycommand = $OPENQRM_SERVER_BASE_DIR."/openqrm/plugins/montag/bin/zips.sh ".$resource_id." ".$resource_ip." ".$resource_mac; $openqrmserver = new openqrm_server(); $openqrmserver->send_command($mycommand); } ... ==== web/zips-about.php ==== ... function zips_about() { global $OPENQRM_SERVER_BASE_DIR; $disp = "<h1><img border=0 src=\"/openqrm/base/plugins/zips/img/plugin.png\"> Tftpd plugin</h1>"; $disp = $disp."<br>"; $disp = $disp."Ziel ist es, dass die erstellten VM's bzw. Cloud's nicht nur eine NIC mit IP haben, sondern auch noch weitere NIC, von denen jede einzelne an ein anderes physikalisches Netz gebunden ist." $disp = $disp."<br>" $disp = $disp."In unserem Fall ist die „normale“ NIC (eth0:op) mit einer IP konfiguriert, die von openQRM zur allgemeinen Verwaltung vergeben wird. Wir brauchen noch eine Verbindung in das Datenbanknetz und eine Verbindung ins Internet (Loadbalancer). Die Konfiguration dieser beiden NIC's soll von diesem Plugin übernommen werden." $disp = $disp."<br>" $disp = $disp."Wenn dieses Plugin installiert wurden, müssen die erforderlichen Anpassungen in der DNS-Konfiguration noch vorgenommen werden, damit die DNS-Einträge für die zusätzlichen IP's auch automatisch beim anlegen der Appliance vorgenommen werden:" $disp = $disp."<br>"; $disp = $disp."siehe http://10.10.2.222/wiki/doku.php?id=openqrm_-_dns"; $disp = $disp."<br>"; $disp = $disp."Es ist geplant, dass diese Anpassungen auch diesem Plugin vorgenommen werden."; $disp = $disp."<br>"; $disp = $disp."<br>"; $disp = $disp."<b>How to use :</b>"; $disp = $disp."<br>"; $disp = $disp."<br>"; $disp = $disp."No manual configuration is needed for the zips-plugin. It automatically starts up the zips-service during start-up of the plugin."; $disp = $disp."<br>"; $disp = $disp."<br>"; $disp = $disp."<br>"; return $disp; } ... ==== etc/zips.cfg ==== Hier werden die Tabellennamen für die Gruppentabelle und für die IP-Tabelle sowie die Sortierreihenfolge der Anzeigen festgelegt. . /usr/share/openqrm/etc/openqrm-server.conf DATABASENET='10.4.' EXTERNNET='10.7.' WWWDIR='/var/www' CGIBIN='/usr/lib/cgi-bin/' ZIPGROUPS="zimmer_ipgroups" ZIPTABLES="zimmer_iptables" ZIPGORDER="ig_id" #ZIPGORDER="ig_name" ZIPTORDER="INET_ATON(ip_address)" ### Tabellen anlegen, wenn nicht schon vorhanden! echo " CREATE DATABASE IF NOT EXISTS ${OPENQRM_DATABASE_NAME}; USE ${OPENQRM_DATABASE_NAME}; CREATE TABLE IF NOT EXISTS ${ZIPGROUPS} ( ig_id int(5) NOT NULL, ig_name varchar(50) NOT NULL, ig_domain varchar(50) default NULL, PRIMARY KEY (ig_id), KEY (ig_name) ) TYPE=MyISAM; CREATE TABLE IF NOT EXISTS ${ZIPTABLES} ( ip_ig_id int(5) NOT NULL, ip_eth varchar(8) default 'eth1', ip_hostname varchar(50), ip_domain varchar(50) NOT NULL, ip_address varchar(15) NOT NULL, ip_subnet varchar(15), ip_gateway varchar(15), ip_dns1 varchar(15), ip_dns2 varchar(15), PRIMARY KEY (ip_address) ) TYPE=MyISAM; " | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} ==== bin/zipscfg.sh ==== Dieses Script wird vom Clienten ausgeführt, um die zusätzliche Netzwerkkonfiguration durchzuführen. #!/bin/bash aptitude -y install links ethtool LINKS="$(which links)" if [ -n "${LINKS}" ] ; then . /var/openqrm/openqrm-resource.conf IFS="|" ${LINKS} -dump http://${resource_openqrmserver}/cgi-bin/zimmer_netzcfg.cgi?ip_hostname=$(hostname) | egrep -v '[\+\|]---------' | while read ANFANG ip_eth ip_hostname ip_domain ip_address ip_subnet ip_gateway ip_dns1 ip_dns2 ENDE do ip_eth="$(echo "${ip_eth}" | awk '{print $1}')" ip_hostname="$(echo "${ip_hostname}" | awk '{print $1}')" ip_domain="$(echo "${ip_domain}" | awk '{print $1}')" ip_address="$(echo "${ip_address}" | awk '{print $1}')" ip_subnet="$(echo "${ip_subnet}" | sed 's/%22//g' | awk '{print $1}')" ip_gateway="$(echo "${ip_gateway}" | sed 's/%22//g' | awk '{print $1}')" ip_dns1="$(echo "${ip_dns1}" | sed 's/%22//g' | awk '{print $1}')" ip_dns2="$(echo "${ip_dns2}" | sed 's/%22//g' | awk '{print $1}')" if [ -z "${1}" ] ; then if [ -n "${ip_address}" -a -n "${ip_eth}" -a "${ip_address}" != "NULL" -a "${ip_eth}" != "NULL" ] ; then echo "ip addr add ${ip_address}/${ip_subnet} dev ${ip_eth}" ip addr add ${ip_address}/${ip_subnet} dev ${ip_eth} echo "ip link set ${ip_eth} up" ip link set ${ip_eth} up fi if [ -n "${ip_gateway}" -a -n "${ip_eth}" -a "${ip_gateway}" != "NULL" -a "${ip_eth}" != "NULL" ] ; then if $(ip route | egrep ^default > /dev/null) ; then echo "ip route add ${ip_gateway} dev ${ip_eth}" ip route add ${ip_gateway} dev ${ip_eth} else echo "ip route add default via ${ip_gateway} dev ${ip_eth}" ip route add default via ${ip_gateway} dev ${ip_eth} fi fi if [ -n "${ip_domain}" -o -n "${ip_dns1}" -o -n "${ip_dns2}" -a "${ip_domain}" != "NULL" -a "${ip_dns1}" != "NULL" -a "${ip_dns2}" != "NULL" ] ; then echo "search idstein.alphatel.de victorvox.net med.alphatel.de alphatel.de database extern" \ # | tee /etc/resolv.conf fi if [ -n "${ip_domain}" -a "${ip_domain}" != "NULL" ] ; then echo "domain ${ip_domain}" \ # | tee -a /etc/resolv.conf fi if [ -n "${ip_dns1}" -a "${ip_dns1}" != "NULL" ] ; then echo "nameserver ${ip_dns1}" \ # | tee -a /etc/resolv.conf fi if [ -n "${ip_dns2}" -a "${ip_dns2}" != "NULL" ] ; then echo "nameserver ${ip_dns2}" \ # | tee -a /etc/resolv.conf fi else echo " ANFANG='${ANFANG}' ip_eth='${ip_eth}' ip_hostname='${ip_hostname}' ip_domain='${ip_domain}' ip_address='${ip_address}' ip_subnet='${ip_subnet}' ip_gateway='${ip_gateway}' ip_dns1='${ip_dns1}' ip_dns2='${ip_dns2}' ENDE='${ENDE}' " fi done else echo "links konnte nicht installiert werden" fi ==== /usr/share/openqrm/web/base/top.php ==== Hier ist die Zeile mit **/cgi-bin/zimmer_ip-machen.cgi** eingefühgt worden: ... <div class="top"> <a id="Event_box" href="server/event/event-overview.php?currenttab=tab1" target="MainFrame">Error(s) <span id="events_critical"></span></a> <a id="Support_box" href="http://www.openqrm-enterprise.com" target="_BLANK">Support</a> <a id="Docu_box" href="server/zz_documentation/introduction.php" target="MainFrame">Documentation</a> <a id="Docu_box" href="/cgi-bin/remconstab_aendern.cgi" target="MainFrame">Remote-Consolen-IP's</a> <a id="Docu_box" href="/store.php" target="MainFrame">QRM-Info</a> <a id="Docu_box" href="/cgi-bin/zimmer_ip-machen.cgi" target="MainFrame">Zimmer-IP-Gruppen</a> <a id="Docu_box" href="http://10.10.2.222/wiki/doku.php" target="MainFrame">Wiki</a> <a id="Login_box" href="server/user/user.php" target="MainFrame"><?php echo OPENQRM_USER_NAME; ?></a> <div id="Watch"> <span id="timecontainer"></span> <script type="text/javascript"> new showLocalTime("timecontainer", "server-php", 0, "xx") </script> </div> <div class="floatbreaker">&#160;</div> </div> ... ==== /usr/lib/cgi-bin/zimmer_ip-machen.cgi ==== Dieses Script ist das Herzstück, hier werden alle wichtigen Aktionen mit realisiert. #!/bin/sh DATENDATEI="$(mktemp /tmp/zimmer.XXXXXXXXXXXX)" ### POST-Daten werden in eine Datei geschrieben echo "$(dd bs=1 count=${CONTENT_LENGTH} 2> /dev/null | tr -s '&' '\n')" | tr -d '"' > ${DATENDATEI} 2>&1 . ${DATENDATEI} . /usr/share/openqrm/etc/openqrm-server.conf . $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg ### GET AKTION="$(echo "${QUERY_STRING}" | awk -F'=' '{print $1}')" WERT="$(echo "${QUERY_STRING}" | awk -F'=' '{print $2}')" ### Achtung! # "action" englisch und klein geschrieben, ist die Variable aus dem POST-Datenstrom; # "AKTION" deutsch und groß geschrieben, ist aus der GET-Zeile if [ -n "${1}" -a -z "${AKTION}" ] ; then AKTION="$(echo "${1}" | awk -F'=' '{print $1}')" WERT="$(echo "${1}" | awk -F'=' '{print $2}')" fi ### mit dem richtigen "action"-Eintrag wird eine neue Gruppe erstelt if [ "${action}" = "angelegt" ] ; then #------------------------------------------------------------------------------# ### den neuen Wert für ig_id bestimmen ZAHLEN1="$(mktemp /tmp/zimmer.XXXXXXXXXXXX)" ZAHLEN2="$(mktemp /tmp/zimmer.XXXXXXXXXXXX)" igidmax="$(echo "SELECT ig_id FROM ${ZIPGROUPS} ORDER BY ${ZIPGORDER} DESC LIMIT 1;"|mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" echo "$(seq 1 ${igidmax})" > ${ZAHLEN1} echo " SELECT ig_id FROM ${ZIPGROUPS} ORDER BY ${ZIPGORDER} ASC; "|mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} | egrep -v '^$' > ${ZAHLEN2} ig_id="$(sdiff ${ZAHLEN1} ${ZAHLEN2} | fgrep '<' | awk '{print $1}' | head -n1)" if [ -z "${ig_id}" -o "${ig_id}" = "0" ] ; then ig_id="$((${igidmax}+1))" fi rm -f ${ZAHLEN1} ${ZAHLEN2} ### der "action"-Eintrag wird entfernt sed -i -e 's/action=angelegt//' -e 's/ip_adressen=.*//' -e 's/ig_name=.*//' ${DATENDATEI} ### die neue Gruppe wird erstelt (echo "INSERT INTO ${ZIPGROUPS} (ig_id,ig_name,ig_domain) VALUES ('${ig_id}','${ig_name}','${ip_domain}');" | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 ### IPs in die Tabelle eintragen echo "${ip_adressen}" | sed -e 's#%0D%0A#\n#g' | egrep -v '^$' | while read ADRESSE do echo "INSERT INTO ${ZIPTABLES} (ip_ig_id,ip_address,$(cat ${DATENDATEI}|egrep -v '^$'|awk -F'=' '{print $1}'|tr -s '\n' ','|sed 's/,$//')) VALUES ('${ig_id}','${ADRESSE}',$(cat ${DATENDATEI}|egrep -v '^$'|awk -F'=' '{print $2}'|sed "s/.*/'&'/"|tr -s '\n' ','|sed "s/',$/'/"));" done) | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 ### und noch ein schöner Gruß ${CGIBIN}/zimmer_ip-machen.cgi elif [ "${action}" = "aendern" ] ; then sed -i -e 's/action=aendern//' ${DATENDATEI} echo 'Content-type: text/html <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">Zimmer IP-Eintrag</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> ' IGID="$(echo "SELECT ip_ig_id FROM ${ZIPTABLES} WHERE ip_address='${ip_address}' LIMIT 1;"|mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" echo " <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen anzeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?liste=1">alle Zimmer IPs zeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?aendern=${IGID}">alle Zimmer IP's der Gruppe '${IGID}' anzeigen</a></b> " echo "UPDATE ${ZIPTABLES} SET $(cat ${DATENDATEI} | fgrep -v ip_address | sed -e "s#=#='#" -e "s#.*#&'#" -e "s#^'##" | tr -s '\n' ',' | sed -e 's#,$##') WHERE ip_address='${ip_address}'; SELECT * FROM ${ZIPTABLES} WHERE ip_address='${ip_address}';" | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | tr -s '\n' ' ' \ | sed -e 's#> <#><#g' -e 's#></#> </#g' -e 's#><#>\n<#g' -e 's#</TD> </TR>#</TD>\n</TR>#g' | while read HTMLZEILE do SPALTENANFANG="$(echo "${HTMLZEILE}" | egrep '^<TR>$')" if [ -n "${SPALTENANFANG}" ] ; then SPALTENZAHL="0" fi SPALTENZAHL="$((${SPALTENZAHL}+1))" TH="$(echo "${HTMLZEILE}" | egrep '^<TH>')" if [ -z "${TH}" -a "${SPALTENZAHL}" = "2" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" echo "<TD><a href=/cgi-bin/zimmer_ip-machen.cgi?aendern=${ZELLENWERT}>${ZELLENWERT}</a></TD>" elif [ -z "${TH}" -a "${SPALTENZAHL}" = "6" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" #echo "<TD><a href=/cgi-bin/zimmer_iptable-aendern.cgi?aendern=${ZELLENWERT}>${ZELLENWERT}</a></TD>" echo "<TD><a href=/cgi-bin/zimmer_iptable-aendern.cgi?loeschen=${ZELLENWERT}>l&ouml;schen</a> <a href=/cgi-bin/zimmer_iptable-aendern.cgi?aendern=${ZELLENWERT}>&auml;ndern</a> ${ZELLENWERT}</TD>" else echo "${HTMLZEILE}" fi done elif [ "${AKTION}" = "liste" ] ; then AKTION="" #------------------------------------------------------------------------------# echo 'Content-type: text/html <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">Zimmer IPs</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen anzeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?liste=1">alle Zimmer IPs zeigen</a></b> <br> <b><a href="/zimmer_ipgroup-machen.php?action=angelegt">neue Zimmer IP-Gruppe anlegen</a></b> <br> <br> ' echo "SELECT * FROM ${ZIPTABLES} ORDER BY ${ZIPTORDER} ; " | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | tr -s '\n' ' ' \ | sed -e 's#> <#><#g' -e 's#></#> </#g' -e 's#><#>\n<#g' -e 's#</TD> </TR>#</TD>\n</TR>#g' | while read HTMLZEILE do SPALTENANFANG="$(echo "${HTMLZEILE}" | egrep '^<TR>$')" if [ -n "${SPALTENANFANG}" ] ; then SPALTENZAHL="0" fi SPALTENZAHL="$((${SPALTENZAHL}+1))" TH="$(echo "${HTMLZEILE}" | egrep '^<TH>')" if [ -z "${TH}" -a "${SPALTENZAHL}" = "2" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" echo "<TD><a href=/cgi-bin/zimmer_ip-machen.cgi?aendern=${ZELLENWERT}>${ZELLENWERT}</a></TD>" elif [ -z "${TH}" -a "${SPALTENZAHL}" = "4" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" echo "<TD><a href=/cgi-bin/zimmer_netzcfg.cgi?ip_hostname=${ZELLENWERT}>${ZELLENWERT}</a></TD>" elif [ -z "${TH}" -a "${SPALTENZAHL}" = "6" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" #echo "<TD><a href=/cgi-bin/zimmer_iptable-aendern.cgi?aendern=${ZELLENWERT}>${ZELLENWERT}</a></TD>" echo "<TD><a href=/cgi-bin/zimmer_iptable-aendern.cgi?loeschen=${ZELLENWERT}>l&ouml;schen</a> <a href=/cgi-bin/zimmer_iptable-aendern.cgi?aendern=${ZELLENWERT}>&auml;ndern</a> ${ZELLENWERT}</TD>" else echo "${HTMLZEILE}" fi done elif [ "${AKTION}" = "loeschen" ] ; then AKTION="" echo 'Content-type: text/html <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">verbliebene Zimmer IP-Gruppen</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> ' echo " <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen anzeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?liste=1">alle Zimmer IPs zeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?aendern=${WERT}">alle Zimmer IP's der Gruppe '${WERT}' anzeigen (zur &Uuml;berpr&uuml;fung)</a></b> " echo "DELETE FROM ${ZIPTABLES} WHERE ip_ig_id='${WERT}';" | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 echo "DELETE FROM ${ZIPGROUPS} WHERE ig_id='${WERT}';" | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 elif [ "${AKTION}" = "aendern" ] ; then #------------------------------------------------------------------------------# if [ -z "${1}" ] ; then echo 'Content-type: text/html <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">Zimmer IP-Gruppe</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">Zimmer IP-Gruppen</a></b> ' fi #------------------------------------------------------------------------------# echo " SELECT * FROM ${ZIPTABLES} WHERE ip_ig_id=${WERT} ORDER BY ${ZIPTORDER} ASC ; " | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | tr -s '\n' ' ' \ | sed -e 's#> <#><#g' -e 's#></#> </#g' -e 's#><#>\n<#g' -e 's#</TD> </TR>#</TD>\n</TR>#g' | while read HTMLZEILE do SPALTENANFANG="$(echo "${HTMLZEILE}" | egrep '^<TR>$')" if [ -n "${SPALTENANFANG}" ] ; then SPALTENZAHL="0" fi SPALTENZAHL="$((${SPALTENZAHL}+1))" TH="$(echo "${HTMLZEILE}" | egrep '^<TH>')" if [ -z "${TH}" -a "${SPALTENZAHL}" = "4" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" echo "<TD><a href=/cgi-bin/zimmer_netzcfg.cgi?ip_hostname=${ZELLENWERT}>${ZELLENWERT}</a></TD>" elif [ -z "${TH}" -a "${SPALTENZAHL}" = "6" ] ; then ZELLENWERT="$(echo "${HTMLZEILE}" | sed -e 's#<TD>##' -e 's#</TD>##')" echo "<TD><a href=/zimmer_ip_loeschen.php?loeschen=${ZELLENWERT}>l&ouml;schen</a> <a href=/cgi-bin/zimmer_iptable-aendern.cgi?aendern=${ZELLENWERT}>&auml;ndern</a> ${ZELLENWERT}</TD>" else echo "${HTMLZEILE}" fi done echo "<BR>" echo "<BR>" #------------------------------------------------------------------------------# else #------------------------------------------------------------------------------# echo 'Content-type: text/html <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">Zimmer IP-Gruppen</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?liste=1">alle Zimmer IPs zeigen</a></b> <br> <b><a href="/zimmer_ipgroup-machen.php?action=angelegt">neue Zimmer IP-Gruppe anlegen</a></b> <br> <br> ' echo " SELECT * FROM ${ZIPGROUPS} ORDER BY ${ZIPGORDER} ASC ; " | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | tr -s '\n' ' ' \ | sed -e 's#<TR><TD>[0-9]*#<TR><TD><a href=/zimmer_ipgroup_loeschen.php?loeschen=&>l\&ouml;schen</a> <a href=/cgi-bin/zimmer_ip-machen.cgi?aendern=&><B>auflisten</B></a> <a href=/cgi-bin/zimmer_iptable-aendern.cgi?hinzufuegen=&>hinzuf\&uuml;gen</a>Liste &</B>#g' -e 's#=<TR><TD>#=#g' -e 's#>Liste <TR><TD>#><B>#g' -e 's#</TD></TR></TD></TR>#</TD></TR>#g' -e 's#></#> </#g' -e 's#><#>\n<#g' fi rm -f ${DATENDATEI} ${ZAHLEN1} ${ZAHLEN2} echo "<br> <BR> </div> " echo ' </body> </html> ' ==== ${WWWDIR}/zimmer_ipgroup_loeschen.php ==== <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> <div class="htmlobject_tabs"> <ul> <li class="current"><span><a href="" onclick="this.blur();">Zimmer IP-Liste</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> <H1> Sind Sie wirklich sicher, dass Sie die Zimmer-IP-Gruppe <?php echo $_GET["loeschen"]; ?> l&ouml;schen wollen? </H1> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?loeschen= <?php echo $_GET["loeschen"]; ?> ">Zimmer IP-Gruppe <?php echo $_GET["loeschen"]; ?> l&ouml;schen</a></b> <br> <br> ==== ${WWWDIR}/zimmer_ipgroup-machen.php ==== <link rel="stylesheet" type="text/css" href="/openqrm/base/css/htmlobject.css" /> <link rel="stylesheet" type="text/css" href="/cloud.css" /> <script type="text/javascript"> function currenttabToggle(id) { document.getElementById(id).style.display = "block"; document.getElementById("tab_" + id).className = "current"; } </script> <div class="htmlobject_tabs"> <ul> <li id="tab_currenttabtab0" class="current"><span><a href="" onclick="this.blur();">neue Zimmer IP-Gruppe erstellen</a></span></li> </ul> </div> <div style="line-height:0px;clear:both;">&#160;</div> <div class="htmlobject_tab_box" id="currenttabtab0"><style> .htmlobject_tab_box { } </style> <h1><img border=0 src="/cloudipgroups.png">neue Zimmer IP-Gruppe erstellen</h1> <br> <br> <form action=/cgi-bin/zimmer_ip-machen.cgi method=post> <div class="htmlobject_box input" id="htmlobject_box_ig_name"> <div class="left"><label>Markenname</label></div> <div class="right"><input title="GruppenName" maxlength="20" name="ig_name" value="GruppenName" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ig_network"> <div class="left"><label>Domain (ohne "www" davor!)</label></div> <div class="right"><input title="Domain" maxlength="20" name="ip_domain" value="domain.de" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ig_subnet"> <div class="left"><label>Netzwerk-Schnittstelle</label></div> <div class="right"><input title="Netzwerk-Schnittstelle" maxlength="20" name="ip_eth" value="eth2" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ip_subnet"> <div class="left"><label>Netzwerkmaske</label></div> <div class="right"><input title="Netzwerkmaske" maxlength="20" name="ip_subnet" value="255.255.255.0" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ig_gateway"> <div class="left"><label>Gateway</label></div> <div class="right"><input title="Gateway" maxlength="20" name="ip_gateway" value="192.168.1.1" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ip_dns1"> <div class="left"><label>1. DNS</label></div> <div class="right"><input title="1. DNS" maxlength="20" name="ip_dns1" value="192.168.1.254" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ip_dns2"> <div class="left"><label>2. DNS</label></div> <div class="right"><input title="2. DNS" maxlength="20" name="ip_dns2" value="192.168.1.253" type="text"></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <div class="htmlobject_box input" id="htmlobject_box_ip_adressen"> <div class="left"><label>ip_adressen</label></div> <div class="right"><textarea name="ip_adressen" cols="15" rows="17">192.168.1.10 192.168.1.11 192.168.1.12 192.168.1.13 </textarea></div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> <input type=hidden name="action" value="angelegt"> <br> <input type=submit value="erstellen"> <br> </form> <div style="line-height:0px;clear:both;">&#160;</div> </div> ==== /usr/lib/cgi-bin/zimmer_iptable-aendern.cgi ==== #!/bin/sh DATENDATEI="$(mktemp /tmp/zimmer.XXXXXXXXXXXX)" ### POST-Daten werden in eine Datei geschrieben echo "$(dd bs=1 count=${CONTENT_LENGTH} 2> /dev/null | tr -s '&' '\n')" | sed -e 's/=+/=/g' -e 's/+$//g' | tr -d '"' > ${DATENDATEI} 2>&1 . ${DATENDATEI} . /usr/share/openqrm/etc/openqrm-server.conf . $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg ### GET AKTION="$(echo "${QUERY_STRING}" | awk -F'=' '{print $1}')" WERT="$(echo "${QUERY_STRING}" | awk -F'=' '{print $2}' | awk -F'&' '{print $1}')" if [ -n "${1}" -a -z "${AKTION}" ] ; then AKTION="$(echo "${1}" | awk -F'=' '{print $1}')" WERT="$(echo "${1}" | awk -F'=' '{print $2}')" fi #------------------------------------------------------------------------------# echo "Content-type: text/html <link rel='stylesheet' type='text/css' href='/openqrm/base/css/htmlobject.css' /> <link rel='stylesheet' type='text/css' href='/cloud.css' /> <script type='text/javascript'> function currenttabToggle(id) { document.getElementById(id).style.display = 'block'; document.getElementById('tab_' + id).className = 'current'; } </script> " #------------------------------------------------------------------------------# if [ "${AKTION}" = "aendern" ] ; then echo " <div class='htmlobject_tabs' id='p8c889ec95a9d2'> <ul> <li id='tab_currenttabtab0' class='current'><span><a href='' onclick='this.blur();'>neue Zimmer IP-Gruppe erstellen</a></span></li> </ul> </div> <div style='line-height:0px;clear:both;'>&#160;</div> <div class='htmlobject_tab_box' id='currenttabtab0'><style> .htmlobject_tab_box { } </style> <h1><img border=0 src='/cloudipgroups.png'>Datensatz zur Zimmer-IP '${WERT}' &auml;ndern</h1> <br> <form action=/cgi-bin/zimmer_ip-machen.cgi method=post> " echo " SELECT * FROM ${ZIPTABLES} WHERE ip_address='${WERT}' ; " | mysql -t -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | egrep -v '[\+\|]---------' | tr -s '\t' ' ' | sed -e 's#| |#| "" |#g' -e 's#| |#| "" |#g' | nl | while read LFDNR ZEILE do if [ "${LFDNR}" = "1" ] ; then KOPF="$(echo "${ZEILE}" | sed 's#|#\n#g' | egrep -v '^$' | awk '{print $1}')" else DATEN="$(echo "${ZEILE}" | sed 's#|#\n#g' | egrep -v '^$' | awk '{print $1}')" echo "${KOPF}" | nl | fgrep -v ip_ig_id | while read SPALTENNR SPALTENNAME do SPALTENWERT="$(echo "${DATEN}" | head -n${SPALTENNR} | tail -n1 | tr -d '"')" if [ "${SPALTENNAME}" = "ip_address" ] ; then echo "<input type=\"hidden\" name=\"${SPALTENNAME}\" value=\"${SPALTENWERT}\">" else echo " <div class=\"htmlobject_box input\" id=\"htmlobject_box_${SPALTENNAME}\"> <div class=\"left\"><label for=\"p4c443ec95a81b\">${SPALTENNAME}</label></div> <div class=\"right\"><input title=\"Name\" id=\"p4c443ec95a81b\" maxlength=\"20\" name=\"${SPALTENNAME}\" value=\"${SPALTENWERT}\" type=\"text\"></div> <div style=\"line-height:0px;height:0px;clear:both;\" class=\"floatbreaker\">&#160;</div> </div> " fi done fi done #------------------------------------------------------------------------------# echo ' <input type=hidden name="action" value="aendern"> <br> <input type=submit value="&auml;ndern"> <br> </form> <div style="line-height:0px;clear:both;">&#160;</div> </div> ' #------------------------------------------------------------------------------# elif [ "${AKTION}" = "loeschen" ] ; then IGID="$(echo "SELECT ip_ig_id FROM ${ZIPTABLES} WHERE ip_address='${WERT}' LIMIT 1;"|mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" echo " <div class='htmlobject_tabs' id='p8c889ec95a9d2'> <ul> <li id='tab_currenttabtab0' class='current'><span><a href='' onclick='this.blur();'>Zimmer IP gel&ouml;scht</a></span></li> </ul> </div> <div style='line-height:0px;clear:both;'>&#160;</div> <div class='htmlobject_tab_box' id='currenttabtab0'><style> .htmlobject_tab_box { } </style> <h1><img border=0 src='/cloudipgroups.png'>Zimmer-IP '${WERT}' aus der IP-Gruppe '${IGID}' gel&ouml;scht</h1> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen anzeigen</a></b> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi?aendern=${IGID}">alle Zimmer IP's der Gruppe '${IGID}' anzeigen</a></b> <br> <br> " echo " DELETE FROM ${ZIPTABLES} WHERE ip_address='${WERT}' ;" | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 elif [ "${AKTION}" = "hinzufuegen" ] ; then echo " <div class='htmlobject_tabs' id='p8c889ec95a9d2'> <ul> <li id='tab_currenttabtab0' class='current'><span><a href='' onclick='this.blur();'>zur Zimmer IP-Gruppe '${WERT}' weitere IP's hinzuf&uuml;gen</a></span></li> </ul> </div> <div style='line-height:0px;clear:both;'>&#160;</div> <div class='htmlobject_tab_box' id='currenttabtab0'><style> .htmlobject_tab_box { } </style> <h1><img border=0 src='/cloudipgroups.png'>zur Zimmer IP-Gruppe '${WERT}' weitere IP's hinzuf&uuml;gen</h1> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen</a></b> <br> <br> <form action=/cgi-bin/zimmer_iptable-aendern.cgi method=post> " IPGRUPPE="$(echo " SELECT * FROM ${ZIPTABLES} WHERE ip_ig_id='${WERT}' LIMIT 1 ;" | mysql -t -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | egrep -v '[\+\|]---------' | tr -s '\t' ' ' | sed -e 's#| |#| "" |#g' -e 's#| |#| "" |#g')" KOPF="$(echo "${IPGRUPPE}" | head -n1 | sed -e 's/ //g' -e 's/|/\n/g' | egrep -v '^$')" DATEN="$(echo "${IPGRUPPE}" | tail -n1 | sed -e 's/ //g' -e 's/|/\n/g' | egrep -v '^$')" echo "${KOPF}" | nl | while read SPALTENNUMMER SPALTENNAME do if [ "${SPALTENNAME}" = "ip_address" ] ; then SPALTENWERT="" SPALTENBEZ="<B>${SPALTENNAME}</B>" else SPALTENWERT="$(echo "${DATEN}" | head -n${SPALTENNUMMER} | tail -n1)" SPALTENBEZ="${SPALTENNAME}" fi echo " <div class='htmlobject_box input' id='htmlobject_box_${SPALTENNAME}'> <div class='left'><label>${SPALTENBEZ}:</label></div> <div class='right'><input title='${SPALTENNAME}' maxlength='20' name='${SPALTENNAME}' value='${SPALTENWERT}' type='text'></div> <div style='line-height:0px;height:0px;clear:both;' class='floatbreaker'>&#160;</div> </div> " done echo " <input type=hidden name='action' value='hinzugefuegt'> <br> <input type=submit value='hinzuf&uuml;gen'> <br> </form> <div style='line-height:0px;clear:both;'>&#160;</div> </div> " elif [ "${action}" = "hinzugefuegt" ] ; then echo " <div class='htmlobject_tabs' id='p8c889ec95a9d2'> <ul> <li id='tab_currenttabtab0' class='current'><span><a href='' onclick='this.blur();'>'${ip_address}' wurde zur Zimmer IP-Gruppe '${ip_ig_id}' hinzugef&uuml;gt</a></span></li> </ul> </div> <div style='line-height:0px;clear:both;'>&#160;</div> <div class='htmlobject_tab_box' id='currenttabtab0'><style> .htmlobject_tab_box { } </style> <h1><img border=0 src='/cloudipgroups.png'>'${ip_address}' wurde zur Zimmer IP-Gruppe '${ip_ig_id}' hinzugef&uuml;gt</h1> <br> <b><a href="/cgi-bin/zimmer_ip-machen.cgi">alle Zimmer IP-Gruppen</a></b> <br> <br> " ### der "action"-Eintrag wird entfernt sed -i -e 's/action=hinzugefuegt//' ${DATENDATEI} ### IP in die Tabelle eintragen echo "INSERT INTO ${ZIPTABLES} ($(cat ${DATENDATEI}|egrep -v '^$'|awk -F'=' '{print $1}'|tr -s '\n' ','|sed 's/,$//')) VALUES ($(cat ${DATENDATEI}|egrep -v '^$'|awk -F'=' '{print $2}'|sed "s/.*/'&'/"|tr -s '\n' ','|sed "s/',$/'/"));" \ | mysql -H -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} 2>&1 /usr/lib/cgi-bin/zimmer_ip-machen.cgi aendern=${ip_ig_id} fi rm -f ${DATENDATEI} ==== /opt/bin/ziptables_zeigen.sh ==== #!/bin/sh . /usr/share/openqrm/etc/openqrm-server.conf . $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg #SELECT ip_eth,ip_hostname,ip_domain,ip_address,ip_subnet,ip_gateway,ip_dns1,ip_dns2 echo " SELECT * FROM ${ZIPTABLES} ORDER BY ${ZIPTORDER} ASC ; " | mysql -t -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} ==== /opt/bin/in_zipgroups_eintragen.sh ==== #!/bin/sh ZID="${1}" ZNETIF="${2}" ZHOSTNAME="${3}" if [ -n "${3}" ] ; then . /usr/share/openqrm/etc/openqrm-server.conf . $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg ZIPADRESSE="$(echo " SELECT ip_address FROM ${ZIPTABLES} WHERE ip_ig_id='${ZID}' AND (ip_hostname IS NULL OR ip_hostname = 'NULL' OR ip_hostname = '') ORDER BY ${ZIPTORDER} ASC LIMIT 1 ;" \ | mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" KONFLIKT="$(echo " SELECT ip_hostname FROM ${ZIPTABLES} WHERE ip_ig_id='${ZID}' AND ip_hostname='${ZHOSTNAME}' ORDER BY ${ZIPTORDER} ASC LIMIT 1 ;" \ | mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" ZDOMAIN="$(echo " SELECT ip_domain FROM ${ZIPTABLES} WHERE ip_ig_id='${ZID}' ORDER BY ${ZIPTORDER} ASC LIMIT 1 ;" \ | mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME})" if [ -z "${KONFLIKT}" ] ; then if [ -n "${ZIPADRESSE}" ] ; then echo "UPDATE ${ZIPTABLES} SET ip_eth='${ZNETIF}',ip_hostname='${ZHOSTNAME}' WHERE ip_address='${ZIPADRESSE}';" \ | mysql -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} if [ -n "$(echo "${ZIPADRESSE}"|fgrep "${DATABASENET}")" ] ; then DNSDATEI="/usr/share/openqrm/plugins/dns/etc/bind/zones/database.db" elif [ -n "$(echo "${ZIPADRESSE}"|fgrep "${EXTERNNET}")" ] ; then DNSDATEI="/usr/share/openqrm/plugins/dns/etc/bind/zones/extern.db" else echo "${ZHOSTNAME}: NIC ${ZNETIF} wurde nicht gesetzt, ABBRUCH" exit 1 fi awk '/; serial$/ {sub(";"," ");print $1,$1+1}' ${DNSDATEI} | while read ASERIAL NSERIAL do ### neuer DNS-Eintrag rein echo "${ZHOSTNAME} IN A ${ZIPADRESSE}" >> ${DNSDATEI} sed -i -e "s/${ASERIAL}/${NSERIAL}/" -e '/^$/d' ${DNSDATEI} fgrep -i serial ${DNSDATEI} done else echo "Es gibt in der Gruppe '${ZID}'/'${ZDOMAIN}' keine freie IP mehr!" fi else echo "Es gibt in der Gruppe '${ZID}'/'${ZDOMAIN}' schon den Hostnamen '${KONFLIKT}'!" fi sudo /etc/init.d/bind9 reload else echo "${0} [ig_id] [net_if] [hostname]" fi ==== bin/aus_zipgroups_austragen.sh ==== #!/bin/sh HOSTNAME="${1}" if [ -n "${1}" ] ; then . /usr/share/openqrm/etc/openqrm-server.conf . $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/zips/etc/zips.cfg echo "UPDATE ${ZIPTABLES} SET ip_hostname='' WHERE ip_hostname='${HOSTNAME}';" \ | mysql -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} ### eth1 und eth2 ls /usr/share/openqrm/plugins/dns/etc/bind/zones/database.db /usr/share/openqrm/plugins/dns/etc/bind/zones/extern.db | awk -F':' '{print $1}' | sort | uniq | while read DNSDATEI do awk '/; serial$/ {sub(";"," ");print $1,$1+1}' ${DNSDATEI} | while read ASERIAL NSERIAL do ### alten DNS-Eintrag raus sed -i -e "s/${ASERIAL}/${NSERIAL}/" -e "s/${HOSTNAME}[ ]*IN[ ]*A[ ]*.*//" -e '/^$/d' ${DNSDATEI} fgrep -i serial ${DNSDATEI} done done sudo /etc/init.d/bind9 reload else echo "${0} [hostname]" fi ==== /opt/bin/zipgroups_managen.sh ==== #!/bin/sh # TEMP-Datei erzeugen DATENDATEI="$(mktemp /tmp/zipgroups.XXXXXXXXXXXX)" # TEMP-Datei füllen echo " ${1} ${2} ${3} ${4} " > ${DATENDATEI} # TEMP-Datei in die Umgebung einlesen . ${DATENDATEI} # TEMP-Datei löschen rm -f ${DATENDATEI} #------------------------------------------------------------------------------# ### GET-Daten zum eintragen # step_2=1 # appliance_name=vm-hellomobil02 # appliance_zipgeth1=1 # appliance_zipgeth2=2 ### eintragen # /opt/bin/in_zipgroups_eintragen.sh [ig_id] [net_if] [hostname] #------------------------------------------------------------------------------# ### austragen # /opt/bin/aus_zipgroups_austragen.sh [hostname] ### remove # action=remove # identifier=4,5,6,9, #------------------------------------------------------------------------------# # nur wenn es die richtige Seite war ( if [ "${step_2}" = "1" ] ; then date +'%F %T' # nur wenn der Hostname gesetzt wurde if [ -n "${appliance_name}" ] ; then # Eintrag für eth1 if [ -n "${appliance_zipgeth1}" ] ; then echo "sudo /opt/bin/in_zipgroups_eintragen.sh ${appliance_zipgeth1} eth1 ${appliance_name}" sudo /opt/bin/in_zipgroups_eintragen.sh ${appliance_zipgeth1} eth1 ${appliance_name} fi # Eintrag für eth2 if [ -n "${appliance_zipgeth2}" ] ; then echo "sudo /opt/bin/in_zipgroups_eintragen.sh ${appliance_zipgeth2} eth2 ${appliance_name}" sudo /opt/bin/in_zipgroups_eintragen.sh ${appliance_zipgeth2} eth2 ${appliance_name} fi fi elif [ "${action}" = "remove" ] ; then date +'%F %T' . /opt/etc/zimmer_ip.cfg for IDENTIFIER in $(echo "${identifier}" | sed 's/,/ /g') do for HOSTNAME in $(echo "SELECT appliance_name FROM appliance_info WHERE appliance_id='${IDENTIFIER}' ;" | mysql -N -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME}) do # hier werden die ZIMMER-IP's wieder frei gegeben echo "/opt/bin/aus_zipgroups_austragen.sh ${HOSTNAME}" /opt/bin/aus_zipgroups_austragen.sh ${HOSTNAME} # hier wird die Nagios-Konfiguration gelöscht rm -vf /etc/nagios3/conf.d/${HOSTNAME}*.cfg done /etc/init.d/nagios3 reload done fi ) 2>&1 | logger ==== /opt/bin/zipgroups_zeigen_html.sh ==== #!/bin/sh HTMLCODE="$(cat | tr -s "'" '"')" NA='<h1>New Appliance</h1>' RE='<h3>Requirements</h3>' if [ "$(echo "${HTMLCODE}" | fgrep "${NA}" > /dev/null ; echo "$?")" = "0" -a "$(echo "${HTMLCODE}" | fgrep "${RE}" > /dev/null ; echo "$?")" = "0" ] ; then #------------------------------------------------------------------------------# ### es ist genau die richtige Seite ETHPULLDOWN="$( . /opt/etc/zimmer_ip.cfg IFS="|" echo " eth1 eth2 " | egrep -v '^$' | while read NETZWERKKARTE do echo " <div class='htmlobject_box select' id='htmlobject_box_appliance_zipg${NETZWERKKARTE}'> <div class='left'><label> ${NETZWERKKARTE}</label></div> <div class='right'> <select title='${NETZWERKKARTE}' name='appliance_zipg${NETZWERKKARTE}'> <option value='0'></option> " echo " SELECT ig_id,ig_name,ig_domain FROM ${ZIPGROUPS} ORDER BY ${ZIPGORDER} ASC ;" \ | mysql -N -t -h ${OPENQRM_DATABASE_SERVER} -u${OPENQRM_DATABASE_USER} -p${OPENQRM_DATABASE_PASSWORD} ${OPENQRM_DATABASE_NAME} \ | egrep -v '[\+\|]---------' | egrep -v '^$' | while read ANFANG ig_id ig_name ig_domain ENDE do ig_id="$(echo "${ig_id}" | awk '{print $1}')" ig_name="$(echo "${ig_name}" | awk '{print $1}')" ig_domain="$(echo "${ig_domain}" | awk '{print $1}')" echo "<option value='${ig_id}'>${ig_name} | ${ig_domain}</option>" done echo ' </select> </div> <div style="line-height:0px;height:0px;clear:both;" class="floatbreaker">&#160;</div> </div> ' done | tr -s '"' "'")" #------------------------------------------------------------------------------# echo "${HTMLCODE}" | while read ZEILE do POSITION="$(echo "${ZEILE}" | egrep '<div style="text-align:right;"><input title="save" id=.*name="action" value="save" type="submit"></div>')" if [ -n "${POSITION}" ] ; then echo "${ETHPULLDOWN}" fi echo "${ZEILE}" done #------------------------------------------------------------------------------# else #------------------------------------------------------------------------------# ### es ist eine andere Seite echo "${HTMLCODE}" #------------------------------------------------------------------------------# fi ==== /usr/share/openqrm/web/base/server/appliance/appliance-new.php ==== Ganz oben kommen zwei Zeilen rein ($KOMMANDO), die die Auswertung der GET-Daten vornehmen, in die PHP-Datei. Diese Zeilen gibt es schon: $thisfile = basename($_SERVER['PHP_SELF']); $RootDir = $_SERVER["DOCUMENT_ROOT"].'/openqrm/base/'; require_once "$RootDir/include/user.inc.php"; require_once "$RootDir/class/image.class.php"; require_once "$RootDir/class/resource.class.php"; require_once "$RootDir/class/appliance.class.php"; require_once "$RootDir/class/kernel.class.php"; require_once "$RootDir/class/virtualization.class.php"; require_once "$RootDir/class/openqrm_server.class.php"; require_once "$RootDir/include/htmlobject.inc.php"; if(strtolower(OPENQRM_USER_ROLE_NAME) != 'administrator') { echo 'Access denied'; exit; } Wir setzen unsere beiden Zeilen direkt dhinter: $KOMMANDO = "/opt/bin/zipgroups_managen.sh"." step_2=".$_GET["step_2"]." appliance_name=".$_GET["appliance_name"]." appliance_zipgeth1=".$_GET["appliance_zipgeth1"]." appliance_zipgeth2=".$_GET["appliance_zipgeth2"]; echo shell_exec("$KOMMANDO;"); Ganz unten wird der durch PHP generierte HTML-Code ausgegeben. Hier wird die Originalzeile "echo htmlobject_tabmenu($output);" deaktiviert und dafür drei neue Zeilen eingefühgt. An dieser Stelle muss unser Filterscript (/opt/bin/zipgroups_zeigen_html.sh) zwischen geschaltet werden, damit die zwei Pull-Down-Menüs für die Zuweisung zu den Z-IP-Gruppen je "eth" erscheinen. So sieht das Ende im Original aus: <?php echo htmlobject_tabmenu($output); ?> Wir ändern das so ab: <?php //echo htmlobject_tabmenu($output); $test = htmlobject_tabmenu($output); $KOMMANDO="echo"." '".$test."' | /opt/bin/zipgroups_zeigen_html.sh"; echo shell_exec("$KOMMANDO;"); ?> ==== /usr/share/openqrm/web/base/server/appliance/appliance-index.php ==== Damit die Einträge zu einer Appliance beim löschen auch aus der Z-IP-Tabelle entfernt werden, müssen wir hier noch einen Eintrag vornehmen. Diese Funktion gibt es schon: function redirect($strMsg, $currenttab = 'tab0', $url = '') { global $thisfile; if($url == '') { $url = $thisfile.'?strMsg='.urlencode($strMsg).'&currenttab='.$currenttab; } // using meta refresh here because the appliance and resourc class pre-sending header output echo "<meta http-equiv=\"refresh\" content=\"0; URL=$url\">"; } Unseren Eintrag setzen wir direkt dahinter: foreach ($_GET["identifier"] as $key => $value) { $ids .= $value.","; }; $KOMMANDO = "/opt/bin/zipgroups_managen.sh"." action=".$_GET["action"]." identifier=".$ids; echo shell_exec("$KOMMANDO;"); FIXME

openqrm_-_z-ip_s.txt · Zuletzt geändert: 2016/04/13 00:50 (Externe Bearbeitung)