#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.2.4 # Package: kea #=========================== # DB commit: 3c6efcfc536d7802c89703820d548c1aec13ba9b # APP commit: f0568a86eced844506f88e1faa2e7a1c73783ddf #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: kea" echo "Release: 0.2.4" echo "Install with chimp: NO" downloadFile() { local filename=$1 echo "Downloading $filename ..." if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl -k -O $filename else wget --no-check-certificate -nc $filename fi } echo "loading environment settings(profile)" . /etc/profile echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi #Creating log directory mkdir -p /var/log/ulfs-packages/kea/ #Saving start timestamp date +%s > /var/log/ulfs-packages/kea/start.time #Going to source directory... cd /sources #Checking dependances... #Checking krb5... if [ ! -f /var/cache/ulfs-packages/krb5 ]; then echo "Dependance \"krb5\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/krb5/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/krb5/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/krb5 ]; then echo "Dependance \"krb5\" is not installed. Exiting..." exit fi fi #Checking boost... if [ ! -f /var/cache/ulfs-packages/boost ]; then echo "Dependance \"boost\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/boost/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/boost/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/boost ]; then echo "Dependance \"boost\" is not installed. Exiting..." exit fi fi #Checking mariadb-client... if [ ! -f /var/cache/ulfs-packages/mariadb-client ]; then echo "Dependance \"mariadb-client\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/mariadb-client/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/mariadb-client/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/mariadb-client ]; then echo "Dependance \"mariadb-client\" is not installed. Exiting..." exit fi fi #Checking postgresql-client... if [ ! -f /var/cache/ulfs-packages/postgresql-client ]; then echo "Dependance \"postgresql-client\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/postgresql-client/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/postgresql-client/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/postgresql-client ]; then echo "Dependance \"postgresql-client\" is not installed. Exiting..." exit fi fi #Checking valgrind... if [ ! -f /var/cache/ulfs-packages/valgrind ]; then echo "Dependance \"valgrind\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/valgrind/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/valgrind/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/valgrind ]; then echo "Dependance \"valgrind\" is not installed. Exiting..." exit fi fi #Checking log4cplus... if [ ! -f /var/cache/ulfs-packages/log4cplus ]; then echo "Dependance \"log4cplus\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.4/log4cplus/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.4/log4cplus/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/log4cplus ]; then echo "Dependance \"log4cplus\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/kea/download.time #Downloading source package archive... downloadFile https://umvirt.com/linux/downloads/0.2.4/packages/k/kea-3.0.1.tar.xz.md5sum downloadFile https://umvirt.com/linux/downloads/0.2.4/packages/k/kea-3.0.1.tar.xz #Checking source package file existance if [ ! -f kea-3.0.1.tar.xz ]; then echo "Error: Can't find kea-3.0.1.tar.xz. Exiting!" exit fi #Checking source package file checksum if [ -f kea-3.0.1.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c kea-3.0.1.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of kea-3.0.1.tar.xz is wrong. Exiting!" exit fi fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/kea/cleanup.time rm -rfv /sources/kea-3.0.1/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/kea/unpack.time #Extracting tar source package archive with default parameters... tar -xf kea-3.0.1.tar.xz #Checking package directory size after unpack... du -s kea-3.0.1 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/kea/unpack.size #Going to source package directory... cd kea-3.0.1 #Saving configuration timestamp date +%s > /var/log/ulfs-packages/kea/configure.time #Sleep 1 second sleep 1 if [[ "$ULFS_PKG_DATERESET" == "YES" ]] then #Changing all files creation time (except build configuration files) in source directory to find them after installation find /sources/kea-3.0.1 \! -path "*/configure*" \! -path "*/Makefile*" \! -path "*.make" \! -path "*.m4" \! -path "*.am" \! -path "*.mk" \! -path "*.stamp" \! -path "*gentpl.py" -exec touch -m {} + fi #Running configuration script... echo "loading environment settings(profile)" . /etc/profile echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_configure.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS sed -e "s/, modules: \\['system'\\]//" -i meson.build && sed -e "/shared_ptr.hpp/a#include " \\ -i src/lib/asiolink/interval_timer.cc && sed -e "/posix_time_types.hpp/a#include " \\ -i src/lib/asiodns/io_fetch.cc && sed -e "/posix_time_types.hpp/a#include " \\ -i src/lib/asiodns/tests/io_fetch_unittest.cc mkdir build && cd build && meson setup .. \\ --prefix=/usr \\ --sysconfdir=/etc \\ --localstatedir=/var \\ --buildtype=release \\ -D crypto=openssl \\ -D runstatedir=/run EOIS cat ulfs_configure.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/configure.log #Saving build timestamp date +%s > /var/log/ulfs-packages/kea/build.time #Running build script... echo "loading environment settings(profile)" . /etc/profile echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_build.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS cd build ninja EOIS cat ulfs_build.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/build.log #Saving install timestamp date +%s > /var/log/ulfs-packages/kea/install.time #Running install script... cat > ulfs_install.sh << EOIS cd build ninja install sed -e "s;\\\${prefix}/;;" -i /usr/sbin/keactrl install -dm0750 /var/lib/kea install -dm0750 /var/log/kea cat > /etc/kea/kea-ctrl-agent.conf << "EOF" // Begin /etc/kea/kea-ctrl-agent.conf { // This is a basic configuration for the Kea Control Agent. // RESTful interface to be available at http://127.0.0.1:8000/ "Control-agent": { "http-host": "127.0.0.1", "http-port": 8000, "control-sockets": { "dhcp4": { "socket-type": "unix", "socket-name": "/run/kea/kea4-ctrl-socket" }, "dhcp6": { "socket-type": "unix", "socket-name": "/run/kea/kea6-ctrl-socket" }, "d2": { "socket-type": "unix", "socket-name": "/run/kea/kea-ddns-ctrl-socket" } }, "loggers": [ { "name": "kea-ctrl-agent", "output_options": [ { "output": "/var/log/kea/kea-ctrl-agent.log", "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p %m\\n" } ], "severity": "INFO", "debuglevel": 0 } ] } } // End /etc/kea/kea-ctrl-agent.conf EOF cat > /etc/kea/kea-dhcp4.conf << "EOF" // Begin /etc/kea/kea-dhcp4.conf { "Dhcp4": { // Add names of your network interfaces to listen on. "interfaces-config": { "interfaces": [ "eth0", "eth2" ] }, "control-socket": { "socket-type": "unix", "socket-name": "/run/kea/kea4-ctrl-socket" }, "lease-database": { "type": "memfile", "lfc-interval": 3600, "name": "/var/lib/kea/kea-leases4.csv" }, "expired-leases-processing": { "reclaim-timer-wait-time": 10, "flush-reclaimed-timer-wait-time": 25, "hold-reclaimed-time": 3600, "max-reclaim-leases": 100, "max-reclaim-time": 250, "unwarned-reclaim-cycles": 5 }, "renew-timer": 900, "rebind-timer": 1800, "valid-lifetime": 3600, // Enable DDNS - Kea will dynamically update the DNS "ddns-send-updates" : true, "ddns-qualifying-suffix": "your.domain.tld", "dhcp-ddns" : { "enable-updates": true }, "subnet4": [ { "id": 1001, // Each subnet requires a unique numeric id "subnet": "192.168.56.0/24", "pools": [ { "pool": "192.168.56.16 - 192.168.56.254" } ], "option-data": [ { "name": "domain-name", "data": "your.domain.tld" }, { "name": "domain-name-servers", "data": "192.168.56.2, 192.168.3.7" }, { "name": "domain-search", "data": "your.domain.tld" }, { "name": "routers", "data": "192.168.56.2" } ] } ], "loggers": [ { "name": "kea-dhcp4", "output_options": [ { "output": "/var/log/kea/kea-dhcp4.log", "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p %m\\n" } ], "severity": "INFO", "debuglevel": 0 } ] } } // End /etc/kea/kea-dhcp4.conf EOF EOIS echo "/sbin/ldconfig" >> ulfs_install.sh USER=`whoami` if [ "$USER" == "root" ] ; then cat ulfs_install.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/kea/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/kea/finish.time #Checking package directory size after unpack... cd /sources du -s kea-3.0.1 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/kea/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/kea/files.txt ]; then rm /var/log/ulfs-packages/kea/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /sbin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /usr -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /etc -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/kea/files.txt find /opt -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /lib -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /var -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path "/var/log/ulfs-packages/kea/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/kea/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/kea/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path "/var/log/ulfs-packages/kea/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/kea/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/kea else sudo touch /var/cache/ulfs-packages/kea fi #Calculate delta size a=`cat /var/log/ulfs-packages/kea/unpack.size` b=`cat /var/log/ulfs-packages/kea/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/kea/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/kea/start.time` b=`cat /var/log/ulfs-packages/kea/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/kea/download.time` b=`cat /var/log/ulfs-packages/kea/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/kea/configure.time` b=`cat /var/log/ulfs-packages/kea/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/kea/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: kea" echo "Release: 0.2.4" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script