From d97bb76eab8eeec05cef4453cc614ce7d1c6f02d Mon Sep 17 00:00:00 2001 From: "J. Patrick Avery, Jr" Date: Sun, 5 Feb 2017 20:39:34 -0700 Subject: [PATCH] QUOTES!!!! --- install.sh | 99 +++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/install.sh b/install.sh index b1170d6..9b7f78c 100755 --- a/install.sh +++ b/install.sh @@ -1,82 +1,83 @@ #! /bin/sh -e -DESTDIR=$1 +DESTDIR="$1" if [ -z "$DESTDIR" ]; then - echo "Usage: $0 DESTDIR" - exit + echo "Usage: $0 DESTDIR" + exit fi cd $(dirname $0) older () { - [ -z "$1" ] && return 1 - target=$1; shift - [ -f $target ] || return 0 - for i in "$@"; do - [ $i -nt $target ] && return 0 - done - return 1 + [ -z "$1" ] && return 1 + target="$1"; shift + [ -f "$target" ] || return 0 + for i in "$@"; do + [ "$i" -nt "$target" ] && return 0 + done + return 1 } copy () { - src=$1 - target=$2/$src - targetdir=$(dirname $target) - if older $target $src; then - echo "COPY $src" - mkdir -p $targetdir - cp $src $target - fi + src="$1" + target="$2/$src" + targetdir=$(dirname "$target") + if older "$target" "$src"; then + echo "COPY $src" + mkdir -p "$targetdir" + cp "$src" "$target" + fi } setup() { - [ -d $DESTDIR/state ] && return - echo "SETUP" - for i in points.new points.tmp teams; do - dir=$DESTDIR/state/$i - mkdir -p $dir - setfacl -m ${www}:rwx $dir - done - mkdir -p $DESTDIR/packages - >> $DESTDIR/state/points.log - if ! [ -f $DESTDIR/assigned.txt ]; then - hd $DESTDIR/assigned.txt - fi + www="$1" + [ -d "$DESTDIR/state" ] && return + echo "SETUP" + for i in points.new points.tmp teams; do + dir="$DESTDIR/state/$i" + mkdir -p "$dir" + setfacl -m ${www}:rwx "$dir" + done + mkdir -p "$DESTDIR/packages" + >> "$DESTDIR/state/points.log" + if ! [ -f "$DESTDIR/assigned.txt" ]; then + hd "$DESTDIR/assigned.txt" + fi - mkdir -p $DESTDIR/www - ln -sf ../state/points.json $DESTDIR/www - ln -sf ../state/puzzles.json $DESTDIR/www + mkdir -p "$DESTDIR/www" + ln -sf ../state/points.json "$DESTDIR/www" + ln -sf ../state/puzzles.json "$DESTDIR/www" } echo "Figuring out web user..." for www in www-data http tc _ _www; do - id $www && break + id $www && break done if [ $www = _ ]; then - echo "Unable to determine httpd user on this system. Dying." - exit 1 + echo "Unable to determine httpd user on this system. Dying." + exit 1 fi -mkdir -p $DESTDIR || exit 1 +mkdir -p "$DESTDIR" || exit 1 -setup +setup $www git $SRCDIR ls-files | while read fn; do - case "$fn" in - example-puzzles/*|tools/*|docs/*|install.sh|setup.cfg|README.md|.gitignore|src/mothd) - true # skip - ;; +case "$fn" in + example-puzzles/*|tools/*|docs/*|install.sh|setup.cfg|README.md|.gitignore|src/mothd) + true # skip + ;; www/*) - copy $fn $DESTDIR/ - ;; + copy "$fn" "$DESTDIR/" + ;; bin/*) - copy $fn $DESTDIR/ - ;; + copy "$fn" "$DESTDIR/" + ;; *) - echo "??? $fn" - ;; - esac + echo "??? $fn" + ;; +esac done echo "All done installing."