Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[submodule "ngx_openresty"]
path = dependencies/openresty
url = https://github.com/openresty/ngx_openresty
[submodule "sh-realpath"]
path = dependencies/sh-realpath
url = https://github.com/mkropat/sh-realpath
[submodule "lua.vm.js"]
path = dependencies/lua.vm.js
url = https://github.com/kripken/lua.vm.js.git
[submodule "libev"]
path = dependencies/libev
url = https://github.com/enki/libev.git
134 changes: 8 additions & 126 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ do
cosy_temp="${i#*=}"
cosy_temp="${cosy_temp%/}"
;;
-l=*|--lua=*)
lua_version="${i#*=}"
lua_version="${lua_version%/}"
;;
-m|--minimal)
minimal=true
;;
-i|--in-ci)
in_ci=true
;;
*)
echo "Usage: "
echo " install [--prefix=PREFIX] [--temp=TEMP_DIR] [--lua=LUA_VERSION] [--minimal] [--in-ci]"
echo " install [--prefix=PREFIX] [--temp=TEMP_DIR] [--in-ci]"
exit 1;
;;
esac
shift
done

# Useful variables:
Expand All @@ -39,7 +31,6 @@ currentwd=$(dirname "${currentwd}")
cosy_temp=${cosy_temp:-$(mktemp -d 2>/dev/null || mktemp -d -t cosy)}
cosy_log="${cosy_temp}/install.log"
cosy_prefix=${cosy_prefix:-${cosy_temp}}
lua_version=${lua_version:-5.2}
parallel=$(nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null)

{ # Detect if apt-get or brew is available:
Expand Down Expand Up @@ -102,7 +93,7 @@ if command -v git >> "${cosy_log}" 2>&1; then
popd >> "${cosy_log}" 2>&1
if [ "${version}" = "${oldversion}" ]; then
echo -e "Environment is already installed at version ${green}${oldversion}${nc}."
return
exit 0
fi
fi

Expand Down Expand Up @@ -136,7 +127,8 @@ cosy_temp=$(realpath "${cosy_temp}")
perl build-essential wget python python-pip \
libc6-dev libssl-dev \
libreadline-dev libncurses5-dev libpcre3-dev \
redis-server imagemagick npm caca-utils libc-bin
redis-server imagemagick npm caca-utils libc-bin \
postgresql
;;
"Darwin")
HOMEBREW_PREFIX=$(brew config | grep "HOMEBREW_PREFIX" | tr -d ' \t' | cut -d ":" -f 2)
Expand All @@ -145,7 +137,7 @@ cosy_temp=$(realpath "${cosy_temp}")
export LD_LIBRARY_PATH="${HOMEBREW_PREFIX}/lib:${LD_LIBRARY_PATH}"
export DYLD_LIBRARY_PATH="${HOMEBREW_PREFIX}/lib:${DYLD_LIBRARY_PATH}"
brew update
brew install openssl pcre python redis imagemagick wget npm libcaca
brew install openssl pcre python redis imagemagick wget npm libcaca postgresql
brew link --force openssl
;;
*)
Expand All @@ -161,26 +153,11 @@ cosy_temp=$(realpath "${cosy_temp}")
export LD_LIBRARY_PATH="${cosy_prefix}/lib:${LD_LIBRARY_PATH}"
}

# Install libev:
{
export CC=clang
echo -n "Installing libev... "
(
cd "${currentwd}/dependencies/libev"
./configure --prefix="${cosy_prefix}"
make
${sudo} make install
make clean
) >> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"
}

# Install lua, luarocks and packages:
{
export CC=clang
echo -n "Installing lua ${lua_version} and luarocks... "
if pip list | grep "hererocks" >> "${cosy_temp}" 2>&1; then
echo -n "Installing luajit and luarocks... "
if pip list | grep "hererocks" >> "${cosy_log}" 2>&1; then
hererocks="hererocks"
else
${sudo} pip install --root="${cosy_prefix}" hererocks
Expand All @@ -189,7 +166,7 @@ cosy_temp=$(realpath "${cosy_temp}")
PYTHONPATH=$(dirname "${path}"):"${PYTHONPATH}"
hererocks="${cosy_prefix}/usr/local/bin/hererocks"
fi >> "${cosy_log}" 2>&1
${sudo} "${hererocks}" "${cosy_prefix}" -r^ --lua="${lua_version}" \
${sudo} "${hererocks}" "${cosy_prefix}" -r^ --luajit=2.1 \
>> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"
Expand All @@ -201,8 +178,6 @@ cosy_temp=$(realpath "${cosy_temp}")
luacov-coveralls
luafilesystem
luasec
lustache
serpent
)
for dependency in ${dependencies[*]}; do
if "${cosy_prefix}/bin/luarocks" list --porcelain \
Expand All @@ -218,30 +193,6 @@ cosy_temp=$(realpath "${cosy_temp}")
|| echo -e "${red}failure${nc}"
fi
done
echo -n "Installing lua 5.1 and luarocks for nginx... "
${sudo} "${hererocks}" "${cosy_temp}/lua_install" -r^ --lua="5.1" \
>> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"
nginx_dependencies=(
lua-cjson
lua-resty-http
md5
)
for dependency in ${nginx_dependencies[*]}; do
if "${cosy_temp}/lua_install/bin/luarocks" list --tree="${cosy_prefix}" --porcelain \
>> "${cosy_log}" 2>&1 \
| grep --silent "${dependency}"; then
echo " Not installing ${dependency} as it is already installed."
else
echo -n " Installing ${dependency} as it is not installed... "
# shellcheck disable=SC2086
${sudo} "${cosy_temp}/lua_install/bin/luarocks" install --tree="${cosy_prefix}" "${dependency}" \
>> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"
fi
done
echo -n "Installing sh-realpath... "
( ${sudo} cp "${currentwd}/dependencies/sh-realpath/realpath.sh" "${cosy_prefix}/bin/"
${sudo} chmod a+x "${cosy_prefix}/bin/realpath.sh"
Expand All @@ -250,75 +201,6 @@ cosy_temp=$(realpath "${cosy_temp}")
|| echo -e "${red}failure${nc}"
}

if [ ! -z "${minimal+x}" ]; then
echo -e "Skipping openresty and web dependencies as minimal install is set."
return
fi

# Install web dependencies:
(
cd "${currentwd}" || exit 1
web_dependencies=(
bootbox
bootstrap3
d3
font-awesome
jquery
jquery-locationpicker
sjcl
)
rm -rf node_modules
echo "Installing web dependencies... "
for dependency in ${web_dependencies[*]}; do
echo -n " Installing ${dependency}... "
npm install "${dependency}" >> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"
done
${sudo} mkdir -p "${cosy_prefix}/share/cosy/www"
${sudo} mkdir -p "${cosy_prefix}/share/cosy/www/js"
${sudo} mkdir -p "${cosy_prefix}/share/cosy/www/css"
${sudo} mkdir -p "${cosy_prefix}/share/cosy/www/fonts"
for module in node_modules/*; do
name=$(basename "${module}")
${sudo} cp "${module}/dist/"*.js "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/dist/"*.map "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/dist/js/"* "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/dist/css/"* "${cosy_prefix}/share/cosy/www/css/" 2> /dev/null || true
${sudo} cp "${module}/dist/fonts/"* "${cosy_prefix}/share/cosy/www/fonts/" 2> /dev/null || true
${sudo} cp "${module}/js/"* "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/css/"* "${cosy_prefix}/share/cosy/www/css/" 2> /dev/null || true
${sudo} cp "${module}/fonts/"* "${cosy_prefix}/share/cosy/www/fonts/" 2> /dev/null || true
${sudo} cp "${module}/${name}"*.js "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/${name}"*.map "${cosy_prefix}/share/cosy/www/js/" 2> /dev/null || true
${sudo} cp "${module}/${name}"*.css "${cosy_prefix}/share/cosy/www/css/" 2> /dev/null || true
done
${sudo} rm -rf node_modules
${sudo} cp "dependencies/lua.vm.js/dist/lua.vm.js" "${cosy_prefix}/share/cosy/www/js/"
)

# Install openresty:
echo -n "Installing openresty... "
(
cd "${currentwd}/dependencies/openresty" || exit 1
make
for dir in openresty-*; do
if [ -d "${dir}" ]; then
cd "${dir}" || exit 1
./configure --prefix="${cosy_prefix}" \
--without-lua51 \
--with-ipv6 \
--with-pcre-jit
make -j"${parallel}"
${sudo} make install
make clean
break
fi
done
) >> "${cosy_log}" 2>&1 \
&& echo -e "${green}success${nc}" \
|| echo -e "${red}failure${nc}"

(
cd "${currentwd}" || exit 1
git rev-parse HEAD > "${cosy_temp}/environment.version"
Expand Down
1 change: 0 additions & 1 deletion dependencies/libev
Submodule libev deleted from e3a384
1 change: 0 additions & 1 deletion dependencies/lua.vm.js
Submodule lua.vm.js deleted from 4430a0
1 change: 0 additions & 1 deletion dependencies/openresty
Submodule openresty deleted from 5f7f67