67 lines
2 KiB
Bash
67 lines
2 KiB
Bash
#!/usr/bin/env bash
|
|
# PLWL installer — bundled inside the release tarball (build/PLWL-<version>.tar.gz).
|
|
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/bin/olcxja.plwl"
|
|
APP_DIR="$HOME/.local/share/applications"
|
|
ICON_BASE="$HOME/.local/share/icons/hicolor"
|
|
ICON_SRC="$SCRIPT_DIR/olcxja.plwl.png"
|
|
EXE="$INSTALL_DIR/olcxja.plwl/olcxja.plwl"
|
|
|
|
if [ "$SCRIPT_DIR" = "$INSTALL_DIR" ] || [ "$SCRIPT_DIR" = "$HOME" ] || [ "$SCRIPT_DIR" = "/" ]; then
|
|
echo "install.sh: refusing to run from '$SCRIPT_DIR'" >&2
|
|
exit 1
|
|
fi
|
|
case "$INSTALL_DIR/" in
|
|
"$SCRIPT_DIR"/*)
|
|
echo "install.sh: refusing to install into the extraction folder ('$SCRIPT_DIR')" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
[ -f "$SCRIPT_DIR/olcxja.plwl/olcxja.plwl" ] || { echo "install.sh: olcxja.plwl runtime not found in $SCRIPT_DIR" >&2; exit 1; }
|
|
|
|
echo "1. Copying files..."
|
|
mkdir -p "$INSTALL_DIR" "$APP_DIR"
|
|
cp -r "$SCRIPT_DIR/." "$INSTALL_DIR/"
|
|
|
|
echo "2. Installing icon..."
|
|
if [ -f "$ICON_SRC" ]; then
|
|
for dir in 16x16 32x32 48x48 256x256; do
|
|
mkdir -p "$ICON_BASE/$dir/apps"
|
|
cp "$ICON_SRC" "$ICON_BASE/$dir/apps/olcxja.plwl.png"
|
|
done
|
|
fi
|
|
|
|
echo "3. Creating shortcut..."
|
|
cat > "$APP_DIR/olcxja.plwl.desktop" << EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=PLWL
|
|
Comment=Portable Linux Wine Launcher
|
|
Exec="$EXE"
|
|
Icon=olcxja.plwl
|
|
Terminal=false
|
|
Categories=Game;
|
|
EOF
|
|
chmod +x "$APP_DIR/olcxja.plwl.desktop"
|
|
|
|
echo "4. Adding executable permissions..."
|
|
chmod +x "$EXE"
|
|
|
|
echo "5. Cleaning installation..."
|
|
rm -f "$INSTALL_DIR/install.sh" "$INSTALL_DIR/createshortcut.sh"
|
|
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
|
|
|
|
echo "6. Installation completed. Cleaning up and launching..."
|
|
rm -rf "${SCRIPT_DIR:?}"/*
|
|
nohup "$EXE" >/dev/null 2>&1 &
|
|
disown 2>/dev/null || true
|
|
|
|
exit 0
|