Last active
January 3, 2016 01:49
-
-
Save kbanman/8392002 to your computer and use it in GitHub Desktop.
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/bash | |
LOGFILE=/tmp/app-init.log | |
BINPATH=/usr/bin | |
GMPATH=/usr/local/bin/gm | |
WKHTMLPATH="$BINPATH/wkhtmltopdf" | |
function log { | |
echo "[$(date "+%Y-%m-%d %T")] $1" >> $LOGFILE | |
} | |
function npm_fix { | |
FILE="/etc/hook-modified" | |
if [ ! -f "$FILE" ] ; then | |
log "- Performing fix" | |
sed -i 's/function error_exit/export HOME=\/root\n\nfunction error_exit/' /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh | |
touch $FILE | |
fi | |
} | |
function install_gm { | |
stat $GMPATH && log "- Already installed" && return 1 | |
cd /tmp | |
VERSION="1.3.19" | |
NAME="GraphicsMagick-$VERSION" | |
ARCHIVE="$NAME.tar.gz" | |
DOWNLOAD="wget http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/$VERSION/$ARCHIVE" | |
log "- $DOWNLOAD" | |
$DOWNLOAD | |
EXTRACT="tar -xzvf $ARCHIVE" | |
log "- $EXTRACT" | |
$EXTRACT | |
cd $NAME \ | |
&& ./configure && log "- Configured" \ | |
&& make && log "- Built" \ | |
&& make install && log "- Installed" \ | |
|| log "- Something failed" & return 0 | |
} | |
function install_wkhtmltopdf { | |
stat $WKHTMLPATH && log "- Already installed" && return 1 | |
cd /tmp | |
ARCHIVE="wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz" | |
DOWNLOAD="wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.0/$ARCHIVE" | |
log "- $DOWNLOAD" | |
$DOWNLOAD | |
EXTRACT="tar -xvf $ARCHIVE" | |
log "- $EXTRACT" | |
$EXTRACT | |
cd wkhtmltox/bin \ | |
&& cp `pwd`/wkhtmltopdf $WKHTMLPATH \ | |
|| log "- Something failed" & return 0 | |
} | |
log "Starting deploy commands" | |
log "Fixing npm install" | |
npm_fix | |
log "Installing GraphicsMagick" | |
install_gm | |
log "Installing wkhtmltopdf" | |
install_wkhtmltopdf | |
log "Finished deploy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment