Advertisement
Guest User

flisolbr.sh

a guest
Feb 12th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.47 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Baseado no HInventory script for Linux
  4. #Thomas BRETON
  5. #Contribution Julien SAFAR, David DU SERRE TELMON, Kotty, Raphux, Mark, Alexander, Andraž
  6. #Copyright (C) 2005  Thomas BRETON
  7.  
  8. #This program is free software; you can redistribute it and/or
  9. #modify it under the terms of the GNU General Public License
  10. #as published by the Free Software Foundation; either version 2
  11. #of the License, or (at your option) any later version.
  12.  
  13. #This program is distributed in the hope that it will be useful,
  14. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #GNU General Public License for more details.
  17.  
  18. #You should have received a copy of the GNU General Public License
  19. #along with this program; if not, write to the Free Software
  20. #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  21.  
  22. VERSION="0.0.1"
  23.  
  24. ##UNSET des langues
  25. unset LANG LC_ALL LC_MESSAGES
  26.  
  27. ##Global variables
  28. HOSTNAME="`hostname -f`"
  29. DATE="`date +%d/%m/%Y` `date +%H:%M:%S`"
  30.  
  31. ReportFile="$HOSTNAME-`date +%m-%d-%y-%H%M%s`.txt"
  32.  
  33. ##################################################################################
  34. # Check arguments
  35. ##################################################################################
  36. check_login () {
  37.   fail=0
  38.   # Check server
  39.   if [ -z "$server" ]; then
  40.     echo "  Server: Fail (empty)"
  41.     fail=1
  42.   fi
  43.   # Check login
  44.   if [ -z "$user" ]; then
  45.     echo "  Username: Fail (empty)"
  46.     fail=1
  47.   fi
  48.   # Check password
  49.   if [ -z "$password" ] && [ "$method" != scp ] ; then
  50.     echo "  Password: Fail (empty)"
  51.     fail=1
  52.   fi
  53.   # If failure
  54.   if [ $fail = 1 ]; then
  55.     echo "Error, on or more problem(s) has been found for method $method. Review your configuration."
  56.     exit 1
  57.   fi
  58.  }
  59.  
  60.  
  61.  
  62. ##################################################################################
  63. #Upload
  64. ##################################################################################
  65. upload () {
  66.     if [ "$use_ssl" ]  && [ -x /usr/bin/ftp-ssl ];
  67.         then ftp=ftp-ssl
  68.         else ftp=ftp
  69.     fi
  70.     if [ "$debug" = 1 ]; then echo "- Starting upload on $ftp://${user}@${server}/${remote_path}"; fi
  71.       $ftp -ipn $server $port << EOF
  72. user ${user} ${password}
  73. binary
  74. cd $remote_path
  75. put $ReportFile
  76. quit
  77. EOF
  78.     if [ $? = 0 ]; then
  79.       echo "  * Report succesfully uploaded on $server."
  80.     else
  81.       echo "  * Unable to upload report file on $server."
  82.     fi
  83.   }
  84.  
  85. ##################################################################################
  86. ##################################################################################
  87. # MAIN
  88. ##################################################################################
  89. ##################################################################################
  90. blnConfFile="false"
  91. if [ -f "`dirname $0`/flisolbr.conf" ]
  92.         then ConfFile=`dirname $0`/flisolbr.conf
  93.              blnConfFile="true"
  94.         fi
  95.  
  96. if [ $blnConfFile == false ]; then
  97.         echo "Fatal error, configuration file is missing."
  98.   exit 1
  99. else
  100.  
  101. # Checking conf
  102.   . $ConfFile
  103.  
  104.   if [ -z "$remote_path" ]; then
  105.     remote_path=.
  106.   fi
  107.  
  108. case $method in
  109.     ftp)
  110.       check_login
  111.       ;;
  112.     local)
  113.       ;;
  114.     *)
  115.        echo "Fatal error, method not supported, choose : ftp, http, local, smb, nfs or scp"
  116.        exit 1
  117.        ;;
  118.   esac
  119. fi
  120.  
  121. hardinfo -r -a -f text -m computer.so -m devices.so -m network.so >> $ReportFile
  122.  
  123. upload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement