71 lines
2.5 KiB
Bash
Executable File
71 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Basic start script for running MultiMC with the libs packaged with it.
|
|
|
|
MMC_DIR=`dirname "$0"`
|
|
cd "${MMC_DIR}"
|
|
echo "MultiMC Dir: ${MMC_DIR}"
|
|
|
|
# Set up env
|
|
export LD_LIBRARY_PATH="${MMC_DIR}/bin":$LD_LIBRARY_PATH
|
|
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 }'`
|
|
if [ "x$DEPS_LIST" = "x" ]; then
|
|
# We have all our dependencies. Run MultiMC.
|
|
echo "No missing dependencies found."
|
|
|
|
# Just to be sure...
|
|
chmod +x "${MMC_DIR}/bin/MultiMC"
|
|
|
|
# Run MultiMC
|
|
"${MMC_DIR}/bin/MultiMC" -d "${MMC_DIR}" $@
|
|
|
|
# Exit with MultiMC's exit code.
|
|
exit $?
|
|
else
|
|
# 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
|