add installer to build package

This commit is contained in:
olcxja 2026-09-25 20:38:23 +02:00
commit ada55faf13
88 changed files with 10828 additions and 25 deletions

45
tools/install.sh Normal file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
# PLWL installer — bundled inside the release tarball (build/PLWL-<version>.tar.gz).
# Modeled after LarpixClient's install.sh: copies the app into ~/.local,
# registers a desktop shortcut and removes the extraction folder.
set -e
echo "WARNING: Make sure you don't run this script in a folder that contains anything more than PLWL"
echo "otherwise it may result in data loss"
read -r -p "Press Enter to continue (or Ctrl+C, to cancel)..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="$HOME/.local/lib/PLWL"
BIN_DIR="$HOME/.local/bin"
APP_DIR="$HOME/.local/share/applications"
if [ "$SCRIPT_DIR" = "$INSTALL_DIR" ] || [ "$SCRIPT_DIR" = "$HOME" ] || [ "$SCRIPT_DIR" = "/" ]; then
echo "install.sh: refusing to run from '$SCRIPT_DIR'" >&2
exit 1
fi
echo "1. Copying files..."
mkdir -p "$INSTALL_DIR" "$BIN_DIR" "$APP_DIR"
cp -r "$SCRIPT_DIR/." "$INSTALL_DIR/"
echo "2. Creating shortcut..."
sed -i "s|^Exec=.*|Exec=$BIN_DIR/plwl|" "$INSTALL_DIR/plwl.desktop"
mv "$INSTALL_DIR/plwl.desktop" "$APP_DIR/plwl.desktop"
chmod +x "$APP_DIR/plwl.desktop"
echo "3. Adding executable permissions..."
chmod +x "$INSTALL_DIR/plwl"
ln -sfn "$INSTALL_DIR/plwl" "$BIN_DIR/plwl"
echo "4. Cleaning installation..."
rm -f "$INSTALL_DIR/install.sh"
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
echo "5. Installation completed. Cleaning up and launching..."
rm -rf "${SCRIPT_DIR:?}"/*
nohup "$BIN_DIR/plwl" >/dev/null 2>&1 &
disown 2>/dev/null || true
exit 0