homepage/install

96 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2015-03-20 18:32:15 -06:00
DESTDIR=${1:-/home/neale/public_html}
2017-04-30 10:36:56 -06:00
GOPATH=$HOME/go export GOPATH
2015-03-20 18:32:15 -06:00
cd $(dirname $0)
older () {
tgt=$1
2016-01-23 11:33:51 -07:00
[ -f "$tgt" ] || return 0
for src in "$@"; do
[ "$src" -nt "$tgt" ] && return 0
done
return 1
}
2015-03-20 18:32:15 -06:00
html () {
2017-07-08 15:09:23 -06:00
target=$DESTDIR/${1%md}html
2017-04-29 13:13:10 -06:00
if older $target $1 tmpl/*; then
echo "HTML $1"
mkdir -p $(dirname $target)
./tmpl/mdwntohtml < $1 > $target
fi
2015-03-20 18:32:15 -06:00
}
copy () {
2017-04-29 13:13:10 -06:00
target=$DESTDIR/$1
if older $target $1; then
echo "COPY $1"
mkdir -p $(dirname $target)
cp $1 $target
fi
2015-03-20 18:32:15 -06:00
}
cc () {
2017-04-29 13:13:10 -06:00
target=$DESTDIR/${1%.c}
if older $target $1; then
echo "CC $1"
gcc -o $target $1
fi
2015-03-20 18:32:15 -06:00
}
gc () {
2017-04-29 13:13:10 -06:00
target=$DESTDIR/${1%.go}
if older $target $1; then
echo "GO $1"
go build -o $target $1
fi
}
setuid () {
target=$DESTDIR/${1%.*}
2017-05-15 10:57:15 -06:00
if ! [ -u $target ]; then
echo "SETUID $target"
chmod u+s $target
fi
2015-03-20 18:32:15 -06:00
}
install () {
2017-04-29 13:13:10 -06:00
fd=$(dirname $fn)
echo "SUBINSTALL $fd"
(cd $fd && ./install $DESTDIR/$fd)
2015-03-20 18:32:15 -06:00
}
git ls-files | while read fn; do
2017-04-29 13:13:10 -06:00
case "$fn" in
2015-03-20 18:32:15 -06:00
.*|*/.*|*~|install)
2017-04-29 13:13:10 -06:00
true # Skip
;;
2015-03-20 18:32:15 -06:00
*/install)
2017-04-29 13:13:10 -06:00
install $fn
;;
trigger.cgi.go|g.cgi.go)
2017-04-29 13:13:10 -06:00
gc $fn
setuid $fn
;;
2017-07-08 15:09:23 -06:00
*.md)
2017-04-29 13:13:10 -06:00
html $fn
;;
2015-03-20 18:32:15 -06:00
*.cgi.c)
2017-04-29 13:13:10 -06:00
cc $fn
;;
2015-03-20 18:32:15 -06:00
*.cgi.go)
2017-04-29 13:13:10 -06:00
gc $fn
;;
2015-03-20 18:32:15 -06:00
*)
2017-04-29 13:13:10 -06:00
copy $fn
;;
esac
2015-03-20 18:32:15 -06:00
done
2017-05-15 10:57:15 -06:00