#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.3 # Package: hostapd #=========================== # DB commit: 34a83c7a68a930f721bd7a7f9cb2c2ac41e76ba8 # APP commit: 0bd167a48557b5a14ac68d0229893245aacc7f12 #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: hostapd" echo "Release: 0.3" 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/hostapd/ #Saving start timestamp date +%s > /var/log/ulfs-packages/hostapd/start.time #Going to source directory... cd /sources #Checking dependances... #Checking !sqlite... if [ ! -f /var/cache/ulfs-packages/!sqlite ]; then echo "Dependance \"!sqlite\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.3/!sqlite/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.3/!sqlite/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/!sqlite ]; then echo "Dependance \"!sqlite\" is not installed. Exiting..." exit fi fi #Checking libnl... if [ ! -f /var/cache/ulfs-packages/libnl ]; then echo "Dependance \"libnl\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.3/libnl/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.3/libnl/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/libnl ]; then echo "Dependance \"libnl\" is not installed. Exiting..." exit fi fi #Checking linux-firmware... if [ ! -f /var/cache/ulfs-packages/linux-firmware ]; then echo "Dependance \"linux-firmware\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.3/linux-firmware/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.3/linux-firmware/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/linux-firmware ]; then echo "Dependance \"linux-firmware\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/hostapd/download.time #Downloading source package archive... downloadFile .md5sum downloadFile #Checking source package file existance if [ ! -f hostapd-2.11.tar.gz ]; then echo "Error: Can't find hostapd-2.11.tar.gz. Exiting!" exit fi #Checking source package file checksum if [ -f hostapd-2.11.tar.gz.md5sum ]; then MD5=`LANG=C md5sum -c hostapd-2.11.tar.gz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of hostapd-2.11.tar.gz is wrong. Exiting!" exit fi fi #Downloadning patches... downloadFile https://umvirt.com/linux/downloads/0.3/patches/hostapd-2.11-fhs-config.patch #Checking patch file existance if [ ! -f hostapd-2.11-fhs-config.patch ]; then echo -e "Error: Can't find patch \"hostapd-2.11-fhs-config.patch\". Exiting!" exit fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/hostapd/cleanup.time rm -rfv /sources/hostapd-2.11/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/hostapd/unpack.time #Extracting tar source package archive with default parameters... tar -xf hostapd-2.11.tar.gz #Checking package directory size after unpack... du -s hostapd-2.11 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/hostapd/unpack.size #Going to source package directory... cd hostapd-2.11 #Applying patches... patch -Np1 -i ../hostapd-2.11-fhs-config.patch #Saving configuration timestamp date +%s > /var/log/ulfs-packages/hostapd/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/hostapd-2.11 \! -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 cd hostapd cp defconfig .config EOIS cat ulfs_configure.sh | bash 2>&1 | tee /var/log/ulfs-packages/hostapd/configure.log #Saving build timestamp date +%s > /var/log/ulfs-packages/hostapd/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 hostapd make EOIS cat ulfs_build.sh | bash 2>&1 | tee /var/log/ulfs-packages/hostapd/build.log #Saving install timestamp date +%s > /var/log/ulfs-packages/hostapd/install.time #Running install script... cat > ulfs_install.sh << EOIS cd hostapd make install BINDIR=/usr/bin install -vDm 640 hostapd.{accept,conf,deny,eap_user,radius_clients,vlan,wpa_psk} -t "/etc/hostapd/" install -vDm 640 hostapd.{accept,conf,deny,eap_user,radius_clients,vlan,wpa_psk} -t "/usr/share/factory/etc/hostapd/" install -vDm 644 hostapd.8 -t "/usr/share/man/man8/" install -vDm 644 hostapd_cli.1 -t "/usr/share/man/man1/" cat > /usr/lib/systemd/system/hostapd.service << "EOF" [Unit] Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator After=network.target [Service] ExecStart=/usr/bin/hostapd /etc/hostapd/hostapd.conf ExecReload=/bin/kill -HUP \$MAINPID [Install] WantedBy=multi-user.target EOF cat > /usr/lib/systemd/system/hostapd@.service << "EOF" [Unit] Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator After=network.target [Service] ExecStart=/usr/bin/hostapd /etc/hostapd/%i.conf ExecReload=/bin/kill -HUP \$MAINPID [Install] WantedBy=multi-user.target EOF cat > /usr/lib/tmpfiles.d/hostapd.tmpfiles << "EOF" # create configuration files and directories from factory defaults if they do not exist C /etc/hostapd - - - - /usr/share/factory/etc/hostapd # create state dir d /var/lib/hostapd 750 root root - 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/hostapd/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/hostapd/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/hostapd/finish.time #Checking package directory size after unpack... cd /sources du -s hostapd-2.11 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/hostapd/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/hostapd/files.txt ]; then rm /var/log/ulfs-packages/hostapd/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /sbin -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /usr -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /etc -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/hostapd/files.txt find /opt -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /lib -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt find /var -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time \! -path "/var/log/ulfs-packages/hostapd/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/hostapd/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/hostapd/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time >> /var/log/ulfs-packages/hostapd/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/hostapd/configure.time \! -newer /var/log/ulfs-packages/hostapd/finish.time \! -path "/var/log/ulfs-packages/hostapd/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/hostapd/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/hostapd else sudo touch /var/cache/ulfs-packages/hostapd fi #Calculate delta size a=`cat /var/log/ulfs-packages/hostapd/unpack.size` b=`cat /var/log/ulfs-packages/hostapd/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/hostapd/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/hostapd/start.time` b=`cat /var/log/ulfs-packages/hostapd/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/hostapd/download.time` b=`cat /var/log/ulfs-packages/hostapd/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/hostapd/configure.time` b=`cat /var/log/ulfs-packages/hostapd/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/hostapd/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: hostapd" echo "Release: 0.3" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script