mirror of https://github.com/dirtbags/moth.git
QUOTES!!!!
This commit is contained in:
parent
84cf0d7b56
commit
d97bb76eab
99
install.sh
99
install.sh
|
@ -1,82 +1,83 @@
|
||||||
#! /bin/sh -e
|
#! /bin/sh -e
|
||||||
|
|
||||||
DESTDIR=$1
|
DESTDIR="$1"
|
||||||
|
|
||||||
if [ -z "$DESTDIR" ]; then
|
if [ -z "$DESTDIR" ]; then
|
||||||
echo "Usage: $0 DESTDIR"
|
echo "Usage: $0 DESTDIR"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
older () {
|
older () {
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
target=$1; shift
|
target="$1"; shift
|
||||||
[ -f $target ] || return 0
|
[ -f "$target" ] || return 0
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
[ $i -nt $target ] && return 0
|
[ "$i" -nt "$target" ] && return 0
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
copy () {
|
copy () {
|
||||||
src=$1
|
src="$1"
|
||||||
target=$2/$src
|
target="$2/$src"
|
||||||
targetdir=$(dirname $target)
|
targetdir=$(dirname "$target")
|
||||||
if older $target $src; then
|
if older "$target" "$src"; then
|
||||||
echo "COPY $src"
|
echo "COPY $src"
|
||||||
mkdir -p $targetdir
|
mkdir -p "$targetdir"
|
||||||
cp $src $target
|
cp "$src" "$target"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
[ -d $DESTDIR/state ] && return
|
www="$1"
|
||||||
echo "SETUP"
|
[ -d "$DESTDIR/state" ] && return
|
||||||
for i in points.new points.tmp teams; do
|
echo "SETUP"
|
||||||
dir=$DESTDIR/state/$i
|
for i in points.new points.tmp teams; do
|
||||||
mkdir -p $dir
|
dir="$DESTDIR/state/$i"
|
||||||
setfacl -m ${www}:rwx $dir
|
mkdir -p "$dir"
|
||||||
done
|
setfacl -m ${www}:rwx "$dir"
|
||||||
mkdir -p $DESTDIR/packages
|
done
|
||||||
>> $DESTDIR/state/points.log
|
mkdir -p "$DESTDIR/packages"
|
||||||
if ! [ -f $DESTDIR/assigned.txt ]; then
|
>> "$DESTDIR/state/points.log"
|
||||||
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > $DESTDIR/assigned.txt
|
if ! [ -f "$DESTDIR/assigned.txt" ]; then
|
||||||
fi
|
hd </dev/urandom | awk '{print $3 $4 $5 $6;}' | head -n 100 > "$DESTDIR/assigned.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $DESTDIR/www
|
mkdir -p "$DESTDIR/www"
|
||||||
ln -sf ../state/points.json $DESTDIR/www
|
ln -sf ../state/points.json "$DESTDIR/www"
|
||||||
ln -sf ../state/puzzles.json $DESTDIR/www
|
ln -sf ../state/puzzles.json "$DESTDIR/www"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "Figuring out web user..."
|
echo "Figuring out web user..."
|
||||||
for www in www-data http tc _ _www; do
|
for www in www-data http tc _ _www; do
|
||||||
id $www && break
|
id $www && break
|
||||||
done
|
done
|
||||||
if [ $www = _ ]; then
|
if [ $www = _ ]; then
|
||||||
echo "Unable to determine httpd user on this system. Dying."
|
echo "Unable to determine httpd user on this system. Dying."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $DESTDIR || exit 1
|
mkdir -p "$DESTDIR" || exit 1
|
||||||
|
|
||||||
setup
|
setup $www
|
||||||
git $SRCDIR ls-files | while read fn; do
|
git $SRCDIR ls-files | while read fn; do
|
||||||
case "$fn" in
|
case "$fn" in
|
||||||
example-puzzles/*|tools/*|docs/*|install.sh|setup.cfg|README.md|.gitignore|src/mothd)
|
example-puzzles/*|tools/*|docs/*|install.sh|setup.cfg|README.md|.gitignore|src/mothd)
|
||||||
true # skip
|
true # skip
|
||||||
;;
|
;;
|
||||||
www/*)
|
www/*)
|
||||||
copy $fn $DESTDIR/
|
copy "$fn" "$DESTDIR/"
|
||||||
;;
|
;;
|
||||||
bin/*)
|
bin/*)
|
||||||
copy $fn $DESTDIR/
|
copy "$fn" "$DESTDIR/"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "??? $fn"
|
echo "??? $fn"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "All done installing."
|
echo "All done installing."
|
||||||
|
|
Loading…
Reference in New Issue