/
local-install
executable file
·66 lines (57 loc) · 1.86 KB
/
local-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# Used by scripts/Makefile and scripts/rebar-pre-script to do a local
# install of yaws. The "make local_install" top-level command installs
# files under $HOME, whereas "rebar compile" keeps everything local to the
# build directory.
set -e
if [ -z "$2" ]; then
if [ -z "$HOME" ]; then
if [ `id -u` = 0 -a -d /root ]; then
HOME=/root
else
HOME=/tmp
fi
export HOME
fi
target_dir="${HOME}"
conf_dir="${HOME}"
else
target_dir="$2"
conf_dir="${target_dir}/etc/yaws"
[ -d "$target_dir" ] || mkdir "$target_dir"
[ -d "$target_dir/etc" ] || mkdir "$target_dir/etc"
[ -d "$target_dir/etc/yaws" ] || mkdir "$target_dir/etc/yaws"
fi
script=`basename $0`
tmpgen=`mktemp /tmp/${script}.XXXXXX`
logdir="${target_dir}/yaws_logs"
[ -d "$logdir" ] || mkdir "$logdir"
overwrite=true
if [ -f "${conf_dir}/yaws.conf" ]; then
overwrite=false
target="${conf_dir}/yaws.conf.template"
else
target="${conf_dir}/yaws.conf"
fi
topdir=`cd .. && pwd`
[ -d "${VARDIR}" ] || mkdir "${VARDIR}"
[ -d "${VARDIR}/yaws" ] || mkdir "${VARDIR}/yaws"
[ -d "${VARDIR}/yaws/ebin" ] || mkdir "${VARDIR}/yaws/ebin"
YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \
DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \
./gen-yaws-conf > $tmpgen
if [ -f "$target" ] && cmp -s "$target" "$tmpgen"; then
rm -f "$tmpgen"
else
mv -f "$tmpgen" "$target"
[ $overwrite = false ] && echo "--- Will not overwrite ${conf_dir}/yaws.conf"
echo "--- Installing local config file at $target"
fi
[ "$topdir" = "$target_dir" ] && exit 0
if [ "$1" = true ] || [ ! -f "${target_dir}/bin/yaws" ]; then
[ -d "${target_dir}/bin" ] || mkdir "${target_dir}/bin"
rm -f "${target_dir}/bin/yaws"
cp -f ../bin/yaws "${target_dir}/bin/yaws"
echo "--- Installed $target_dir/bin/yaws"
fi
exit 0