Browse Source

First commit

Espinoza Guillermo 7 years ago
commit
4e0e95d7ec

+ 35 - 0
.drone.yml

@@ -0,0 +1,35 @@
+pipeline:
+ build:
+    image: docker.infra.flowdat.com/fd3/sf-php:latest
+    pull: true
+    commands:
+      - env
+      - php -v
+
+ docker_kea_1.3.0:
+   repo : docker.infra.flowdat.com/fd3/kea-1.3.0
+   image: plugins/docker
+   pull: true
+   email: luciano@interlink.com.ar
+   registry: docker.infra.flowdat.com
+   dockerfile: 1.3.0/Dockerfile
+   tag:
+     - latest
+     - ${DRONE_TAG##v}
+   when:
+    event: [ tag ]
+    branch: v*
+
+ docker_kea_1.4.0:
+   repo : docker.infra.flowdat.com/fd3/kea-1.4.0
+   image: plugins/docker
+   pull: true
+   email: luciano@interlink.com.ar
+   registry: docker.infra.flowdat.com
+   dockerfile: 1.4.0/Dockerfile
+   tag:
+     - latest
+     - ${DRONE_TAG##v}
+   when:
+    event: [ tag ]
+    branch: v*

+ 57 - 0
1.3.0/Dockerfile

@@ -0,0 +1,57 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get install -yq git vim build-essential dhcping
+
+RUN apt-get update && apt-get install -yq dh-autoreconf automake
+RUN apt-get update && apt-get install -yq libssl-dev liblog4cplus-dev libboost-dev libmysqlclient-dev libboost-all-dev
+
+RUN git clone https://github.com/isc-projects/kea.git /opt/kea
+RUN cd /opt/kea && autoreconf --install
+RUN cd /opt/kea && ./configure --with-dhcp-mysql --enable-shell
+RUN cd /opt/kea && make install
+
+RUN cd /opt/kea && ldconfig
+
+RUN apt-get update && apt-get install -yq mysql-client
+
+EXPOSE 67/udp
+EXPOSE 68/udp
+
+ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
+ENV KEA_LIB=/opt/kea/src/lib
+ENV KEA_INCLUDE=/opt/kea/src/lib
+
+RUN mkdir ~/.ssh
+RUN ssh-keyscan -H -p 22  bitbucket.org >> ~/.ssh/known_hosts
+COPY keys/ /opt/keys
+RUN chmod 0600 /opt/keys/bitbucket.id_rsa
+RUN eval $(ssh-agent) && ssh-add /opt/keys/bitbucket.id_rsa && git clone git@bitbucket.org:ikflowdat/kea-cm-hook.git
+
+EXPOSE 67/udp
+EXPOSE 68/udp
+
+ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
+ENV KEA_LIB=/opt/kea/src/lib
+ENV KEA_INCLUDE=/opt/kea/src/lib
+
+RUN cd kea-cm-hook && make
+
+RUN git clone git://github.com/alanxz/rabbitmq-c.git
+RUN apt-get update && apt-get install -yq cmake
+RUN cd rabbitmq-c && mkdir build && cd build && cmake .. && cmake --build . 
+RUN cd rabbitmq-c/build && make  && make install
+
+RUN cp /usr/local/lib/x86_64-linux-gnu/librabbitmq.so /usr/local/lib/librabbitmq.so
+
+RUN git clone https://github.com/akalend/amqpcpp
+RUN cd amqpcpp && make && make install
+RUN cp amqpcpp/libamqpcpp.a /usr/local/lib/libamqpcpp.a
+RUN cp amqpcpp/libamqpcpp.so /usr/local/lib/libamqpcpp.so
+RUN cp /usr/local/lib/libamqpcpp.so /usr/local/lib/x86_64-linux-gnu/libamqpcpp.so
+
+COPY hook/ hook/
+RUN cd hook/dhcp && make
+
+COPY script.sh /opt/script.sh
+RUN chmod +x /opt/script.sh
+CMD /opt/script.sh

+ 57 - 0
1.4.0/Dockerfile

@@ -0,0 +1,57 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get install -yq git vim build-essential dhcping
+
+RUN apt-get update && apt-get install -yq dh-autoreconf automake
+RUN apt-get update && apt-get install -yq libssl-dev liblog4cplus-dev libboost-dev libmysqlclient-dev libboost-all-dev
+
+RUN git clone https://github.com/isc-projects/kea.git /opt/kea
+RUN cd /opt/kea && autoreconf --install
+RUN cd /opt/kea && ./configure --with-dhcp-mysql --enable-shell
+RUN cd /opt/kea && make install
+
+RUN cd /opt/kea && ldconfig
+
+RUN apt-get update && apt-get install -yq mysql-client
+
+EXPOSE 67/udp
+EXPOSE 68/udp
+
+ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
+ENV KEA_LIB=/opt/kea/src/lib
+ENV KEA_INCLUDE=/opt/kea/src/lib
+
+RUN mkdir ~/.ssh
+RUN ssh-keyscan -H -p 22  bitbucket.org >> ~/.ssh/known_hosts
+COPY keys/ /opt/keys
+RUN chmod 0600 /opt/keys/bitbucket.id_rsa
+RUN eval $(ssh-agent) && ssh-add /opt/keys/bitbucket.id_rsa && git clone git@bitbucket.org:ikflowdat/kea-cm-hook.git
+
+EXPOSE 67/udp
+EXPOSE 68/udp
+
+ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
+ENV KEA_LIB=/opt/kea/src/lib
+ENV KEA_INCLUDE=/opt/kea/src/lib
+
+RUN cd kea-cm-hook && make
+
+RUN git clone git://github.com/alanxz/rabbitmq-c.git
+RUN apt-get update && apt-get install -yq cmake
+RUN cd rabbitmq-c && mkdir build && cd build && cmake .. && cmake --build . 
+RUN cd rabbitmq-c/build && make  && make install
+
+RUN cp /usr/local/lib/x86_64-linux-gnu/librabbitmq.so /usr/local/lib/librabbitmq.so
+
+RUN git clone https://github.com/akalend/amqpcpp
+RUN cd amqpcpp && make && make install
+RUN cp amqpcpp/libamqpcpp.a /usr/local/lib/libamqpcpp.a
+RUN cp amqpcpp/libamqpcpp.so /usr/local/lib/libamqpcpp.so
+RUN cp /usr/local/lib/libamqpcpp.so /usr/local/lib/x86_64-linux-gnu/libamqpcpp.so
+
+COPY hook/ hook/
+RUN cd hook/dhcp && make
+
+COPY script.sh /opt/script.sh
+RUN chmod +x /opt/script.sh
+CMD /opt/script.sh

+ 94 - 0
conf/kea-ctrl-agent.conf

@@ -0,0 +1,94 @@
+// This is a basic configuration for the Kea Control Agent.
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// on Kea web page (http://kea.isc.org, click User's Guide, direct link for
+// stable version is http://kea.isc.org/docs/kea-guide.html).
+//
+// This configuration file contains only Control Agent's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the Control Agent.
+{
+
+// This is a basic configuration for the Kea Control Agent.
+// RESTful interface to be available at http://127.0.0.1:8080/
+"Control-agent": {
+    "http-host": "0.0.0.0",
+    "http-port": 8080,
+
+    // Specify location of the files to which the Control Agent
+    // should connect to forward commands to the DHCPv4 and DHCPv6
+    // server via unix domain socket.
+    "control-sockets": {
+        "dhcp4": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
+        },
+        "dhcp6": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
+        }
+    },
+
+    // Specify hooks libraries that are attached to the Control Agent.
+    // Such hooks libraries should support 'control_command_receive'
+    // hook point. This is currently commented out because it has to
+    // point to the existing hooks library. Otherwise the Control
+    // Agent will fail to start.
+    "hooks-libraries": [
+//  {
+//      "library": "/opt/local/control-agent-commands.so",
+//      "parameters": {
+//          "param1": "foo"
+//      }
+//  }
+    ]
+},
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+"Logging":
+{
+  "loggers": [
+    {
+        // This specifies the logging for Control Agent daemon.
+        "name": "kea-ctrl-agent",
+        "output_options": [
+            {
+                // Specifies the output file. There are several special values
+                // supported:
+                // - stdout (prints on standard output)
+                // - stderr (prints on standard error)
+                // - syslog (logs to syslog)
+                // - syslog:name (logs to syslog using specified name)
+                // Any other value is considered a name of a time
+                "output": "@localstatedir@/log/kea-ctrl-agent.log"
+
+                // This governs whether the log output is flushed to disk after
+                // every write.
+                // "flush": false,
+
+                // This specifies the maximum size of the file before it is
+                // rotated.
+                // "maxsize": 1048576,
+
+                // This specifies the maximum number of rotated files to keep.
+                // "maxver": 8
+            }
+        ],
+        // This specifies the severity of log messages to keep. Supported values
+        // are: FATAL, ERROR, WARN, INFO, DEBUG
+        "severity": "INFO",
+
+        // If DEBUG level is specified, this value is used. 0 is least verbose,
+        // 99 is most verbose. Be cautious, Kea can generate lots and lots
+        // of logs if told to do so.
+        "debuglevel": 0
+    }
+  ]
+}
+}

