melpa/scripts/build

63 lines
1.6 KiB
Text
Raw Normal View History

2013-01-07 16:22:58 +00:00
#!/bin/bash
function timestamp {
date "+%Y%m%d %H:%M %Z"
}
2013-01-07 16:22:58 +00:00
function melpa {
timestamp
2013-01-07 16:22:58 +00:00
timestamp > $HOME/www/status.txt
2013-01-07 16:22:58 +00:00
echo "building..." >> $HOME/www/status.txt
MELPADIR=${MELPADIR:-$HOME/melpa}
MELPABRANCH=${MELPABRANCH:-master}
WEBROOT=${WEBROOT:-$HOME/www}
PATH=$HOME/.cabal/bin:$HOME/usr/bin:$HOME/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
ENVLOG=$HOME/log/melpaenv.log
env > ${ENVLOG}
STDOUT=`mktemp`
STDERR=`mktemp`
## git pull
cd ${MELPADIR}
git pull origin ${MELPABRANCH} &>> ${STDOUT}
echo >> ${STDOUT}
MELPASTDOUT=`mktemp`
## run the script
cd ${MELPADIR}
make 1>> ${MELPASTDOUT} 2>> ${STDERR}
## sync to the web directory
rsync -avz --delete ${MELPADIR}/packages ${MELPADIR}/html/* ${WEBROOT}/ 1>> ${STDOUT} 2>> ${STDERR}
2013-01-07 16:22:58 +00:00
chmod -R go+r ${WEBROOT}/packages/*
chmod -R go-x ${WEBROOT}/packages/*
/usr/sbin/logrotate -s $HOME/log/logrotate.state $HOME/log/melpa.logrotate 1>> ${STDOUT} 2>> ${STDERR}
EMAIL=`mktemp`
echo "Subject: Melpa status `timestamp`" > ${EMAIL}
2013-01-07 16:22:58 +00:00
cat ${MELPASTDOUT} ${STDOUT} ${ENVLOG} ${STDERR} >> ${EMAIL}
/usr/sbin/sendmail dcurtis@milkbox.net < ${EMAIL}
cat ${ENVLOG} ${STDERR} ${STDOUT} | tee $WEBROOT/lastrun.txt
timestamp > $HOME/www/status.txt
2013-01-07 16:22:58 +00:00
echo "completed" >> $HOME/www/status.txt
}
if [[ `cat $HOME/www/updatemelpa.txt` == 1 ]] ; then
2013-03-15 13:58:31 +00:00
echo "Running MELPA"
echo "2" > $HOME/www/updatemelpa.txt
melpa
echo "0" > $HOME/www/updatemelpa.txt
2013-01-07 16:22:58 +00:00
fi