diff --git a/compile_installer.sh b/compile_installer.sh new file mode 100644 index 00000000..697eff28 --- /dev/null +++ b/compile_installer.sh @@ -0,0 +1,79 @@ +#!/bin/bash +if [ ! -f "./bin/BeamMP-Launcher" ]; then + echo "Please build BeamMP first" + exit 1 +fi + +echo "Setting up" +cd data +cp installer.sh ./BeamMP_Installer.sh + +# Check for libraries automagically +if command -v ldd > /dev/null; then + echo "Adding checks for libraries" + LIBS="$(ldd ../bin/BeamMP-Launcher | awk '{print $1}' | grep -v "linux-vdso.so" | grep -v "ld-linux")" + LIBREQUEST="LIBREQUEST=\"\"" + while IFS= read -r LIB; do + LIBREQUEST="$LIBREQUEST\nif [ ! -n \"\$(ldconfig -p | grep \"$LIB\")\" ]; then\nLIBREQUEST=\"$LIB \$LIBREQUEST\"\nfi" + done <<< "$LIBS" + sed -i "s/SETUPLIBREQUEST/$LIBREQUEST/g" ./BeamMP_Installer.sh +else + echo "Skipping library checks due to lack of ldd (What system are you running???)" + sed -i "s/SETUPLIBREQUEST/LIBREQUEST=\"\"/g" ./BeamMP_Installer.sh +fi + +# Languages +echo "Generating locales" +NL=$'\n' +LANGS="" +LANGSEXEC="if [[ \"\$LANG\" == \"1\" ]]; then" +NUMLANG=1 +for FILE in ./locales/*; do + DAT="$(cat "$FILE" | sed 's/^[[:space:]]*//g' | sed '/^[[:blank:]]*#/d;s/#.*//' | sed '/^[[:blank:]]*$/d')" + OUT="$(echo "$DAT" | tail -n +2)" + LANGNAME="$(echo "$DAT" | head -n +1)" + LANGS="$LANGS \"$NUMLANG\" \"$LANGNAME\"" + if ((NUMLANG > 1)); then + LANGSEXEC="$LANGSEXEC${NL}elif [[ \"\$LANG\" == \"$NUMLANG\" ]]; then" + fi + LANGSEXEC="$LANGSEXEC${NL}$OUT" + NUMLANG=$((NUMLANG+1)) +done +LANGSEXEC="$(echo "$LANGSEXEC${NL}else${NL}echo \"0x1 Unsupported Language\"${NL}exit 1${NL}fi" | sed "s/\\\\/\\\\\\\\/g" | sed "s/\\//\\\\\\//g" | sed "s/\\\$LANG/\\\\\\\$LANG/g")" + +perl -i -pe "s/SETUPLANGS0/$LANGS/" ./BeamMP_Installer.sh +perl -i -pe "s/SETUPLANGS1/$LANGSEXEC/" ./BeamMP_Installer.sh + +# Minify +echo "Cleaning up file" +sed -i '/^[[:blank:]]*#/d;s/#.*//' ./BeamMP_Installer.sh # Remove comments +sed -i 's/^[[:space:]]*//g' ./BeamMP_Installer.sh # Remove whitespace +sed -i '/^[[:blank:]]*$/d' ./BeamMP_Installer.sh # Remove empty lines (ALWAYS USE \n!!) + +# Add binaries +echo "Adding and linking files to script" +echo -e "\nexit" >> ./BeamMP_Installer.sh +LINES0="$(wc -l < ./BeamMP_Installer.sh)" +LINES1="$(wc -l < ../bin/BeamMP-Launcher)" +sed -i "s/+FILELINELENGTH0/+$((LINES0+1))/g" ./BeamMP_Installer.sh +sed -i "s/OUTFILELINELENGTH0/$((LINES1+1))/g" ./BeamMP_Installer.sh +cat ../bin/BeamMP-Launcher >> ./BeamMP_Installer.sh +echo >> ./BeamMP_Installer.sh +LINES0="$(wc -l < ./BeamMP_Installer.sh)" +LINES1="$(wc -l < ./BeamMP.ico)" +sed -i "s/+FILELINELENGTH1/+$((LINES0+1))/g" ./BeamMP_Installer.sh +sed -i "s/OUTFILELINELENGTH1/$((LINES1+1))/g" ./BeamMP_Installer.sh +cat ./BeamMP.ico >> ./BeamMP_Installer.sh +echo >> ./BeamMP_Installer.sh +LINES0="$(wc -l < ./BeamMP_Installer.sh)" +LINES1="$(wc -l < ./BeamMP.desktop)" +sed -i "s/+FILELINELENGTH2/+$((LINES0+1))/g" ./BeamMP_Installer.sh +sed -i "s/OUTFILELINELENGTH2/$((LINES1+1))/g" ./BeamMP_Installer.sh +cat ./BeamMP.desktop >> ./BeamMP_Installer.sh + +# Finish up +echo "Finishing up" +sed -i '1s/^/#!\/usr\/bin\/env bash\n/' ./BeamMP_Installer.sh +chmod u+x ./BeamMP_Installer.sh +mkdir ../bin &>/dev/null +mv ./BeamMP_Installer.sh ../bin diff --git a/data/BeamMP.desktop b/data/BeamMP.desktop new file mode 100644 index 00000000..5a00bfe8 --- /dev/null +++ b/data/BeamMP.desktop @@ -0,0 +1,23 @@ +[Desktop Entry] +Categories=Game; +PrefersNonDefaultGPU=false +Comment[en_US]=Multiplayer for BeamNG.Drive +Comment=Multiplayer for BeamNG.Drive +Exec=SETUPINSTALLLOCATION/BeamMP-Launcher +GenericName[en_US]= +GenericName= +Icon=SETUPINSTALLLOCATION/BeamMP.ico +MimeType= +Name[en_US]=BeamMP +Name=BeamMP +Path=SETUPINSTALLLOCATION +Path= +StartupNotify=true +Terminal=true +TerminalOptions= +Type=Application +X-KDE-SubstituteUID=false +X-KDE-Username= +X-KDE-StartupNotify=false +X-GNOME-AutoRestart=false +X-GNOME-Autostart-enabled=false diff --git a/data/BeamMP.ico b/data/BeamMP.ico new file mode 100644 index 00000000..c087b88d Binary files /dev/null and b/data/BeamMP.ico differ diff --git a/data/installer.sh b/data/installer.sh new file mode 100644 index 00000000..364cee55 --- /dev/null +++ b/data/installer.sh @@ -0,0 +1,238 @@ +#!/bin/bash + +if command -v whiptail &>/dev/null; then + WHIPTAILF="" +else + WHIPTAILF="true" + clear +fi + +if [ -n "$WHIPTAILF" ]; then + while true; do + echo -e "Please enter the number associated with what language you would like use during the installation:\n\n1. English\n" + read -p "> " LANG + case $LANG in + "1") break;; + * ) clear; echo "Please provide a valid answer."; echo "";; + esac + done +else + LANG=$(whiptail --title "BeamMP Installer" --nocancel --notags --menu "Select the language to use during the installation." 0 0 0 SETUPLANGS0 3>&1 1>&2 2>&3) +fi + +SETUPLANGS1 + +if [ -n "$WHIPTAILF" ]; then + while true; do + clear + echo -e "$MENU0\n" + read -p "[$YESBUTTON/$NOBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${YESBUTTON,,}" ) break;; + "${NOBUTTON,,}" ) clear; echo "$REJECT0"; exit 0;; + * ) clear;; + esac + done +else + whiptail --title "$TITLE" --defaultno --yes-button "$ACCEPTBUTTON" --no-button "$REJECTBUTTON" --yesno "$MENU0" 0 0 + if [[ "$?" == "1" ]]; then + echo "$REJECT0" + exit 0 + fi +fi + +STARTMENUSHORT="" +DESKTOPSHORT="" +BINSHORT="" +if [ -n "$WHIPTAILF" ]; then + while true; do + clear + echo -e "$MENU1\n\n$OPTION11\n" + read -p "[$YESBUTTON/$NOBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${YESBUTTON,,}" ) clear; echo -e "$MENU1\n\n$OPTION12\n"; read -e -i "$HOME/.local/share/applications" -p "> " STARTMENUSHORT; break;; + "${NOBUTTON,,}" ) break;; + * ) echo;; + esac + done + while true; do + clear + echo -e "$MENU1\n\n$OPTION21\n" + read -p "[$YESBUTTON/$NOBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${YESBUTTON,,}" ) clear; echo -e "$MENU1\n\n$OPTION22\n"; read -e -i "$HOME/Desktop" -p "> " DESKTOPSHORT; break;; + "${NOBUTTON,,}" ) break;; + * ) echo;; + esac + done + while true; do + clear + echo -e "$MENU1\n\n$OPTION31\n" + read -p "[$YESBUTTON/$NOBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${YESBUTTON,,}" ) clear; echo -e "$MENU1\n\n$OPTION32\n"; read -e -i "$HOME/.local/bin" -p "> " BINSHORT; break;; + "${NOBUTTON,,}" ) break;; + * ) echo;; + esac + done +else + eval EXTRAS=($(whiptail --nocancel --notags --title "$TITLE" --checklist "$MENU1" 0 0 0 "1" "$OPTION11" ON "2" "$OPTION21" OFF "3" "$OPTION31" ON 3>&1 1>&2 2>&3)) + for EXTRA in "${EXTRAS[@]}"; do + if [[ "$EXTRA" == "1" ]]; then + STARTMENUSHORT=$(whiptail --nocancel --title "$TITLE" --inputbox "$OPTION12" 0 0 "$HOME/.local/share/applications" 3>&1 1>&2 2>&3) + fi + if [[ "$EXTRA" == "2" ]]; then + DESKTOPSHORT=$(whiptail --nocancel --title "$TITLE" --inputbox "$OPTION22" 0 0 "$HOME/Desktop" 3>&1 1>&2 2>&3) + fi + if [[ "$EXTRA" == "3" ]]; then + BINSHORT=$(whiptail --nocancel --title "$TITLE" --inputbox "$OPTION32" 0 0 "$HOME/.local/bin" 3>&1 1>&2 2>&3) + fi + done +fi + +if [ -n "$WHIPTAILF" ]; then + clear + echo -e "\n\n$OPTION41\n" + read -e -i "$HOME/.local/share/BeamMP" -p "> " INSTALLLOC + while true; do + clear + echo -e "\n\n$MENU7\n" + read -p "[$CONTINUEBUTTON/$CANCELBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${CONTINUEBUTTON,,}" ) break;; + "${CANCELBUTTON,,}" ) break;; + * ) echo;; + esac + done +else + INSTALLLOC=$(whiptail --nocancel --title "$TITLE" --inputbox "$OPTION41" 0 0 "$HOME/.local/share/BeamMP" 3>&1 1>&2 2>&3) + + whiptail --title "$TITLE" --yes-button "$CONTINUEBUTTON" --no-button "$CANCELBUTTON" --yesno "$MENU7" 0 0 + if [[ "$?" == "1" ]]; then + echo "$REJECT0" + exit 0 + fi +fi + +# libc.so.6, libgcc_s.so.1, libm.so.6, libstdc++.so.6, + +if command -v ldconfig > /dev/null; then +SETUPLIBREQUEST + if [ -n "$LIBREQUEST" ]; then + if [ -n "$WHIPTAILF" ]; then + clear + echo -e "$MENU41 $LIBREQUEST $MENU42\n" + read -p "[$CONTINUEBUTTON/$CANCELBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${CONTINUEBUTTON,,}" ) break;; + "${CANCELBUTTON,,}" ) clear; echo "0x2 Potentially Unsupported"; exit 2;; + * ) clear;; + esac + else + whiptail --title "$TITLE" --defaultno --yes-button "$CONTINUEBUTTON" --no-button "$CANCELBUTTON" --yesno "$MENU41 $LIBREQUEST $MENU42" 0 0 + if [[ "$?" == "1" ]]; then + echo "0x2 Potentially Unsupported" + exit 2 + fi + fi + fi +else + whiptail --title "$TITLE" --defaultno --yes-button "$CONTINUEBUTTON" --no-button "$CANCELBUTTON" --yesno "$MENU2" 0 0 + if [[ "$?" == "1" ]]; then + echo "0x2 Potentially Unsupported" + exit 2 + fi +fi + +ECHOCOMMAND="true" + +DOECHO() { + if [ -n "$ECHOCOMMAND" ]; then + echo $@ + fi +} + +DOLINK() { + ln -s $1 $2 &>/dev/null + if [[ ! -L "$2" || ! -e "$2" ]]; then + rm $2 &>/dev/null + rm -f $2 &>/dev/null + cp $1 $2 # Backup incase symlinking is broken (Dependent on your filesystem type) + fi +} + +PERFORM_SETUP() { + DOECHO 0 + mkdir -p $INSTALLLOC &>/dev/null + if [ ! -d "$INSTALLLOC" ]; then + echo "0x5 Invalid Install Directory" + exit 5 + fi + rm -f $INSTALLLOC/BeamMP-Launcher &>/dev/null + rm -f $INSTALLLOC/BeamMP.ico &>/dev/null + DOECHO 5 + touch $INSTALLLOC/BeamMP-Launcher + cat "$0" | tail -n +FILELINELENGTH0 | head -n OUTFILELINELENGTH0 > $INSTALLLOC/BeamMP-Launcher + chmod +x $INSTALLLOC/BeamMP-Launcher &>/dev/null + DOECHO 35 + touch $INSTALLLOC/BeamMP.ico + cat "$0" | tail -n +FILELINELENGTH1 | head -n OUTFILELINELENGTH1 > $INSTALLLOC/BeamMP.ico + DOECHO 65 + touch $INSTALLLOC/BeamMP.desktop + cat "$0" | tail -n +FILELINELENGTH2 | head -n OUTFILELINELENGTH2 > $INSTALLLOC/BeamMP.desktop + sed -i "s/SETUPINSTALLLOCATION/$(echo "$INSTALLLOC" | sed "s/\\//\\\\\\//g")/g" $INSTALLLOC/BeamMP.desktop + DOECHO 95 + if [ -n "$BINSHORT" ]; then + rm $BINSHORT/BeamMP-Launcher &>/dev/null + DOLINK $INSTALLLOC/BeamMP-Launcher $BINSHORT/BeamMP-Launcher + chmod +x $BINSHORT/BeamMP-Launcher + fi + if [ -n "$DESKTOPSHORT" ]; then + rm $DESKTOPSHORT/BeamMP.desktop &>/dev/null + cp $INSTALLLOC/BeamMP.desktop $DESKTOPSHORT/BeamMP.desktop # Common practice to cp, not link + fi + if [ -n "$STARTMENUSHORT" ]; then + rm $STARTMENUSHORT/BeamMP.desktop &>/dev/null + DOLINK $INSTALLLOC/BeamMP.desktop $STARTMENUSHORT/BeamMP.desktop + if command -v update-desktop-database >/dev/null; then + update-desktop-database $STARTMENUSHORT + fi + fi + DOECHO 100 +} + +if [ -n "$WHIPTAILF" ]; then + clear + echo "$MENU5..." + echocommand="" + PERFORM_SETUP + echo "Finished installing BeamMP" +else + { + PERFORM_SETUP + } | whiptail --title "$TITLE" --gauge "$MENU5..." 0 0 0 +fi + +if [ -n "$WHIPTAILF" ]; then + while true; do + clear + echo -e "$MENU6\n" + read -p "$OPTION51 [$YESBUTTON/$NOBUTTON]> " RESPONSE + case "${RESPONSE,,}" in + "${YESBUTTON,,}" ) cd $INSTALLLOC; "$INSTALLLOC/BeamMP-Launcher"; exit $?; break;; + "${NOBUTTON,,}" ) echo "$REJECT0"; break;; + * ) clear;; + esac + done +else + eval DONES=($(whiptail --nocancel --notags --title "$TITLE" --checklist "$MENU6" 0 0 0 "1" "$OPTION51" ON 3>&1 1>&2 2>&3)) + for DONE in "${DONES[@]}"; do + if [[ "$DONE" == "1" ]]; then + cd $INSTALLLOC + "$INSTALLLOC/BeamMP-Launcher" + exit $? + else + echo "$REJECT0" + fi + done +fi diff --git a/data/locales/en.lang b/data/locales/en.lang new file mode 100644 index 00000000..e70e3677 --- /dev/null +++ b/data/locales/en.lang @@ -0,0 +1,28 @@ +English + +TITLE="BeamMP Installer" +CHECKING="Checking" +CONTINUEBUTTON="Continue" +ACCEPTBUTTON="Accept" +REJECTBUTTON="Reject" +YESBUTTON="Yes" +NOBUTTON="No" +CANCELBUTTON="Cancel" +MENU0="Please read the following License Agreement. You must accept the terms of this agreement before continuing with the installation.\n\nCopyright (C) 2026 BeamMP Ltd., BeamMP team and contributors.\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.\nYou should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/agpl-3.0.html." +REJECT0="Goodbye!" +MENU1="What additional tasks should be performed?" +OPTION11="Create a start menu shortcut" +OPTION12="Please choose a .desktop location for your start menu." +OPTION21="Create a desktop shortcut" +OPTION22="Please choose a .desktop location for your desktop." +OPTION31="Create a local bin link" +OPTION32="Please choose a bin location." +OPTION41="Where should BeamMP be installed?" +OPTION51="Run BeamMP Launcher" +MENU2="Unfortunately, your distribution is not supported\nWe can still install a binary.\nIf your system is based on gcc, then there is a 99% chance this package will work.\nHowever, we cannot guarantee it will work if you choose to install." +MENU3="Checking for packages" +MENU41="It appears you do not have libraries:\n\n" +MENU42="\n\nIf you would like to continue, please select continue.\nHowever, we cannot guarantee that BeamMP will work." +MENU5="Installing BeamMP" +MENU6="Successfully installed BeamMP! Setup is finished." +MENU7="Last chance, would you like to continue with the BeamMP installation?" \ No newline at end of file