+ 27 - 0
hook/dhcp/Makefile

@@ -0,0 +1,27 @@
+
+KEA_MSG_COMPILER ?= /opt/kea/bin/kea-msg-compiler
+KEA_INCLUDE ?= ~/kea-1.3.0/src/lib
+KEA_LIB ?= /opt/kea/lib/
+
+OBJECTS = src/messages.o src/logger.o src/load.o src/callouts.o src/version.o
+DEPS = $(OBJECTS:.o=.d)
+CXXFLAGS = -I $(KEA_INCLUDE) -g -fPIC -Wno-deprecated -std=c++11
+LDFLAGS = -L $(KEA_LIB) -shared -lkea-dhcpsrv -lkea-dhcp++ -lkea-hooks -lkea-log -lkea-util -lkea-exceptions -lamqpcpp -lrabbitmq
+
+kea-hook-flowdat3.so: $(OBJECTS)
+	$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(OBJECTS)
+
+%.o: %.cc
+	$(CXX) -MMD -MP -c $(CXXFLAGS) -o $@ $<
+
+# Compile messages (for logging)
+src/messages.h src/messages.cc: s-messages
+s-messages: src/messages.mes
+	$(KEA_MSG_COMPILER) -d src/ $<
+	touch $@
+
+clean:
+	rm -f src/*.o *.so
+	rm -f src/messages.h src/messages.cc s-messages
+
+-include $(DEPS)

+ 34 - 0
hook/dhcp/src/amqppublisher.h

@@ -0,0 +1,34 @@
+#include "AMQPcpp.h"
+#include <string>
+
+using namespace std;
+
+class AMQPPublisher 
+{
+    public:
+        int publish(string message)
+        {
+            try {
+                AMQP amqp("guest:guest@amqp:5672/");
+                
+                AMQPExchange * ex = amqp.createExchange("kea");
+            
+                ex->Declare("kea", "fanout");
+            
+                AMQPQueue * qu2 = amqp.createQueue("kea");
+            
+                qu2->Declare();
+                qu2->Bind( "kea", "");		
+            
+                ex->setHeader("Delivery-mode", 2);
+                ex->setHeader("Content-type", "text/text");
+                ex->setHeader("Content-encoding", "UTF-8");
+            
+                ex->Publish(  message , "");				
+            } catch (AMQPException e) {
+                std::cout << e.getMessage() << std::endl;
+            }
+            
+            return 0;
+        }
+};

+ 89 - 0
hook/dhcp/src/callouts.cc

@@ -0,0 +1,89 @@
+#include <hooks/hooks.h>
+#include <dhcp/pkt4.h>
+#include <dhcp/hwaddr.h>
+#include <dhcpsrv/subnet.h>
+#include <dhcpsrv/lease.h>
+#include <util/strutil.h>
+#include <dhcp/option_string.h>
+#include <dhcp/option4_addrlst.h>
+#include <dhcp/docsis3_option_defs.h>
+#include <string>
+
+#include <boost/foreach.hpp>
+
+#include "logger.h"
+#include "common.h"
+
+#include "amqp.h"
+#include "AMQPcpp.h"
+// #include <amqp.h>
+// #include <AMQPcpp.h>
+// #include "amqppublisher.h"
+
+using namespace isc::dhcp;
+using namespace isc::hooks;
+
+int publishMessage(std::string message)
+{
+    try {
+        // AMQP amqp("guest:guest@amqp:5672/");
+        AMQP amqp("guest:guest@172.20.0.6:5672/");
+        
+        AMQPExchange * ex = amqp.createExchange("kea");
+        
+        ex->Declare("kea", "fanout");
+        
+        AMQPQueue * qu2 = amqp.createQueue("kea");
+        
+        qu2->Declare();
+        qu2->Bind( "kea", "");		
+        
+        ex->setHeader("Delivery-mode", 2);
+        ex->setHeader("Content-type", "text/text");
+        ex->setHeader("Content-encoding", "UTF-8");
+        
+        ex->Publish(  message , "");				
+    } catch (AMQPException e) {
+        std::cout << e.getMessage() << std::endl;
+    }
+    
+    return 0;
+}
+
+extern "C" {
+
+#include <numeric>    //inner_product
+#include <functional> //plus, equal_to, not2
+#include <string>   
+#include <stdexcept>
+
+
+
+/* IPv4 callouts */
+int pkt4_receive(CalloutHandle& handle) 
+{
+    Pkt4Ptr query;
+    handle.getArgument("query4", query);
+
+    // AMQPPublisher amqp;
+    publishMessage(query->toText());
+
+    return 0;
+}
+
+int pkt4_send(CalloutHandle& handle) 
+{
+    Pkt4Ptr response;
+    Pkt4Ptr query;
+    handle.getArgument("response4", response);
+    handle.getArgument("query4", query);
+
+    // AMQPPublisher amqp;
+    publishMessage(query->toText());
+
+    return 0;
+}
+
+
+
+} // end extern "C"

+ 12 - 0
hook/dhcp/src/common.h

@@ -0,0 +1,12 @@
+#include <string>
+#include <map>
+
+extern "C" {
+
+/* From load.cc */
+
+/* Maps of the cablemodem states */
+extern std::map<std::string, std::string> cm_map;
+extern std::map<std::string, std::string> option122_map;
+
+}

+ 66 - 0
hook/dhcp/src/load.cc

@@ -0,0 +1,66 @@
+#include <hooks/hooks.h>
+#include <map>
+#include <boost/foreach.hpp>
+
+#include "logger.h"
+#include "common.h"
+
+// #include "amqp.h"
+// #include "amqppublisher.h"
+
+using namespace isc::hooks;
+using namespace isc::data;
+
+std::map<std::string, std::string> cm_map;
+std::map<std::string, std::string> option122_map;
+// AMQPPublisher amqp;
+
+extern "C" {
+
+int loadMappging(std::string base_map_config, LibraryHandle& handle, std::map<std::string, std::string>& map){
+
+    ConstElementPtr curr_map = handle.getParameter(base_map_config);
+    if (Element::map != curr_map->getType()){
+        LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config);
+        return 1;
+    }
+
+    std::map<std::string, ConstElementPtr> map_config = curr_map->mapValue();;
+    std::pair<std::string, ConstElementPtr> me; 
+
+    BOOST_FOREACH(me, map_config) {
+	std::string class_to_map = me.first;
+	std::cout << me.first << "\n";
+	ConstElementPtr table = me.second;
+	if(table->getType() != Element::list){
+		LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first);
+		return 1;
+	} 
+	const std::vector<ElementPtr> mac_list = table->listValue();
+	for(int i = 0; i < mac_list.size(); i++) {
+		ElementPtr it = mac_list[i];
+		if(it->getType() != Element::string){
+			LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first + "[" + std::to_string(i) + "]");
+			return 1;
+		}
+		std::cout << mac_list[i]->stringValue() << "\n";
+		std::string mac = mac_list[i]->stringValue();
+		std::transform(mac.begin(), mac.end(),mac.begin(), ::toupper);
+
+		map[mac] = class_to_map;
+	}
+    }
+
+    return 0;
+}
+
+int load(LibraryHandle& handle) 
+{
+    // amqp;
+    
+    return 0;
+}
+
+
+
+} // end extern "C"

