From e8dff0b99e4469fbf1216b968733a8267fd22da6 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sun, 15 Dec 2013 22:27:32 +0100 Subject: Make the linux runner script more helpful and add dialogs --- package/linux/MultiMC | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'package/linux') diff --git a/package/linux/MultiMC b/package/linux/MultiMC index 8229b24f..8095413d 100755 --- a/package/linux/MultiMC +++ b/package/linux/MultiMC @@ -12,7 +12,7 @@ export QT_FONTPATH="${MMC_DIR}/fonts" # Detect missing dependencies... DEPS_LIST=`ldd "${MMC_DIR}"/plugins/*/*.so | grep "not found" | awk -vORS=", " '{ print $1 }'` -if [ -z $DEPS_LIST ]; then +if [ "x$DEPS_LIST" = "x" ]; then # We have all our dependencies. Run MultiMC. echo "No missing dependencies found." @@ -25,9 +25,46 @@ if [ -z $DEPS_LIST ]; then # Exit with MultiMC's exit code. exit $? else - echo "Error: MultiMC is missing the following libraries that it needs to work correctly:" - echo "\t${DEPS_LIST}" - echo "Please install them from your distribution's package manager." + # apt + if which apt-file >/dev/null; then + LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` + COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do apt-file -l search $LIBRARY; done` + COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` + INSTALL_CMD="sudo apt-get install $COMMAND_LIBS" + # pacman + elif which pkgfile >/dev/null; then + LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` + COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do pkgfile $LIBRARY; done` + COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` + INSTALL_CMD="sudo pacman -S $COMMAND_LIBS" + # yum + elif which yum >/dev/null; then + LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` + COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do yum whatprovides $LIBRARY; done` + COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` + INSTALL_CMD="sudo yum install $COMMAND_LIBS" + # zypper + elif which zypper >/dev/null; then + LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` + COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do zypper wp $LIBRARY; done` + COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` + INSTALL_CMD="sudo zypper install $COMMAND_LIBS" + # emerge + elif which pfl >/dev/null; then + LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` + COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do pfl $LIBRARY; done` + COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` + INSTALL_CMD="sudo emerge $COMMAND_LIBS" + fi + + MESSAGE="Error: MultiMC is missing the following libraries that it needs to work correctly:\n\t${DEPS_LIST}\nPlease install them from your distribution's package manager." + MESSAGE="$MESSAGE\n\nHint: $INSTALL_CMD" + + echo $MESSAGE + + if which zenity >/dev/null; then zenity --error --text="$MESSAGE"; + elif which kdialog >/dev/null; then kdialog --error "$MESSAGE"; + fi + exit 1 fi - -- cgit From 7353908fd69eb23391d29240a5f274cce7f49e42 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 16 Dec 2013 13:47:27 +0100 Subject: Fix running the runner script using a symlink --- package/linux/MultiMC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/linux') diff --git a/package/linux/MultiMC b/package/linux/MultiMC index 8229b24f..d8d620aa 100755 --- a/package/linux/MultiMC +++ b/package/linux/MultiMC @@ -1,7 +1,7 @@ #!/bin/sh # Basic start script for running MultiMC with the libs packaged with it. -MMC_DIR=`dirname "$0"` +MMC_DIR="$(dirname "$(readlink -f "$0")")" cd "${MMC_DIR}" echo "MultiMC Dir: ${MMC_DIR}" -- cgit From 0f6ad12fd8d4b1b727891f6fa0fb69f09f64e827 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sat, 21 Dec 2013 09:36:12 +0100 Subject: Prevent running as root on linux --- package/linux/MultiMC | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'package/linux') diff --git a/package/linux/MultiMC b/package/linux/MultiMC index 8e854676..fb2c28f6 100755 --- a/package/linux/MultiMC +++ b/package/linux/MultiMC @@ -1,6 +1,19 @@ #!/bin/sh # Basic start script for running MultiMC with the libs packaged with it. +function printerror { + echo $1 + if which zenity >/dev/null; then zenity --error --text="$1" &>/dev/null; + elif which kdialog >/dev/null; then kdialog --error "$1" &>/dev/null; + fi +} + +if [[ $EUID -eq 0 ]]; then + printerror "This program should not be run using sudo or as the root user" + exit 1 +fi + + MMC_DIR="$(dirname "$(readlink -f "$0")")" cd "${MMC_DIR}" echo "MultiMC Dir: ${MMC_DIR}" @@ -11,7 +24,7 @@ export QT_PLUGIN_PATH="${MMC_DIR}/plugins" export QT_FONTPATH="${MMC_DIR}/fonts" # Detect missing dependencies... -DEPS_LIST=`ldd "${MMC_DIR}"/plugins/*/*.so | grep "not found" | awk -vORS=", " '{ print $1 }'` +DEPS_LIST=`ldd "${MMC_DIR}"/plugins/*/*.so 2>/dev/null | grep "not found" | awk -vORS=", " '{ print $1 }'` if [ "x$DEPS_LIST" = "x" ]; then # We have all our dependencies. Run MultiMC. echo "No missing dependencies found." @@ -60,11 +73,6 @@ else MESSAGE="Error: MultiMC is missing the following libraries that it needs to work correctly:\n\t${DEPS_LIST}\nPlease install them from your distribution's package manager." MESSAGE="$MESSAGE\n\nHint: $INSTALL_CMD" - echo $MESSAGE - - if which zenity >/dev/null; then zenity --error --text="$MESSAGE"; - elif which kdialog >/dev/null; then kdialog --error "$MESSAGE"; - fi - + printerror $MESSAGE exit 1 fi -- cgit From 42bc02dc8af3f9791bce1b797cbe78d6d2c66040 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 22 Dec 2013 20:53:35 +0100 Subject: BASH! --- package/linux/MultiMC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/linux') diff --git a/package/linux/MultiMC b/package/linux/MultiMC index fb2c28f6..7ccc2bac 100755 --- a/package/linux/MultiMC +++ b/package/linux/MultiMC @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Basic start script for running MultiMC with the libs packaged with it. function printerror { -- cgit From 449f55c3e668c0e01eee0868226473f12d0b109f Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Wed, 25 Dec 2013 14:43:51 +0100 Subject: Fix linux runner script. --- package/linux/MultiMC | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'package/linux') diff --git a/package/linux/MultiMC b/package/linux/MultiMC index 7ccc2bac..7fb72f98 100755 --- a/package/linux/MultiMC +++ b/package/linux/MultiMC @@ -2,14 +2,14 @@ # Basic start script for running MultiMC with the libs packaged with it. function printerror { - echo $1 + printf "$1" if which zenity >/dev/null; then zenity --error --text="$1" &>/dev/null; elif which kdialog >/dev/null; then kdialog --error "$1" &>/dev/null; fi } if [[ $EUID -eq 0 ]]; then - printerror "This program should not be run using sudo or as the root user" + printerror "This program should not be run using sudo or as the root user!\n" exit 1 fi @@ -39,31 +39,31 @@ if [ "x$DEPS_LIST" = "x" ]; then exit $? else # apt - if which apt-file >/dev/null; then + if which apt-file &>/dev/null; then LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do apt-file -l search $LIBRARY; done` COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` INSTALL_CMD="sudo apt-get install $COMMAND_LIBS" # pacman - elif which pkgfile >/dev/null; then + elif which pkgfile &>/dev/null; then LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do pkgfile $LIBRARY; done` COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` INSTALL_CMD="sudo pacman -S $COMMAND_LIBS" # yum - elif which yum >/dev/null; then + elif which yum &>/dev/null; then LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do yum whatprovides $LIBRARY; done` COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` INSTALL_CMD="sudo yum install $COMMAND_LIBS" # zypper - elif which zypper >/dev/null; then + elif which zypper &>/dev/null; then LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do zypper wp $LIBRARY; done` COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` INSTALL_CMD="sudo zypper install $COMMAND_LIBS" # emerge - elif which pfl >/dev/null; then + elif which pfl &>/dev/null; then LIBRARIES=`echo "$DEPS_LIST" | grep -oP "[^, ]*"` COMMAND_LIBS=`for LIBRARY in $LIBRARIES; do pfl $LIBRARY; done` COMMAND_LIBS=`echo "$COMMAND_LIBS" | awk -vORS=" " '{ print $1 }'` @@ -71,8 +71,8 @@ else fi MESSAGE="Error: MultiMC is missing the following libraries that it needs to work correctly:\n\t${DEPS_LIST}\nPlease install them from your distribution's package manager." - MESSAGE="$MESSAGE\n\nHint: $INSTALL_CMD" + MESSAGE="$MESSAGE\n\nHint: $INSTALL_CMD\n" - printerror $MESSAGE + printerror "$MESSAGE" exit 1 fi -- cgit