2013-01-07 16:22:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-05-04 07:23:10 +00:00
|
|
|
export LANG=en_US.UTF-8
|
2013-08-24 16:11:37 +00:00
|
|
|
WEBROOT=${WEBROOT:-$HOME/www}
|
2013-05-04 07:23:10 +00:00
|
|
|
|
2013-04-17 11:47:12 +00:00
|
|
|
function timestamp {
|
2013-04-23 08:50:24 +00:00
|
|
|
date "+%Y%m%d %H:%M %z"
|
2013-04-17 11:47:12 +00:00
|
|
|
}
|
2013-08-24 10:06:45 +00:00
|
|
|
function unix_timestamp {
|
|
|
|
date "+%s"
|
|
|
|
}
|
2013-01-07 16:22:58 +00:00
|
|
|
|
2013-04-17 11:47:12 +00:00
|
|
|
function melpa {
|
|
|
|
timestamp
|
2013-01-07 16:22:58 +00:00
|
|
|
|
2013-08-24 16:11:37 +00:00
|
|
|
timestamp > $WEBROOT/status.txt
|
|
|
|
echo "building..." >> $WEBROOT/status.txt
|
2013-01-07 16:22:58 +00:00
|
|
|
|
|
|
|
MELPADIR=${MELPADIR:-$HOME/melpa}
|
|
|
|
MELPABRANCH=${MELPABRANCH:-master}
|
|
|
|
|
|
|
|
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
|
2013-08-24 16:16:05 +00:00
|
|
|
rsync -avz --delete ${MELPADIR}/packages ${MELPADIR}/html/. ${WEBROOT}/ 1>> ${STDOUT} 2>> ${STDERR}
|
2013-01-07 16:22:58 +00:00
|
|
|
|
2013-08-24 16:15:36 +00:00
|
|
|
chmod -R go+rx ${WEBROOT}/packages/*
|
2013-01-07 16:22:58 +00:00
|
|
|
|
|
|
|
/usr/sbin/logrotate -s $HOME/log/logrotate.state $HOME/log/melpa.logrotate 1>> ${STDOUT} 2>> ${STDERR}
|
|
|
|
|
|
|
|
EMAIL=`mktemp`
|
2013-04-17 11:47:12 +00:00
|
|
|
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
|
|
|
|
|
2013-08-24 16:11:37 +00:00
|
|
|
timestamp > $WEBROOT/status.txt
|
|
|
|
echo "completed" >> $WEBROOT/status.txt
|
|
|
|
echo '{"completed":' `unix_timestamp` '}' > $WEBROOT/build-status.json
|
2013-01-07 16:22:58 +00:00
|
|
|
}
|
|
|
|
|
2013-08-24 16:11:37 +00:00
|
|
|
if [[ `cat $WEBROOT/updatemelpa.txt` == 1 ]] ; then
|
2013-03-15 13:58:31 +00:00
|
|
|
echo "Running MELPA"
|
2013-08-24 16:11:37 +00:00
|
|
|
echo "2" > $WEBROOT/updatemelpa.txt
|
2013-03-15 13:58:31 +00:00
|
|
|
melpa
|
2013-08-24 16:11:37 +00:00
|
|
|
echo "0" > $WEBROOT/updatemelpa.txt
|
2013-01-07 16:22:58 +00:00
|
|
|
fi
|