Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/install.sh

78 lines
1.6 KiB
Bash
Raw Normal View History

2016-03-09 20:41:24 +05:00
#!/usr/bin/env bash
set -e
root=$(readlink -e "$(dirname "$0")")
2016-03-09 20:41:24 +05:00
prefix="/opt/nntpchan"
help_text="usage: $0 [--prefix /opt/nntpchan] [-q|--quiet] [-r|--rebuild] [--disable-redis]"
2016-03-09 20:41:24 +05:00
# check for help flags first
for arg in "$@" ; do
2016-03-09 20:41:24 +05:00
case $arg in
-h|--help)
echo "$help_text"
2016-03-09 20:41:24 +05:00
exit 0
;;
esac
done
_next=""
want_rebuild="0"
want_quiet="0"
build_args=""
# check for main flags
for arg in "$@" ; do
2016-03-09 20:41:24 +05:00
case $arg in
-q|--quiet)
want_quiet="1"
;;
-r|--rebuild)
want_rebuild="1"
;;
--prefix)
_next="prefix"
;;
--prefix=*)
prefix=$(echo "$arg" | cut -d'=' -f2)
2016-03-09 20:41:24 +05:00
;;
--disable-redis)
build_args="$build_args --disable-redis"
;;
2016-03-09 20:41:24 +05:00
*)
if [ "X$_next" == "Xprefix" ] ; then
# set prefix
prefix="$arg"
_next=""
fi
;;
esac
done
_cmd() {
if [ "X$want_quiet" == "X1" ] ; then
"$@" &> /dev/null
2016-03-09 20:41:24 +05:00
else
"$@"
2016-03-09 20:41:24 +05:00
fi
}
if [ "X$want_rebuild" == "X1" ] ; then
_cmd echo "rebuilding daemon";
_cmd "$root/build.sh" $build_args
2016-03-09 20:41:24 +05:00
fi
if [ ! -e "$root/srndv2" ] ; then
2016-03-09 20:41:24 +05:00
_cmd echo "building daemon"
# TODO: use different GOPATH for root?
_cmd "$root/build.sh" "$build_args"
2016-03-09 20:41:24 +05:00
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/"
2016-03-09 20:41:24 +05:00
_cmd echo "installed to $prefix"