1 (edited by tabad 2011-09-17 07:52:17)

Topic: A Bash script to synchronize with Git repositories...

Hello to all,

   This afternoon, when I was changing impressions with David Durieux (ddurieux) and Gonéri le Bouder (goneri), we have found that the Nightly Builds System was broken; it wasn't synchronized with Git repositories. At the moment (2011-09-17 00:00h), the Nightly Builds System is not fixed.

   I have written this bash script to make something like Nightly Builds System do, but when you want.

   This script creates a file with name 'fusionInventory-for-GLPI-snapshot-0.80-YYYYMMDD-HHMM.tar.gz' with last changes in Git repository. Make sure you have Git installed in your system.

   The bash script:

   

#!/bin/bash

declare -r date=$(type -P date)
declare -r git=$(type -P git)
declare -r mkdir=$(type -P mkdir)
declare -r rm=$(type -P rm)
declare -r tar=$(type -P tar)

declare -r FusionInventoryBranch=2.4.0
declare -r FusionInventoryPrefix=fusionInventory-for-GLPI-snapshot-0.80
declare -r FusionInventoryPath=${FusionInventoryPrefix}-$(${date} --utc +%Y%m%d-%H%M)

${mkdir} ./${FusionInventoryPath}
cd ./${FusionInventoryPath}

${git} clone http://github.com/fusinv/fusioninventory-for-glpi.git fusioninventory
cd fusioninventory
${git} checkout ${FusionInventoryBranch}
cd ..

${git} clone http://github.com/fusinv/fusioninventor … entory.git fusinvinventory
cd fusinvinventory
${git} checkout ${FusionInventoryBranch}
cd ..

${git} clone http://github.com/fusinv/fusioninventor … nvsnmp.git fusinvsnmp
cd fusinvsnmp
${git} checkout ${FusionInventoryBranch}
cd ..

cd ..

${rm} -rf ./${FusionInventoryPath}/fusioninventory/.git
${rm} -rf ./${FusionInventoryPath}/fusinvinventory/.git
${rm} -rf ./${FusionInventoryPath}/fusinvsnmp/.git
${tar} -czf ./${FusionInventoryPath}.tar.gz ./${FusionInventoryPath}
${rm} -rf ./${FusionInventoryPath}

Tomás Abad

2 (edited by tabad 2011-12-08 01:47:13)

Re: A Bash script to synchronize with Git repositories...

Hello to all,

   With the recent changes in the Git repositories of FusionInventory Project (see https://github.com/fusinv) the previous script don't work.

   Now, the public repository 'fusioninventory-for-glpi' (see https://github.com/fusinv/fusioninventory-for-glpi) contains all the previous plugins ('fusinvinventory', 'fusinvsnmp' and 'fusioninventory') in addition to a new plugin, 'fusinvdeploy'.

   With this new script you can replace the old nightly build system and get a file 'fusioninventory-for-glpi-snapshot-0.80-YYYYMMDD-HHMM.tar.gz' with the last changes of the 'glpi0.80' branch of the 'fusioninventory-for-glpi' public repository.

   This is the script.

#!/bin/bash
#
#
# Sociedad Imaginaria, S.I.
# Copyright (c) Dic 2011, SI
#
# Node Name:     cicere.sociedad.imaginaria.es
# Service Name: 
# File Name:     fusioninventory-for-glpi-snapshot-0.80
# Symbolic Link:
# OS Name:       Ubuntu Desktop 10.04.3 LTS (Lucid Lynx)
#
# Author(s):     Tomas Abad <tabad@sescam.jccm.es>
#
#

#
#
# Purpose:
#       Build a file 'fusioninventory-for-glpi-snapshot-0.80-YYYYMMDD-HHMM.tar.gz'
#    with the last changes of the 'glpi0.80' branch of the 'fusioninventory-for-glpi'
#    public repository.
#
#

declare -r date=$(type -P date)
declare -r git=$(type -P git)
declare -r mkdir=$(type -P mkdir)
declare -r rm=$(type -P rm)
declare -r sleep=$(type -P sleep)
declare -r tar=$(type -P tar)

declare -r FusionInventoryBranch=glpi0.80
declare -r FusionInventoryPrefix=${0##*/}
declare -r FusionInventoryPath=./${FusionInventoryPrefix}-$(${date} --utc +%Y%m%d-%H%M)

${git} clone http://github.com/fusinv/fusioninventory-for-glpi.git ${FusionInventoryPath}
cd ${FusionInventoryPath}
${git} checkout ${FusionInventoryBranch}
cd ..

${rm} -f ${FusionInventoryPath}/getWS.sh
${rm} -rf ${FusionInventoryPath}/.git*

${sleep} 2
${tar} -czf ${FusionInventoryPath}.tar.gz ${FusionInventoryPath}
${sleep} 2
${rm} -rf ${FusionInventoryPath}

   I hope that this will be useful to you.

Tomás Abad

Re: A Bash script to synchronize with Git repositories...

Hello to all,

   This is an improve (faster) version and compatible with Mac OS X.

#!/bin/bash
#
#
# Sociedad Imaginaria, S.I.
# Copyright (c) Dic 2011, SI
#
# Node Name:     cicere.sociedad.imaginaria.es
# Service Name:
# File Name:     fusioninventory-for-glpi-snapshot-0.80
# Symbolic Link:
# OS Name:       Ubuntu Desktop 10.04.3 LTS (Lucid Lynx)
#
# Author(s):     Tomas Abad <tabad@sescam.jccm.es>
#
#

#
#
# Purpose:
#       Build a file 'fusioninventory-for-glpi-snapshot-0.80-YYYYMMDD-HHMM.tar.gz'
#    with the last changes of the 'glpi0.80' branch of the 'fusioninventory-for-glpi'
#    public repository.
#
#

declare -r date=$(type -P date)
declare -r git=$(type -P git)
declare -r mkdir=$(type -P mkdir)
declare -r rm=$(type -P rm)
declare -r sleep=$(type -P sleep)
declare -r tar=$(type -P tar)

declare -r FusionInventoryBranch=glpi0.80
declare -r FusionInventoryPrefix=fusioninventory-for-glpi-snapshot-0.80
declare -r FusionInventoryPath=./${FusionInventoryPrefix}-$(${date} -u +%Y%m%d-%H%M)

${git} clone --branch ${FusionInventoryBranch} --depth 1 http://github.com/fusinv/fusioninventory-for-glpi.git ${FusionInventoryPath}

${rm} -f ${FusionInventoryPath}/getWS.sh
${rm} -rf ${FusionInventoryPath}/.git*

${sleep} 2
${tar} -czf ${FusionInventoryPath}.tar.gz ${FusionInventoryPath}
${sleep} 2
${rm} -rf ${FusionInventoryPath}

Tomás Abad

Re: A Bash script to synchronize with Git repositories...

Updated for FusionInventory for GLPI 0.83

#!/bin/bash
#
#
# Sociedad Imaginaria, S.I.
# Copyright (c) Aug 2012, SI
#
# Node Name:     cicere.sociedad.imaginaria.es
# Service Name:
# File Name:     fusioninventory-for-glpi-snapshot-0.83
# Symbolic Link:
# OS Name:       Ubuntu Desktop 10.04.4 LTS (Lucid Lynx)
#
# Author(s):     Tomas Abad <tabadgp@gmail.com>
#
#

#
#
# Purpose:
#       Build a file 'fusioninventory-for-glpi-snapshot-0.83-YYYYMMDD-HHMM.tar.gz'
#    with the last changes of the 'glpi0.83' branch of the 'fusioninventory-for-glpi'
#    public repository.
#
#


declare -r date=$(type -P date)
declare -r git=$(type -P git)
declare -r mkdir=$(type -P mkdir)
declare -r rm=$(type -P rm)
declare -r sleep=$(type -P sleep)
declare -r tar=$(type -P tar)

declare -r FusionInventoryBranch=glpi0.83
declare -r FusionInventoryPrefix=fusioninventory-for-glpi-snapshot-0.83
declare -r FusionInventoryPath=./${FusionInventoryPrefix}-$(${date} -u +%Y%m%d-%H%M)
declare -r FusionInventoryRepository=http://github.com/fusinv/fusioninventory-for-glpi.git

${git} clone --branch ${FusionInventoryBranch} --depth 1 ${FusionInventoryRepository} ${FusionInventoryPath}

${rm} -f ${FusionInventoryPath}/getWS.sh
${rm} -rf ${FusionInventoryPath}/.git*

${sleep} 2
${tar} -czf ${FusionInventoryPath}.tar.gz ${FusionInventoryPath}
${sleep} 2
${rm} -rf ${FusionInventoryPath}

Best regards.

Tomás Abad