Add before-remove script for package uninstallation and streamline after-remove script
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good

Introduce a new before-remove.sh script to stop and disable the farmcontrol-server service before package removal. Update after-remove.sh to only reload systemd, simplifying the uninstallation process. Modify build-linux-packages.sh to include the new before-remove script in the packaging process.
This commit is contained in:
Tom Butcher 2026-07-26 22:56:42 +01:00
parent 2e95075d3e
commit 997b374e0e
5 changed files with 18 additions and 12 deletions

View File

@ -1,11 +1,4 @@
#!/bin/bash
# Stop the service
systemctl stop farmcontrol-server.service
# Disable the service
systemctl disable farmcontrol-server.service
# Reload systemd
systemctl daemon-reload
# Reload systemd after unit file removal
systemctl daemon-reload 2>/dev/null || true

View File

@ -0,0 +1,6 @@
#!/bin/bash
# Stop and disable before package files (including the unit file) are removed
systemctl stop farmcontrol-server.service 2>/dev/null || true
systemctl disable farmcontrol-server.service 2>/dev/null || true
systemctl daemon-reload 2>/dev/null || true

View File

@ -12,6 +12,7 @@ common_fpm_args=(
-p "${output_dir}/"
-v "${version}"
--after-install packaging/linux/after-install.sh
--before-remove packaging/linux/before-remove.sh
--after-remove packaging/linux/after-remove.sh
"${binary}=/usr/bin/farmcontrol-server"
packaging/linux/farmcontrol-server.service=/lib/systemd/system/farmcontrol-server.service

View File

@ -9,8 +9,10 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const isPackaged = __dirname.includes("app.asar");
const NODE_ENV =
process.env.NODE_ENV || (isPackaged ? "production" : "development");
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = "production";
}
const NODE_ENV = process.env.NODE_ENV;
// Configure paths
function getProductionConfigPath() {

View File

@ -1,11 +1,15 @@
import axios from "axios";
import { loadConfig } from "./config.js";
import axios from "axios";
import log4js from "log4js";
import { createElectronWindow } from "./electron/window.js";
import { setupIPC } from "./electron/ipc.js";
import { LOCAL_SERVER_PORT, LocalServer } from "./localserver/localserver.js";
import { SocketClient } from "./socket/socketclient.js";
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = "production";
}
// Load configuration
const config = loadConfig();