+ 3 - 0
hook/dhcp/src/logger.cc

@@ -0,0 +1,3 @@
+#include "logger.h"
+
+isc::log::Logger runscript_logger("hook-ik-cablemodem");

+ 11 - 0
hook/dhcp/src/logger.h

@@ -0,0 +1,11 @@
+#ifndef RUNSCRIPT_LOGGER_H
+#define RUNSCRIPT_LOGGER_H
+#include <log/logger.h>
+#include <log/message_initializer.h>
+#include <log/macros.h>
+
+#include "messages.h"
+
+extern isc::log::Logger runscript_logger;
+
+#endif

+ 30 - 0
hook/dhcp/src/messages.mes

@@ -0,0 +1,30 @@
+% RUNSCRIPT_MISSING_PARAM required parameter "%1" missing in configuration
+A required parameter of this library hook is missing in the configuration,
+which prevents the library from working correctly.
+
+% RUNSCRIPT_MISTYPED_PARAM parameter "%1" in configuration has wrong type
+A parameter of this library hook is defined in the configuration but has the
+wrong type.  For instance, a string may have been passed as parameter while
+an integer was expected.
+
+% RUNSCRIPT_FORK_FAILED fork() failed with error: %1
+Running the user-defined script is done with fork + exec, and there was an error
+during the fork, possibly due to a lack of resources.
+
+% RUNSCRIPT_EXEC_FAILED exec() failed, please check that the script exists and is executable. Error: %1
+Attempting to execute the user-defined script failed.
+
+% RUNSCRIPT_WAITPID_FAILED waitpid() failed with error: %1
+The main hook process failed to wait for the child process to exit.
+The hook runs the user-defined script in a child process, and normally waits for it to exit.
+
+% RUNSCRIPT_WAITING_SCRIPT the user-defined script is running, and the main process is currently waiting
+The user-defined script has just been launched, and Kea is waiting for it to exit.
+This is useful to know, because if the user-defined script blocks, Kea will stay stuck
+at this point.
+
+% RUNSCRIPT_DEBUG_STRING %1
+Something somthing shomething
+
+% FLOWDAT_DEBUG_STRING %1
+Something somthing shomething

+ 7 - 0
hook/dhcp/src/version.cc

@@ -0,0 +1,7 @@
+// version.cc
+#include <hooks/hooks.h>
+extern "C" {
+int version() {
+    return (KEA_HOOKS_VERSION);
+}
+}

+ 27 - 0
keys/bitbucket.id_rsa

@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAsCo4Xa/fLaryiZt6igRK1IPNJsKeDLWBN6CWrv3TQ2iMcwE1
+zhTTX115N+KngVN8p1v5VrSMHKpvyXQDZPG/FJnWm5ry75qSYTmEtY8nfRsGAbwT
+i4swY+4jqrH1RRjbuVMsXPGjFX34SZTTJEl8ouVAFy/7HR+ODUe2+enWVnaouhVs
+Xj+bW2u7/dV1kZctFa5g5iV3hqGH32dBME5ztg4Fh7fAxkRTiJl+NBI7/LIdv9dl
+qmtDAdNdRqaI1dBpy8sHyZhRfjPeVbhdKsjE5IBhDLlYzyxK5FC41us08VCdq+M1
+1qVzIVM61PBosW5NfwlrRgLDPEXkazUdhJO6YwIDAQABAoIBAFEf4D0klH4PTwmX
+k+Ki/2LGH19OGEJ6Azt+tGV5diSArMz5LbHtXTl5bi0SL1ka/TiE3lnTYwKAamI3
+DqkZuojeHzohLOayI96qAjcp6WFvZGDAH7APNQWP0NT2hqB/RhAeATv7+sIW9JPN
++T2oqcDKGa2T5uwOb/glolmMGaxOzNfAFAgnD7p7cnR0yijW5t3bc4q0sOFu/H3N
+jYsAqvMu6Nkpt9hjlu42x5Muwj9YeKwpZoE1sno62JeQFZo7nO7DrOrE7DOENoWV
+PMDxs8Hz0SRQlZcJn2I/W9wX8A8gCAWGhbAtUGQkS8gCaMp0dOcxoV3EttriQgtU
+X1oUwIECgYEA2Vge4E8E53BzLGTk8sozn1qteYn3cLGgJgC78MEzZN/G57DxVbC9
+ntlSlYaYLlaPlSlNzZyG0s3UhpPY7YgP9srpohfPyXvb0ycfsGYMOcRNjVwdi2ap
+dPiG+p9vLSG3raNoeTxDEtjFZz1EM1rQECx2N40JwIuzeM2g+kE0JjMCgYEAz38r
+NTs1wASG7Bc7geIDxb34PWM8Nnw/DN57ceJP+Miwq/hYAJg6eK57ar9n44Y3xf7a
+mHkkgBU1vzuIyYfC5jVut6XkbialLsJUHfCNi3fPDBR7sEy6soiN34GoGp2vnCVD
+pDf2aCSMeFGfgwe4imFHbqE0R87cnet+q+CjCxECgYA8EbfO5OgFEzYxwdzpIWtt
+EoG5gqEpu134wuEupCcRLSvrIyNAPK3btlK10tJClFfwsM65EhbNMmgXncspsx4+
+Zkx2KUCbfij+TeTbOwkL+i448ImV2pThKEMeB2yRu6zpR617PGWJUvIUG4G689Fn
+dvJhXhCg77t1mtdv8w93swKBgQCIxor0y9LigBlwBuBy/Uj/T/oSfRdz0vK8yOsW
+ZtfQZnoO4eUgfzgL1PgFpaYVlKOvIA938mLdCx4isFu6fIM8vHv/EptBALhh2jcY
+hTjIdnFExTvDOtDWXq0mZ5En+kmH5Ahyd3E1tOHjbep3tN8wWG99vUV5ECLc9h7J
+rYnMAQKBgQDQ/JiBT7ygfzAblxPnq5Dnr52C3CFTE57GNA8FIEx+On6FdtVDRM0g
+cNjoc2e+2MfbaJXFAuMvXDvzb2qxrHgf2TosxeuPTg79iYOfWMU8G62i/v0wPr1M
+0Cj2hszJg4H0dMQPS0kDmO6mZmt6FB4E2gItmeBlTGfMwdJpaQC4rw==
+-----END RSA PRIVATE KEY-----

