This repository has been archived by the owner on Sep 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_repository
executable file
·57 lines (50 loc) · 2.47 KB
/
load_repository
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
#!/bin/bash
#set -x
PROJECT=`grep defproject project.clj | awk '{print $2}'`
v=`grep defproject project.clj | awk '{print $3}'`
VERSION=${v//\"/}
DOMAIN="com.rentpath"
DOMAIN_PATH=${DOMAIN//./\/}
CMD="install_${PROJECT}.sh"
ARTIFACT="${PROJECT}-${VERSION}.jar"
ARTIFACT_STANDALONE="${PROJECT}-${VERSION}-standalone.jar"
ARTIFACT_PATH="`pwd`/target"
REMOTE_HOST="ec2-54-224-24-95.compute-1.amazonaws.com"
if [[ ("$1" == "-h") || ("$1" == "--help") || ($1 == "") ]]
then
echo ""
echo "Load $ARTIFACT into a local or remote Maven repository."
echo ""
echo "Usage: load_repository <options>"
echo ""
echo "Options:"
echo ""
echo " -l, --local # Load $ARTIFACT and $ARTIFACT_STANDALONE files into local Maven repository ~/m2/repository/$DOMAIN_PATH/$ARTIFACT"
echo " -r, --remote # Load $ARTIFACT and $ARTIFACT_STANDALONE files into the remote repository on $REMOTE_HOST:/public/maven/.m2/$DOMAIN_PATH/$PROJECT/$ARTIFACT"
echo ""
exit 0
fi
lein uberjar
if [[ ("$1" == "-l") || ("$1" = "--local") ]]
then
echo "Installing $ARTIFACT into local Maven repository ..."
mvn install:install-file -DgroupId=$DOMAIN -DartifactId=$PROJECT -Dversion=$VERSION -Dpackaging=jar -Dfile=$ARTIFACT_PATH/$ARTIFACT -DgeneratePom=true -DcreateChecksum=true
mvn install:install-file -DgroupId=$DOMAIN -DartifactId=$PROJECT -Dversion=$VERSION -Dpackaging=jar -Dfile=$ARTIFACT_PATH/$ARTIFACT_STANDALONE -DgeneratePom=true -DcreateChecksum=true
fi
if [[ ($1 == "-r") || ($1 == "--remote") ]]
then
echo "Installing $ARTIFACT into remote Maven repository ..."
tee << EOF > $CMD
mvn install:install-file -DgroupId=$DOMAIN -DartifactId=$PROJECT -Dversion=$VERSION -Dpackaging=jar -Dfile=$ARTIFACT -DgeneratePom=true -DcreateChecksum=true
mvn install:install-file -DgroupId=$DOMAIN -DartifactId=$PROJECT -Dversion=$VERSION -Dpackaging=jar -Dfile=$ARTIFACT_STANDALONE -DgeneratePom=true -DcreateChecksum=true
EOF
cat $CMD
scp -p $CMD $REMOTE_HOST:/public/maven
ssh ${REMOTE_HOST} "chmod 775 /public/maven/$CMD ; chgrp wheel /public/maven/$CMD"
scp $ARTIFACT_PATH/$ARTIFACT $REMOTE_HOST:/public/maven/
scp $ARTIFACT_PATH/$ARTIFACT_STANDALONE $REMOTE_HOST:/public/maven/
ssh ${REMOTE_HOST} "chmod 775 /public/maven/$ARTIFACT ; chgrp wheel /public/maven/$ARTIFACT"
ssh ${REMOTE_HOST} "chmod 775 /public/maven/$ARTIFACT_STANDALONE ; chgrp wheel /public/maven/$ARTIFACT_STANDALONE"
ssh $REMOTE_HOST "cd /public/maven ; ./$CMD ; rm $ARTIFACT $ARTIFACT_STANDALONE $CMD"
rm $CMD
fi