homepage/install

92 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-03-20 18:32:15 -06:00
#! /bin/sh
DESTDIR=${1:-/home/neale/public_html}
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-04-29 13:13:10 -06:00
target=$DESTDIR/${1%mdwn}html
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%.*}
echo "SETUID $target"
chmod u+s $target
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
;;
car.cgi.go)
gc $fn
setuid $fn
;;
2015-03-20 18:32:15 -06:00
*.mdwn)
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