Quote variables, remove trailing whitespace
If you don't quote your variables the scripts get very buggy if you run them with arguments with spaces in them, or even run them from a directory with spaces in its path.
This commit is contained in:
parent
6f5130d8fd
commit
a502259ba9
28
build-js.sh
28
build-js.sh
@ -1,21 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
root=$(readlink -e $(dirname $0))
|
||||
root=$(readlink -e "$(dirname "$0")")
|
||||
set -e
|
||||
if [ "x" == "x$root" ] ; then
|
||||
root=$PWD/${0##*}
|
||||
fi
|
||||
cd $root
|
||||
cd "$root"
|
||||
|
||||
if [ -z "$GOPATH" ]; then
|
||||
export GOPATH=$root/go
|
||||
mkdir -p $GOPATH
|
||||
mkdir -p "$GOPATH"
|
||||
fi
|
||||
|
||||
if [ ! -f $GOPATH/bin/minify ]; then
|
||||
echo "set up minifiy"
|
||||
if [ ! -f "$GOPATH/bin/minify" ]; then
|
||||
echo "set up minifiy"
|
||||
go get -v github.com/tdewolff/minify/cmd/minify
|
||||
fi
|
||||
if [ ! -f $GOPATH/bin/gopherjs ]; then
|
||||
if [ ! -f "$GOPATH/bin/gopherjs" ]; then
|
||||
echo "set up gopherjs"
|
||||
go get -v -u github.com/gopherjs/gopherjs
|
||||
fi
|
||||
@ -23,7 +23,7 @@ fi
|
||||
# build cuckoo miner
|
||||
echo "Building cuckoo miner"
|
||||
go get -v -u github.com/ZiRo-/cuckgo/miner_js
|
||||
$GOPATH/bin/gopherjs -m -v build github.com/ZiRo-/cuckgo/miner_js
|
||||
"$GOPATH/bin/gopherjs" -m -v build github.com/ZiRo-/cuckgo/miner_js
|
||||
mv ./miner_js.js ./contrib/static/miner-js.js
|
||||
rm ./miner_js.js.map
|
||||
|
||||
@ -35,7 +35,7 @@ lint() {
|
||||
true
|
||||
else
|
||||
echo "jslint: $1"
|
||||
jslint --browser $1
|
||||
jslint --browser "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -43,14 +43,14 @@ mini() {
|
||||
echo "minify $1"
|
||||
echo "" >> $2
|
||||
echo "/* local file: $1 */" >> $2
|
||||
$GOPATH/bin/minify --mime=text/javascript >> $2 < $1
|
||||
"$GOPATH/bin/minify" --mime=text/javascript >> $2 < $1
|
||||
}
|
||||
|
||||
# do linting too
|
||||
if [ "x$1" == "xlint" ] ; then
|
||||
echo "linting..."
|
||||
for f in ./contrib/js/*.js ; do
|
||||
lint $f
|
||||
lint "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
@ -58,14 +58,14 @@ echo -e "//For source code and license information please check https://github.c
|
||||
|
||||
if [ -e ./contrib/js/contrib/*.js ] ; then
|
||||
for f in ./contrib/js/contrib/*.js ; do
|
||||
mini $f $outfile
|
||||
mini "$f" "$outfile"
|
||||
done
|
||||
fi
|
||||
|
||||
mini ./contrib/js/main.js_ $outfile
|
||||
|
||||
mini ./contrib/js/main.js_ "$outfile"
|
||||
|
||||
# local js
|
||||
for f in ./contrib/js/*.js ; do
|
||||
mini $f $outfile
|
||||
mini "$f" "$outfile"
|
||||
done
|
||||
echo "ok"
|
||||
|
36
build.sh
36
build.sh
@ -1,20 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
root=$(readlink -e $(dirname $0))
|
||||
root=$(readlink -e "$(dirname "$0")")
|
||||
set -e
|
||||
if [ "x" == "x$root" ] ; then
|
||||
root=$PWD/${0##*}
|
||||
fi
|
||||
cd $root
|
||||
cd "$root"
|
||||
|
||||
tags=""
|
||||
|
||||
help_text="usage: $0 [--disable-redis]"
|
||||
|
||||
# check for help flags first
|
||||
for arg in $@ ; do
|
||||
for arg in "$@" ; do
|
||||
case $arg in
|
||||
-h|--help)
|
||||
echo $help_text
|
||||
echo "$help_text"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@ -25,7 +25,7 @@ ipfs="no"
|
||||
rebuildjs="yes"
|
||||
_next=""
|
||||
# check for build flags
|
||||
for arg in $@ ; do
|
||||
for arg in "$@" ; do
|
||||
case $arg in
|
||||
"--no-js")
|
||||
rebuildjs="no"
|
||||
@ -43,7 +43,7 @@ for arg in $@ ; do
|
||||
_next="rev"
|
||||
;;
|
||||
"--revision=*")
|
||||
rev=$(echo $arg | cut -d'=' -f2)
|
||||
rev=$(echo "$arg" | cut -d'=' -f2)
|
||||
;;
|
||||
*)
|
||||
if [ "x$_next" == "xrev" ] ; then
|
||||
@ -57,35 +57,35 @@ if [ "x$rev" == "x" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd $root
|
||||
cd "$root"
|
||||
if [ "x$rebuildjs" == "xyes" ] ; then
|
||||
echo "rebuilding generated js..."
|
||||
./build-js.sh
|
||||
fi
|
||||
unset GOPATH
|
||||
unset GOPATH
|
||||
export GOPATH=$PWD/go
|
||||
mkdir -p $GOPATH
|
||||
mkdir -p "$GOPATH"
|
||||
|
||||
if [ "x$ipfs" == "xyes" ] ; then
|
||||
if [ ! -e $GOPATH/bin/gx ] ; then
|
||||
if [ ! -e "$GOPATH/bin/gx" ] ; then
|
||||
echo "obtaining gx"
|
||||
go get -u -v github.com/whyrusleeping/gx
|
||||
fi
|
||||
if [ ! -e $GOPATH/bin/gx-go ] ; then
|
||||
if [ ! -e "$GOPATH/bin/gx-go" ] ; then
|
||||
echo "obtaining gx-go"
|
||||
go get -u -v github.com/whyrusleeping/gx-go
|
||||
fi
|
||||
echo "building stable revision, this will take a bit. to speed this part up install and run ipfs locally"
|
||||
mkdir -p $GOPATH/src/gx/ipfs
|
||||
cd $GOPATH/src/gx/ipfs
|
||||
$GOPATH/bin/gx get $rev
|
||||
cd $root
|
||||
go get -d -v
|
||||
mkdir -p "$GOPATH/src/gx/ipfs"
|
||||
cd "$GOPATH/src/gx/ipfs"
|
||||
"$GOPATH/bin/gx" get "$rev"
|
||||
cd "$root"
|
||||
go get -d -v
|
||||
go build -v .
|
||||
mv nntpchan srndv2
|
||||
else
|
||||
go get -u -v github.com/majestrate/srndv2
|
||||
cp $GOPATH/bin/srndv2 $root
|
||||
go get -u -v github.com/majestrate/srndv2
|
||||
cp "$GOPATH/bin/srndv2" "$root"
|
||||
fi
|
||||
|
||||
echo -e "Built\n"
|
||||
|
@ -3,8 +3,8 @@
|
||||
# script to make sql file for inserting all "currently trusted" keys
|
||||
#
|
||||
|
||||
root=$(readlink -e $(dirname $0))
|
||||
touch $root/keys.sql
|
||||
for key in $(cat $root/keys.txt) ; do
|
||||
root=$(readlink -e "$(dirname "$0")")
|
||||
touch "$root/keys.sql"
|
||||
for key in $(cat "$root/keys.txt") ; do
|
||||
echo "insert into modprivs(pubkey, newsgroup, permission) values('$key', 'overchan', 'all');" >> keys.sql ;
|
||||
done
|
||||
|
30
install.sh
30
install.sh
@ -1,16 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
root=$(readlink -e $(dirname $0))
|
||||
root=$(readlink -e "$(dirname "$0")")
|
||||
|
||||
prefix="/opt/nntpchan"
|
||||
|
||||
help_text="usage: $0 [--prefix /opt/nntpchan] [-q|--quiet] [-r|--rebuild] [--disable-redis]"
|
||||
|
||||
# check for help flags first
|
||||
for arg in $@ ; do
|
||||
for arg in "$@" ; do
|
||||
case $arg in
|
||||
-h|--help)
|
||||
echo $help_text
|
||||
echo "$help_text"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@ -22,7 +22,7 @@ want_quiet="0"
|
||||
build_args=""
|
||||
|
||||
# check for main flags
|
||||
for arg in $@ ; do
|
||||
for arg in "$@" ; do
|
||||
case $arg in
|
||||
-q|--quiet)
|
||||
want_quiet="1"
|
||||
@ -34,7 +34,7 @@ for arg in $@ ; do
|
||||
_next="prefix"
|
||||
;;
|
||||
--prefix=*)
|
||||
prefix=$(echo $arg | cut -d'=' -f2)
|
||||
prefix=$(echo "$arg" | cut -d'=' -f2)
|
||||
;;
|
||||
--disable-redis)
|
||||
build_args="$build_args --disable-redis"
|
||||
@ -51,27 +51,27 @@ done
|
||||
|
||||
_cmd() {
|
||||
if [ "X$want_quiet" == "X1" ] ; then
|
||||
$@ &> /dev/null
|
||||
"$@" &> /dev/null
|
||||
else
|
||||
$@
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "X$want_rebuild" == "X1" ] ; then
|
||||
_cmd echo "rebuilding daemon";
|
||||
_cmd $root/build.sh $build_args
|
||||
_cmd "$root/build.sh" $build_args
|
||||
fi
|
||||
|
||||
if [ ! -e $root/srndv2 ] ; then
|
||||
if [ ! -e "$root/srndv2" ] ; then
|
||||
_cmd echo "building daemon"
|
||||
# TODO: use different GOPATH for root?
|
||||
_cmd $root/build.sh $build_args
|
||||
_cmd "$root/build.sh" "$build_args"
|
||||
fi
|
||||
|
||||
|
||||
_cmd mkdir -p $prefix
|
||||
_cmd mkdir -p $prefix/webroot/thm
|
||||
_cmd mkdir -p $prefix/webroot/img
|
||||
_cmd cp -f $root/srndv2 $prefix/srndv2
|
||||
_cmd cp -rf $root/{doc,contrib,certs} $prefix/
|
||||
_cmd mkdir -p "$prefix"
|
||||
_cmd mkdir -p "$prefix/webroot/thm"
|
||||
_cmd mkdir -p "$prefix/webroot/img"
|
||||
_cmd cp -f "$root/srndv2" "$prefix/srndv2"
|
||||
_cmd cp -rf "$root/"{doc,contrib,certs} "$prefix/"
|
||||
_cmd echo "installed to $prefix"
|
||||
|
Reference in New Issue
Block a user