1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/bin/sh
set -e
# Branch name (first args)
BRANCH=$1
# Release name (second args)
RELEASE_NAME=$2
# URL to the ocs server git repository
SRV_REPO=https://github.com/OCSInventory-NG/OCSInventory-Server.git
# URL to the ocs reports git repository
WEB_REPO=https://github.com/OCSInventory-NG/OCSInventory-OCSReports.git
# Composer path
COMPOSER_PATH=/usr/bin/composer
# If no branch is supplied exit
if [ -z $BRANCH ]; then
echo "Please set a source branch (first argument)"
exit 1
fi
if [ -z $RELEASE_NAME ]; then
echo "Please set a release name (second argument)"
exit 1
fi
echo "$COMPOSER_PATH"
# Check if composer bin is available, otherwise exit and display an error
if [ ! -f $COMPOSER_PATH ]; then
echo "Error retreving composer executable. Please verify if composer is intalled or the COMPOSER_PATH configuration at the begining of the file (Currently used COMPOSER_PATH = $COMPOSER_PATH)"
exit 1
fi
# Clone server repository and remove git related files
git clone $SRV_REPO -b $BRANCH
rm -rf OCSInventory-Server/.git
rm -rf OCSInventory-Server/.github
rm -rf OCSInventory-Server/.gitignore
# Clone reports repository and remove git related files
cd OCSInventory-Server && git clone $WEB_REPO -b $BRANCH ocsreports
rm -rf ocsreports/.git
rm -rf ocsreports/.github
rm -rf ocsreports/.gitignore
# Reset the default settings so install.php will be correctly loaded
rm ocsreports/dbconfig.inc.php
cd ocsreports/
# Run composer on ocsreports
$COMPOSER_PATH install
# Go back to the base path
cd ../..
# Change name to comply with OCS' naming convention
mv OCSInventory-Server OCSNG_UNIX_SERVER-$RELEASE_NAME
tar cfz OCSNG_UNIX_SERVER-$RELEASE_NAME.tar.gz OCSNG_UNIX_SERVER-$RELEASE_NAME
rm -rf OCSNG_UNIX_SERVER-$RELEASE_NAME
# Release created !
echo "Release has been successfully created"
|