Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux HexGL installer. #65

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Unless specified in the file, HexGL's code and resources are now licensed under
chromium index.html

To use full size textures, swap the two textures/ and textures.full/ directories.
## Installation Linux

Run 'hexgl_installer.run' in the terminal.
chmod +x hexgl_installer.run
$ ./hexgl_installer.run
### Building for linux


I have added makeself build ability.
Cut the files in the root of the repo besides for the installer into /hexgl-makeself/hexgl_files
Then fork makeself and use makeself.sh with this command:
'makeself.sh hexgl-makeself hexgl_installer.run' "HexGL Installer" ./installer.sh
Then it should work.

## Note

Expand Down
1 change: 1 addition & 0 deletions hexgl-makeself/formakeself
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions hexgl-makeself/hexgl_files/HexGL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start the HTTP server in the background
python3 -m http.server &

# Wait for a moment to ensure the server starts
sleep 2

# Open the index.html file in the default system browser
xdg-open http://localhost:8000/index.html

1 change: 1 addition & 0 deletions hexgl-makeself/hexgl_files/how_i_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
makeself.sh hexgl hexgl_installer.run "HexGL Installer" ./installer.sh
143 changes: 143 additions & 0 deletions hexgl-makeself/installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

###For_makeself.
###All_credit besides this script and the game goes to makeself.
###The game is made by BKcore
###The installer.sh is made by 12Tae12

# Prompt user to choose GUI or terminal mode
echo "Do you want to use a graphical (GUI) installer? (requires Zenity)"
echo "Type Y to use GUI or N for a text-based installation."
read -r gui_choice

if [[ "$gui_choice" == "Y" || "$gui_choice" == "y" ]]; then
use_gui=true
else
use_gui=false
fi

# Check if Zenity is installed, and if not, warn and offer to install it
if [ "$use_gui" = true ]; then
if ! command -v zenity &> /dev/null; then
echo "Warning: Zenity is not installed. A GUI installer requires Zenity."
read -p "Do you want to install Zenity? (Y/N): " install_choice
if [[ "$install_choice" == "Y" || "$install_choice" == "y" ]]; then
# Detect the distribution and install Zenity accordingly
if [ -f /etc/debian_version ]; then
echo "Detected Debian-based system. Installing Zenity using apt..."
sudo apt update && sudo apt install -y zenity
elif [ -f /etc/arch-release ]; then
echo "Detected Arch-based system. Installing Zenity using pacman..."
sudo pacman -Sy zenity --noconfirm
elif [ -f /etc/fedora-release ]; then
echo "Detected Fedora-based system. Installing Zenity using dnf..."
sudo dnf install -y zenity
elif [ -f /etc/SuSE-release ] || [ -f /etc/SUSE-brand ]; then
echo "Detected SUSE-based system. Installing Zenity using zypper..."
sudo zypper install -y zenity
else
echo "Could not detect your distribution automatically."
echo "Please install Zenity manually, then re-run this script."
exit 1
fi
else
echo "Zenity is required for GUI mode. Exiting."
exit 1
fi
fi
fi

if [ "$use_gui" = true ]; then
# GUI mode
zenity --info --title="HexGL Installer" --text="Welcome to the HexGL installer!"
if ! zenity --question --title="Install HexGL" --text="Do you want to install HexGL?" --ok-label="Yes" --cancel-label="No"; then
zenity --info --title="HexGL Installer" --text="Installation cancelled."
exit 0
fi
else
# Terminal mode
echo 'Hello! This is the easy HexGL Linux game installer!'
echo 'Press Y and enter to install HexGL or press N and enter to quit.'

# Read user input
read -r choice

# Check if the user wants to install or quit
if [[ "$choice" != "Y" && "$choice" != "y" ]]; then
echo "Quitting the installer."
exit 0
fi
fi

# Define the target directory
TARGET_DIR="/opt/BKcore/HexGL"

if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="Installing HexGL..."
else
echo "Installing HexGL..."
fi

# Check if the target directory exists; if not, create it
if [ ! -d "$TARGET_DIR" ]; then
if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="Creating directory $TARGET_DIR..."
else
echo "Directory $TARGET_DIR does not exist. Creating it now."
fi
sudo mkdir -p "$TARGET_DIR"
sudo chown $USER:$USER "$TARGET_DIR"
else
if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="Directory $TARGET_DIR already exists."
else
echo "Directory $TARGET_DIR already exists."
fi
fi

# Define the source directory (the folder you want to cut/move)
SOURCE_DIR="./hexgl_files"

# Move the source directory to the target directory
if [ -d "$SOURCE_DIR" ]; then
if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="Moving $SOURCE_DIR to $TARGET_DIR..."
else
echo "Moving $SOURCE_DIR to $TARGET_DIR..."
fi
sudo mv "$SOURCE_DIR" "$TARGET_DIR"
if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="Moved successfully."
else
echo "Moved successfully."
fi
else
if [ "$use_gui" = true ]; then
zenity --error --title="HexGL Installer" --text="Source directory $SOURCE_DIR does not exist. Please check the path."
else
echo "Source directory $SOURCE_DIR does not exist. Please check the path."
fi
exit 1
fi

# Define the desktop entry content
desktop_entry="[Desktop Entry]
Name=HexGL
Comment=Futuristic racing game
Exec=/opt/BKcore/HexGL/hexgl_files/HexGL.sh
Terminal=false
Type=Application
Categories=Game;ArcadeGame;"

# Create the .desktop file
echo "$desktop_entry" > ~/.local/share/applications/hexgl.desktop

# Make the .desktop file executable
chmod +x ~/.local/share/applications/hexgl.desktop

if [ "$use_gui" = true ]; then
zenity --info --title="HexGL Installer" --text="HexGL desktop entry created successfully!"
else
echo "HexGL desktop entry created successfully!"
fi

Loading