+ 1 - 0
keys/bitbucket.id_rsa.pub

@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwKjhdr98tqvKJm3qKBErUg80mwp4MtYE3oJau/dNDaIxzATXOFNNfXXk34qeBU3ynW/lWtIwcqm/JdANk8b8UmdabmvLvmpJhOYS1jyd9GwYBvBOLizBj7iOqsfVFGNu5Uyxc8aMVffhJlNMkSXyi5UAXL/sdH44NR7b56dZWdqi6FWxeP5tba7v91XWRly0VrmDmJXeGoYffZ0EwTnO2DgWHt8DGRFOImX40Ejv8sh2/12Wqa0MB011GpojV0GnLywfJmFF+M95VuF0qyMTkgGEMuVjPLErkULjW6zTxUJ2r4zXWpXMhUzrU8Gixbk1/CWtGAsM8ReRrNR2Ek7pj flowdat@bitbucket

+ 18 - 0
script.sh

@@ -0,0 +1,18 @@
+echo "[mysql]\nprotocol=tcp\n[client]\nhost=mysql" >> /etc/my.cnf
+echo "[mysql]\nprotocol=tcp\n[client]\nhost=mysql" >> /etc/mysql/my.cnf
+
+DATABASE=kea
+
+if ! mysql -u$MYSQL_USER -p$MYSQL_ROOT_PASSWORD -e "use ${DATABASE}"; then
+  mysql -u$MYSQL_USER -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE ${DATABASE} /*\!40100 DEFAULT CHARACTER SET utf8 */;"
+fi
+
+kea-admin lease-init mysql -h mysql -u $MYSQL_USER -p $MYSQL_ROOT_PASSWORD -n $DATABASE
+
+keactrl start -s dhcp4
+
+kea-ctrl-agent -c /usr/local/etc/kea/kea-ctrl-agent.conf
+
+keactrl status
+
+tail -f /dev/null