From 56ac65a54bdc9a9f55d15a2d9c317651361619c4 Mon Sep 17 00:00:00 2001 From: Akythius Date: Mon, 25 Nov 2013 21:52:38 +0000 Subject: [PATCH] Install wrapper to automatically detect distribution Detects Linux distribution, downloads and executes corresponding installation script. --- installers/install.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 installers/install.sh diff --git a/installers/install.sh b/installers/install.sh new file mode 100644 index 0000000..b227ce4 --- /dev/null +++ b/installers/install.sh @@ -0,0 +1,37 @@ +BASE_URL="https://raw.github.com/marcuswhybrow/minecraft-server-manager/master/installers/" + +function check_os() { + if [[ -f /etc/debian_version ]]; then + INSTALL_SCRIPT="debian.sh" + elif [[ -f /etc/redhat-release ]]; then + INSTALL_SCRIPT="arch.sh" + elif [[ -f /etc/arch-release ]]; then + INSTALL_SCRIPT="redhat.sh" + else + echo "Error, unsupported distribution. Please install manually." + exit 1 + fi +} + +function get_installer() { + type curl 1>/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + curl "${BASE_URL}/${INSTALL_SCRIPT}" -o /tmp/msminst.sh + else + wget -q "${BASE_URL}/${INSTALL_SCRIPT}" -O /tmp/msminst.sh + fi + chmod u+x /tmp/msminst.sh +} + +function do_install() { + if [[ -f /tmp/msminst.sh ]]; then + /tmp/msminst.sh && rm -f /tmp/msminst.sh + else + echo "Error, failed to download install script." + exit 1 + fi +} + +check_os +get_installer +do_install