Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Baseado no HInventory script for Linux
- #Thomas BRETON
- #Contribution Julien SAFAR, David DU SERRE TELMON, Kotty, Raphux, Mark, Alexander, Andraž
- #Copyright (C) 2005 Thomas BRETON
- #This program is free software; you can redistribute it and/or
- #modify it under the terms of the GNU General Public License
- #as published by the Free Software Foundation; either version 2
- #of the License, or (at your option) any later version.
- #This program is distributed in the hope that it will be useful,
- #but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- #GNU General Public License for more details.
- #You should have received a copy of the GNU General Public License
- #along with this program; if not, write to the Free Software
- #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- VERSION="0.0.1"
- ##UNSET des langues
- unset LANG LC_ALL LC_MESSAGES
- ##Global variables
- HOSTNAME="`hostname -f`"
- DATE="`date +%d/%m/%Y` `date +%H:%M:%S`"
- ReportFile="$HOSTNAME-`date +%m-%d-%y-%H%M%s`.txt"
- ##################################################################################
- # Check arguments
- ##################################################################################
- check_login () {
- fail=0
- # Check server
- if [ -z "$server" ]; then
- echo " Server: Fail (empty)"
- fail=1
- fi
- # Check login
- if [ -z "$user" ]; then
- echo " Username: Fail (empty)"
- fail=1
- fi
- # Check password
- if [ -z "$password" ] && [ "$method" != scp ] ; then
- echo " Password: Fail (empty)"
- fail=1
- fi
- # If failure
- if [ $fail = 1 ]; then
- echo "Error, on or more problem(s) has been found for method $method. Review your configuration."
- exit 1
- fi
- }
- ##################################################################################
- #Upload
- ##################################################################################
- upload () {
- if [ "$use_ssl" ] && [ -x /usr/bin/ftp-ssl ];
- then ftp=ftp-ssl
- else ftp=ftp
- fi
- if [ "$debug" = 1 ]; then echo "- Starting upload on $ftp://${user}@${server}/${remote_path}"; fi
- $ftp -ipn $server $port << EOF
- user ${user} ${password}
- binary
- cd $remote_path
- put $ReportFile
- quit
- EOF
- if [ $? = 0 ]; then
- echo " * Report succesfully uploaded on $server."
- else
- echo " * Unable to upload report file on $server."
- fi
- }
- ##################################################################################
- ##################################################################################
- # MAIN
- ##################################################################################
- ##################################################################################
- blnConfFile="false"
- if [ -f "`dirname $0`/flisolbr.conf" ]
- then ConfFile=`dirname $0`/flisolbr.conf
- blnConfFile="true"
- fi
- if [ $blnConfFile == false ]; then
- echo "Fatal error, configuration file is missing."
- exit 1
- else
- # Checking conf
- . $ConfFile
- if [ -z "$remote_path" ]; then
- remote_path=.
- fi
- case $method in
- ftp)
- check_login
- ;;
- local)
- ;;
- *)
- echo "Fatal error, method not supported, choose : ftp, http, local, smb, nfs or scp"
- exit 1
- ;;
- esac
- fi
- hardinfo -r -a -f text -m computer.so -m devices.so -m network.so >> $ReportFile
- upload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement