#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.2.3 # Package: net-snmp #=========================== # DB commit: 9479b41c328304e88d8b007b04bc0dff783bbc6e # APP commit: b0e7f121177a769c20a4c985867d650259b096ce #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: net-snmp" echo "Release: 0.2.3" 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/net-snmp/ #Saving start timestamp date +%s > /var/log/ulfs-packages/net-snmp/start.time #Going to source directory... cd /sources #Checking dependances... #Checking pcre2... if [ ! -f /var/cache/ulfs-packages/pcre2 ]; then echo "Dependance \"pcre2\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/pcre2/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/pcre2/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/pcre2 ]; then echo "Dependance \"pcre2\" is not installed. Exiting..." exit fi fi #Checking libpcap... if [ ! -f /var/cache/ulfs-packages/libpcap ]; then echo "Dependance \"libpcap\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/libpcap/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/libpcap/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/libpcap ]; then echo "Dependance \"libpcap\" is not installed. Exiting..." exit fi fi #Checking pciutils... if [ ! -f /var/cache/ulfs-packages/pciutils ]; then echo "Dependance \"pciutils\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/pciutils/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/pciutils/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/pciutils ]; then echo "Dependance \"pciutils\" is not installed. Exiting..." exit fi fi #Checking lm-sensors... if [ ! -f /var/cache/ulfs-packages/lm-sensors ]; then echo "Dependance \"lm-sensors\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/lm-sensors/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/lm-sensors/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/lm-sensors ]; then echo "Dependance \"lm-sensors\" is not installed. Exiting..." exit fi fi #Checking perl-TermReadKey... if [ ! -f /var/cache/ulfs-packages/perl-TermReadKey ]; then echo "Dependance \"perl-TermReadKey\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/perl-TermReadKey/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/perl-TermReadKey/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/perl-TermReadKey ]; then echo "Dependance \"perl-TermReadKey\" is not installed. Exiting..." exit fi fi #Checking perl-Tk... if [ ! -f /var/cache/ulfs-packages/perl-Tk ]; then echo "Dependance \"perl-Tk\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/perl-Tk/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/perl-Tk/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/perl-Tk ]; then echo "Dependance \"perl-Tk\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/net-snmp/download.time #Downloading source package archive... downloadFile https://umvirt.com/linux/downloads/0.2.3/packages/n/net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2.md5sum downloadFile https://umvirt.com/linux/downloads/0.2.3/packages/n/net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2 #Checking source package file existance if [ ! -f net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2 ]; then echo "Error: Can't find net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2. Exiting!" exit fi #Checking source package file checksum if [ -f net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2.md5sum ]; then MD5=`LANG=C md5sum -c net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2 is wrong. Exiting!" exit fi fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/net-snmp/cleanup.time rm -rfv /sources/net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/net-snmp/unpack.time #Extracting tar source package archive with default parameters... tar -xf net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports.tar.bz2 #Checking package directory size after unpack... du -s net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/net-snmp/unpack.size #Going to source package directory... cd net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports #Saving configuration timestamp date +%s > /var/log/ulfs-packages/net-snmp/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/net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports \! -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 autoreconf -i ./configure \\ --prefix='/usr' \\ --sysconfdir='/etc' \\ --sbindir='/usr/bin' \\ --mandir='/usr/share/man' \\ --enable-blumenthal-aes \\ --enable-ipv6 \\ --enable-ucd-snmp-compatibility \\ --with-python-modules \\ --with-default-snmp-version='3' \\ --with-sys-contact='root@localhost' \\ --with-sys-location='Unknown' \\ --with-logfile='/var/log/snmpd.log' \\ --with-mib-modules='host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib' \\ --with-persistent-directory='/var/net-snmp' EOIS cat ulfs_configure.sh | bash 2>&1 | tee /var/log/ulfs-packages/net-snmp/configure.log #Saving build timestamp date +%s > /var/log/ulfs-packages/net-snmp/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 make NETSNMP_DONT_CHECK_VERSION=1 EOIS cat ulfs_build.sh | bash 2>&1 | tee /var/log/ulfs-packages/net-snmp/build.log #Saving install timestamp date +%s > /var/log/ulfs-packages/net-snmp/install.time #Running install script... cat > ulfs_install.sh << EOIS make INSTALLDIRS=vendor install install -D -m644 snmpd.service" /usr/lib/systemd/system/snmpd.service install -D -m644 snmptrapd.service" /usr/lib/systemd/system/snmptrapd.service 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/net-snmp/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/net-snmp/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/net-snmp/finish.time #Checking package directory size after unpack... cd /sources du -s net-snmp-7d38b8299e26708ee92c9fe1628e5a000bc23e17-backports | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/net-snmp/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/net-snmp/files.txt ]; then rm /var/log/ulfs-packages/net-snmp/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /sbin -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /usr -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /etc -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/net-snmp/files.txt find /opt -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /lib -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt find /var -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time \! -path "/var/log/ulfs-packages/net-snmp/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/net-snmp/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time >> /var/log/ulfs-packages/net-snmp/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/net-snmp/configure.time \! -newer /var/log/ulfs-packages/net-snmp/finish.time \! -path "/var/log/ulfs-packages/net-snmp/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/net-snmp/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/net-snmp else sudo touch /var/cache/ulfs-packages/net-snmp fi #Calculate delta size a=`cat /var/log/ulfs-packages/net-snmp/unpack.size` b=`cat /var/log/ulfs-packages/net-snmp/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/net-snmp/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/net-snmp/start.time` b=`cat /var/log/ulfs-packages/net-snmp/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/net-snmp/download.time` b=`cat /var/log/ulfs-packages/net-snmp/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/net-snmp/configure.time` b=`cat /var/log/ulfs-packages/net-snmp/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/net-snmp/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: net-snmp" echo "Release: 0.2.3" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script