From f370cb89e8c8f11e02f51adc0675302e542e4e12 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Wed, 29 Apr 2020 19:28:42 -0400 Subject: [PATCH] Add web install for minetestmapper from source. --- minetestmapper-deps.sh | 38 ++++++++++++++++++++++++ minetestmapper-web-install.sh | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100755 minetestmapper-deps.sh create mode 100755 minetestmapper-web-install.sh diff --git a/minetestmapper-deps.sh b/minetestmapper-deps.sh new file mode 100755 index 0000000..0d20836 --- /dev/null +++ b/minetestmapper-deps.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +customDie() { + echo + echo + echo "ERROR:" + echo "$1" + echo "You'll need to manually install:" + echo "libgd sqlite3 LevelDB hiredis Postgres" + echo + echo + exit 1 +} + + +PACKAGE_TYPE= +if [ -f "`command -v apt`" ]; then + INSTALL_CMD="apt -y install" + PACKAGE_TYPE="deb" +elif [ -f "`command -v apt-get`" ]; then + INSTALL_CMD="apt-get -y install" + PACKAGE_TYPE="deb" +elif [ -f "`command -v dnf`" ]; then + INSTALL_CMD="dnf -y install" + PACKAGE_TYPE="rpm" +elif [ -f "`command -v yum`" ]; then + INSTALL_CMD="yum -y install" + PACKAGE_TYPE="rpm" +else + customDie "Your package system is not implemented in this script." +fi +if [ "@$PACKAGE_TYPE" = "@deb" ]; then + sudo $INSTALL_CMD libgd-dev libsqlite3-dev libleveldb-dev libhiredis-dev libpq-dev +elif [ "@$PACKAGE_TYPE" = "@rpm" ]; then + sudo $INSTALL_CMD gd-devel sqlite-devel leveldb-devel hiredis-devel libpq-devel +else + customDie "The package names for your OS are unknown." +fi diff --git a/minetestmapper-web-install.sh b/minetestmapper-web-install.sh new file mode 100755 index 0000000..c3bc93e --- /dev/null +++ b/minetestmapper-web-install.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +customDie() { + echo + echo + echo "ERROR:" + echo "$1" + echo + echo + exit 1 +} + +_REPO_NAME=minetestmapper +if [ -z "$_INSTALL_PATH" ]; then + _INSTALL_PATH="$HOME/$_REPO_NAME" +fi +_EXE_NAME=minetestmapper +_REPO_URL="https://github.com/minetest/$_REPO_NAME.git" +if [ -z "$REPOS_PATH" ]; then + REPOS_PATH=~/Downloads/git +fi +mkdir -p $REPOS_PATH + +REPO_PATH="$REPOS_PATH/$_REPO_NAME" + +if [ ! -d "$REPOS_PATH" ]; then + mkdir -p "$REPOS_PATH" || customDie "mkdir -p \"$REPOS_PATH\" failed." +fi + +cd "$REPOS_PATH" || customDie "cd \"$REPOS_PATH\" failed." +if [ -d "$REPO_PATH" ]; then + cd "$REPO_PATH" || customDie "cd \"$REPO_PATH\" failed." + git pull || customDie "git pull failed in `pwd`." +else + git clone "$_REPO_URL" "$REPO_PATH" || customDie "git clone \"$_REPO_URL\" \"$REPO_PATH\" failed." +fi +echo "* compiling in `pwd`..." +cmake . -DENABLE_LEVELDB=1 -DENABLE_POSTGRES=1 -DENABLE_REDIS=1 || customDie "cmake . failed in `pwd`." +make -j$(nproc) || customDie "make failed in `pwd`." +_EXE_PATH="`pwd`/$_EXE_NAME" +if [ -f "$_EXE_PATH" ]; then + echo "* finished compiling \"$_EXE_PATH\"" + mkdir -p "$_INSTALL_PATH" || "mkdir -p \"$_INSTALL_PATH\" failed." + #cp "$_EXE_PATH" "$_INSTALL_PATH" || "cp \"$_EXE_PATH\" \"$_INSTALL_PATH\" failed." + rsync -rtu "`pwd`/" "$_INSTALL_PATH" || "rsync -rtu \"`pwd`/\" \"$_INSTALL_PATH\" failed." + # -u: skip files that are newer on the receiver + EXE_DEST_PATH="$_INSTALL_PATH/$_EXE_NAME" + if [ -f "$EXE_DEST_PATH" ]; then + echo "* installed \"$EXE_DEST_PATH\"" + else + customDie "* installing \"$EXE_DEST_PATH\" failed." + fi +else + echo "* finished compiling in `pwd` (but $_EXE_PATH was not detected)" +fi