fix: chemin stable pour AppImage, desktop entry permanent après install initiale
This commit is contained in:
@@ -1,37 +1,46 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Installe (ou met à jour) l'entrée de menu "Farm Tracker" pointant vers l'AppImage déjà construit.
|
# Installation initiale de Farm Tracker (AppImage + entrée de menu).
|
||||||
set -e
|
# À lancer une seule fois. Les mises à jour suivantes sont automatiques.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
APPDIR="/home/shamiiow/GitHub/farm-tracker-app/dist"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
APPIMAGE=$(ls "$APPDIR"/*.AppImage 2>/dev/null | head -n1)
|
DIST_DIR="$SCRIPT_DIR/dist"
|
||||||
|
|
||||||
if [ -z "$APPIMAGE" ]; then
|
# Trouve l'AppImage dans dist/
|
||||||
echo "Aucun fichier .AppImage trouvé dans : $APPDIR"
|
APPIMAGE_SRC=$(ls "$DIST_DIR"/*.AppImage 2>/dev/null | head -n1)
|
||||||
echo "Lance d'abord (depuis le dossier du projet) : npm run dist"
|
if [ -z "$APPIMAGE_SRC" ]; then
|
||||||
|
echo "Aucun .AppImage trouvé dans dist/. Lance d'abord : npm run dist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x "$APPIMAGE"
|
# Chemin stable — indépendant de la version
|
||||||
|
INSTALL_DIR="$HOME/.local/bin"
|
||||||
|
STABLE_PATH="$INSTALL_DIR/farm-tracker.AppImage"
|
||||||
|
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
cp "$APPIMAGE_SRC" "$STABLE_PATH"
|
||||||
|
chmod +x "$STABLE_PATH"
|
||||||
|
|
||||||
|
# Entrée de menu
|
||||||
DESKTOP_DIR="$HOME/.local/share/applications"
|
DESKTOP_DIR="$HOME/.local/share/applications"
|
||||||
mkdir -p "$DESKTOP_DIR"
|
mkdir -p "$DESKTOP_DIR"
|
||||||
DESKTOP_FILE="$DESKTOP_DIR/farm-tracker.desktop"
|
|
||||||
|
|
||||||
cat > "$DESKTOP_FILE" << INNEREOF
|
cat > "$DESKTOP_DIR/farm-tracker.desktop" << EOF
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Farm Tracker
|
Name=Farm Tracker
|
||||||
Comment=Suivi de loot Minecraft en direct
|
Comment=Suivi de loot Minecraft en direct
|
||||||
Exec="$APPIMAGE" %U
|
Exec="$STABLE_PATH" %U
|
||||||
Icon=applications-games
|
Icon=applications-games
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Game;Utility;
|
Categories=Game;Utility;
|
||||||
StartupWMClass=farm-tracker
|
StartupWMClass=farm-tracker
|
||||||
INNEREOF
|
EOF
|
||||||
|
|
||||||
chmod +x "$DESKTOP_FILE"
|
chmod +x "$DESKTOP_DIR/farm-tracker.desktop"
|
||||||
update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true
|
update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
echo "Entrée installée : $DESKTOP_FILE"
|
echo "Installé dans : $STABLE_PATH"
|
||||||
echo "AppImage détecté : $APPIMAGE"
|
echo "Entrée de menu : $DESKTOP_DIR/farm-tracker.desktop"
|
||||||
echo "Cherche \"Farm Tracker\" dans ton menu d'applications (déconnexion/reconnexion parfois nécessaire selon le bureau)."
|
echo ""
|
||||||
|
echo "Les prochaines mises à jour s'installeront automatiquement sans rien retoucher."
|
||||||
|
|||||||
12
main.js
12
main.js
@@ -153,9 +153,15 @@ async function downloadAndInstall(downloadUrl, version) {
|
|||||||
sendUpdateProgress(100, 'installing');
|
sendUpdateProgress(100, 'installing');
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
fs.chmodSync(tmpPath, 0o755);
|
fs.chmodSync(tmpPath, 0o755);
|
||||||
const current = process.env.APPIMAGE;
|
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||||
if (current) { fs.copyFileSync(tmpPath, current); fs.unlinkSync(tmpPath); app.relaunch(); }
|
const target = fs.existsSync(stablePath) ? stablePath : process.env.APPIMAGE;
|
||||||
else app.relaunch({ execPath: tmpPath });
|
if (target) {
|
||||||
|
fs.copyFileSync(tmpPath, target);
|
||||||
|
fs.unlinkSync(tmpPath);
|
||||||
|
app.relaunch({ execPath: target });
|
||||||
|
} else {
|
||||||
|
app.relaunch({ execPath: tmpPath });
|
||||||
|
}
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
} else if (process.platform === 'win32') {
|
} else if (process.platform === 'win32') {
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
|
|||||||
Reference in New Issue
Block a user