"Fossies" - the Fresh Open Source Software Archive

Member "unix/DEBIAN/make_deb_package.sh" (15 Sep 2021, 4421 Bytes) of package /linux/misc/pandorafms_agent_unix-7.0NG.757.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "make_deb_package.sh": 7.0NG.756_vs_7.0NG.757.

    1 #!/bin/bash
    2 
    3 #Pandora FMS- http:#pandorafms.com
    4 # ==================================================
    5 # Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
    6 # Please see http:#pandorafms.org for full contribution list
    7 
    8 # This program is free software; you can redistribute it and/or
    9 # modify it under the terms of the  GNU Lesser General Public License
   10 # as published by the Free Software Foundation; version 2
   11 
   12 # This program is distributed in the hope that it will be useful,
   13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 # GNU General Public License for more details.
   16 
   17 pandora_version="7.0NG.757-210915"
   18 
   19 echo "Test if you has the tools for to make the packages."
   20 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
   21 if [ $? = 1 ]
   22 then
   23     if [ "$DPKG_DEB" == "" ]; then
   24         echo "No found \"dpkg-deb\" aplication, please install."
   25         exit 1
   26     fi
   27 
   28     echo ">> Using dockerized version of dpkg-deb: "
   29     echo "  $DPKG_DEB"
   30     USE_DOCKER_APP=1
   31 else
   32     echo "Found \"dpkg-debs\"."
   33 fi
   34 
   35 cd ..
   36 
   37 echo "Make a \"temp_package\" temp dir for job."
   38 
   39 mkdir -p temp_package/usr
   40 mkdir -p temp_package/usr/share/pandora_agent/
   41 mkdir -p temp_package/usr/bin/
   42 mkdir -p temp_package/usr/sbin/
   43 mkdir -p temp_package/etc/pandora/plugins
   44 mkdir -p temp_package/etc/pandora/collections
   45 mkdir -p temp_package/etc/pandora/trans
   46 mkdir -p temp_package/etc/pandora/commands
   47 mkdir -p temp_package/etc/init.d/
   48 mkdir -p temp_package/lib/systemd/system/
   49 mkdir -p temp_package/var/log/pandora/
   50 mkdir -p temp_package/var/spool/pandora/data_out
   51 mkdir -p temp_package/usr/share/man/man1/
   52 mkdir -p temp_package/usr/share/pandora_agent/plugins
   53 mkdir -p temp_package/tmp
   54 mkdir -p temp_package/etc/logrotate.d/
   55 
   56 echo "Make directory system tree for package."
   57 cp DEBIAN temp_package -R
   58 chmod 755 -R temp_package/DEBIAN
   59 
   60 #Next lines is same to
   61 #cp -aRf * temp_package/usr/share/pandora_agent/
   62 #but don't copy recursive the temp_package into temp_package
   63 
   64 for item in `ls | grep -v NT4 | grep -v AIX | grep -v FreeBSD | grep -v HP-UX | grep -v SunOS | grep -v temp_package`
   65 do
   66     #if  [ \( $item != 'temp_package' \) -a \( $item != 'NT4' \) ]
   67     #then
   68         cp -aRf $item temp_package/usr/share/pandora_agent/
   69     #fi
   70 done
   71 cp -aRf tentacle_client temp_package/usr/bin/
   72 cp -aRf pandora_agent temp_package/usr/bin/
   73 cp -aRf pandora_agent_exec temp_package/usr/bin/pandora_agent_exec
   74 cp -aRf pandora_agent_daemon temp_package/etc/init.d/pandora_agent_daemon
   75 cp -aRf pandora_agent_daemon.service temp_package/lib/systemd/system/pandora_agent_daemon.service
   76 cp -aRf pandora_agent_logrotate temp_package/etc/logrotate.d/pandora_agent
   77 cp Linux/pandora_agent.conf temp_package/etc/pandora/
   78 
   79 cp -aRf man/man1/* temp_package/usr/share/man/man1/
   80 
   81 # Relocate plugins to the final dir and delete 
   82 cp temp_package/usr/share/pandora_agent/plugins/* temp_package/etc/pandora/plugins
   83 
   84 # Make sure the plugins have execution privileges
   85 chmod 755 temp_package/etc/pandora/plugins/*
   86 
   87 echo "Official plugins are placed on /etc/pandora/plugins" > temp_package/usr/share/pandora_agent/plugins/README
   88 
   89 #Disabled, now the package overwrite the previous files.
   90 ##Create a temp file for to update files of plugins dir but don't crush dir.
   91 ##cp -aRf temp_package/usr/share/pandora_agent/plugins temp_package/tmp
   92 ##rm -rf temp_package/usr/share/pandora_agent/plugins/*
   93 
   94 echo "Remove the SVN files and other temp files."
   95 for item in `find temp_package`
   96 do
   97     echo -n "."
   98     echo $item | grep "svn" > /dev/null
   99     #last command success
  100     if [ $? -eq 0 ]
  101     then
  102         rm -rf $item
  103     fi
  104     
  105     echo $item | grep "make_deb_package.sh" > /dev/null
  106     #last command success
  107     if [ $? -eq 0 ]
  108     then
  109         rm -rf $item
  110     fi
  111 done
  112 echo "END"
  113 
  114 echo "Calcule md5sum for md5sums file control of package"
  115 for item in `find temp_package`
  116 do
  117     echo -n "."
  118     if [ ! -d $item ]
  119     then
  120         echo $item | grep "DEBIAN" > /dev/null
  121         #last command success
  122         if [ $? -eq 1 ]
  123         then
  124             md5=`md5sum $item | cut -d" " -f1`
  125             
  126             #delete "temp_package" in the path
  127             final_path=${item#temp_package}
  128             echo $md5" "$final_path >> temp_package/DEBIAN/md5sums
  129         fi
  130     fi
  131 done
  132 echo "END"
  133 
  134 echo "Make the package \"Pandorafms agent\"."
  135 if [ "$USE_DOCKER_APP" == "1" ]; then 
  136     eval $DPKG_DEB --build temp_package
  137 else
  138     dpkg-deb --build temp_package
  139 fi
  140 mv temp_package.deb pandorafms.agent_unix_$pandora_version.deb
  141 
  142 echo "Delete the \"temp_package\" temp dir for job."
  143 rm -rf temp_package