Created
June 30, 2012 03:27
-
-
Save kisom/3022035 to your computer and use it in GitHub Desktop.
Simple deployments for clojure projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# simple deploy script for Clojure projects. | |
# very rough | |
echo "[+] generating standalone jar." | |
lein uberjar | |
target="[email protected]" | |
jarfile="$(ls -1 *standalone*)" | |
timestamp=$(date +'%s') | |
deploy_dir=$(basename $(pwd)) | |
echo "[+] deploying $jarfile to $target..." | |
echo "[+] building tarball..." | |
mkdir $deploy_dir | |
cp *standalone*.jar $deploy_dir | |
cp environ.sh $deploy_dir | |
printf "#!/bin/sh\n\n. ./environ.sh\njava -jar $jarfile $*\n" > \ | |
$deploy_dir/run.sh | |
chmod +x $deploy_dir/run.sh | |
tar czvf $deploy_dir-deploy-$timestamp.tgz $deploy_dir | |
if [ ! -e $deploy_dir-deploy-$timestamp.tgz ]; then | |
echo "[!] failed to create tarball" | |
exit 1 | |
fi | |
echo "[+] tarball $deploy_dir-deploy-$timestamp.tgz created..." | |
echo "[+] pushing to $target" | |
scp $deploy_dir-deploy-$timestamp.tgz $target:deploy/ | |
echo "[+] unpacking on $target" | |
ssh $target "cd deploy && tar xzf $deploy_dir-deploy-$timestamp.tgz " | |
ssh $target "rm deploy/$deploy_dir-deploy-$timestamp.tgz" | |
echo "[+] target unpacked to $target:deploy/$deploy_dir/" | |
echo "[+] cleaning up..." | |
rm -r $deploy_dir | |
rm -r $deploy_dir-deploy-$timestamp.tgz | |
lein clean | |
echo "[+] complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment