Skip to content

Instantly share code, notes, and snippets.

@gbersac
Created November 18, 2016 13:52
Show Gist options
  • Save gbersac/ca49a109070bedb4023ee1cccca9fd7b to your computer and use it in GitHub Desktop.
Save gbersac/ca49a109070bedb4023ee1cccca9fd7b to your computer and use it in GitHub Desktop.
Creation d'un fichier rpm et installation dans un host distant
#! /bin/sh
# You have to be at the root of the package of the project from which you
# want to install the rpm
projectName=api_intranet
projectNameLong=intranet-parcel-defect-process
target="ftops-recette-apiserverintranet-a-01.archinext.local"
# Create rpm
cat version.sbt | tr - _ > temp && mv temp version.sbt
sbt "project $projectName" "rpm:packageBin"
cat version.sbt | tr _ - > temp && mv temp version.sbt
# Copy file to distant host
cd $projectName/target/rpm/RPMS/noarch/
fileName=`ls | grep $projectNameLong`
echo "Transfer of file: $fileName"
scp $fileName ansible@$target:/tmp
cd -
# Install on distant host
ssh -tt ansible@$target 'sudo yum -y remove `yum list installed | grep $projectNameLong`'
ssh -tt ansible@$target "sudo yum -y install /tmp/$fileName"
ssh -tt ansible@$target "sudo /etc/init.d/$projectNameLong restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment