Last active
February 25, 2016 05:09
-
-
Save xpol/4db9397b9e6d3a61980e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install luarocks for luaenv. | |
function install() { | |
printf "install luarocks for $1..." | |
local ROOT=`luaenv root` | |
if [[ $1 == luajit* ]]; then | |
./configure --prefix=$ROOT/versions/$1 \ | |
--with-lua=$ROOT/versions/$1 \ | |
--rocks-tree=$ROOT/versions/$1 \ | |
--sysconfdir=$ROOT/versions/$1 \ | |
--with-lua-include=$ROOT/versions/$1/include/${1:0:10} >/dev/null | |
else | |
./configure --prefix=$ROOT/versions/$1 \ | |
--with-lua=$ROOT/versions/$1 \ | |
--rocks-tree=$ROOT/versions/$1 \ | |
--sysconfdir=$ROOT/versions/$1 >/dev/null | |
fi | |
if [ $? -ne 0 ]; then | |
printf "\e[31merror: configure luarocks\e[0m\n" | |
exit | |
fi | |
make build >/dev/null | |
if [ $? -ne 0 ]; then | |
printf "\e[31merror: build luarocks\e[0m\n" | |
exit | |
fi | |
make install >/dev/null | |
if [ $? -ne 0 ]; then | |
printf "\e[31merror: install luarocks\e[0m\n" | |
exit | |
else | |
printf "\e[32mok\e[0m\n" | |
fi | |
} | |
function main() { | |
case $1 in | |
all) | |
for version in `luaenv whence lua`; do | |
install $version | |
done | |
;; | |
*.*) | |
for version in `luaenv whence lua`; do | |
if [ $version == $1 ] ; then | |
install $version | |
exit | |
fi | |
done | |
printf "\e[1mError: version \e[31m$1\e[0m \e[1mnot found.\e[0m\n" | |
exit | |
;; | |
*) | |
echo "Usage: luaenv-rocks [<version>|all]" | |
echo "" | |
echo "Install luarocks for your Lua installtion in luaenv." | |
echo "" | |
echo "<version>: install for specified version only" | |
echo " (same version strings as used in luaenv)." | |
echo " all: install luarocks for all is the lua versions" | |
echo " installed in luaenv." | |
exit | |
;; | |
esac | |
} | |
main $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt-get update >/dev/null | |
sudo apt-get install build-essential -y >/dev/null | |
if ! [ -x "$(command -v unzip)" ]; then | |
echo install unzip | |
sudo apt-get install unzip -y >/dev/null | |
fi | |
if ! [ -x "$(command -v git)" ]; then | |
echo install git... | |
sudo apt-get install git -y >/dev/null | |
fi | |
if ! [ -x "$(command -v mongod)" ]; then | |
echo install mongodb... | |
sudo apt-get install mongodb -y >/dev/null | |
fi | |
if ! [ -x "$(command -v luaenv)" ]; then | |
echo install luaenv... | |
git clone https://github.com/cehoffman/luaenv.git ~/.luaenv | |
git clone git://github.com/cehoffman/lua-build.git ~/.luaenv/plugins/lua-build | |
echo 'export PATH="$HOME/.luaenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(luaenv init -)"' >> ~/.bashrc | |
. ~/.bashrc | |
fi | |
if ! [ -x "$(command -v lua)" ]; then | |
echo install luajit... | |
luaenv install luajit-2.0.4 | |
luaenv global luajit-2.0.4 | |
fi | |
if ! [ -x "$(command -v luarocks)" ]; then | |
echo install luarocks... | |
curl -L -O http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz | |
tar -xvzf luarocks-2.3.0.tar.gz | |
pushd luarocks-2.3.0 | |
curl -L -O https://gist.githubusercontent.com/xpol/4db9397b9e6d3a61980e/raw/7f29bc09632eae14e9f149f8f121f90d163f4b10/luaenv-rocks.sh | |
chmod +x luaenv-rocks.sh | |
./luaenv-rocks.sh luajit-2.0.4 | |
luaenv rehash | |
popd | |
fi | |
if ! [ -x "$(command -v luvit)" ]; then | |
echo install luvit... | |
mkdir ~/.luvit | |
pushd ~/.luvit | |
echo 'export PATH="$HOME/.luvit:$PATH"' >> ~/.bashrc | |
curl -L https://github.com/luvit/lit/raw/master/get-lit.sh | sh | |
./lit make github://luvit/luvit | |
popd | |
fi | |
. ~/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment