BlueGit

timfa filemanager

refactor(install): centralize system dependency lists

timfa Tim Falken · pushed by timfa

Authored 2026-05-16 · 6 months ago

Hash
fd6d48535b6e1a6e38bdb4b0c7f258e5c8ea2442
Parent
836e41eb
2 files changed +13 −12
.github/technical-reference.md +2 −2
@@ -259,8 +259,8 @@
259 259 - .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
260 260
261 261 ## installsystemdservice.sh
262 - maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`), asks whether to install them, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
263 - install_with_package_manager(pm) - Runs package-manager-specific install commands for filemanager system dependencies.
262 - maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`, `ffprobe`) from a single command list, asks whether to install dependencies, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
263 - install_with_package_manager(pm) - Runs package-manager-specific install commands using the central `REQUIRED_PACKAGES` list so dependency updates only need one edit.
264 264
265 265 ## tests/auth.routes.test.js
266 266 - session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
@@ -259,8 +259,8 @@
259- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
259- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
260
260
261## installsystemdservice.sh
261## installsystemdservice.sh
262- maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`), asks whether to install them, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
262- maybe_install_system_dependencies() - Detects missing runtime tools (`node`, `npm`, `git`, `ffmpeg`, `ffprobe`) from a single command list, asks whether to install dependencies, then tries supported package managers (`apt-get`, `apt`, `dnf`, `yum`, `pacman`, `zypper`, `apk`) with warning logs for unavailable or failing managers.
263- install_with_package_manager(pm) - Runs package-manager-specific install commands for filemanager system dependencies.
263- install_with_package_manager(pm) - Runs package-manager-specific install commands using the central `REQUIRED_PACKAGES` list so dependency updates only need one edit.
264
264
265## tests/auth.routes.test.js
265## tests/auth.routes.test.js
266- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
266- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
installsystemdservice.sh +11 −10
@@ -12,7 +12,8 @@ fi
12 12 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 13 SERVICE_NAME="filemanager"
14 14 SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
15 REQUIRED_COMMANDS=(node npm git ffmpeg)
15 REQUIRED_PACKAGES=(nodejs npm git ffmpeg)
16 REQUIRED_COMMANDS=(node npm git ffmpeg ffprobe)
16 17 KNOWN_PACKAGE_MANAGERS=(apt-get apt dnf yum pacman zypper apk)
17 18
18 19 # Resolve the user who owns the project directory (i.e. the user who cloned it,
@@ -60,25 +61,25 @@ install_with_package_manager() {
60 61
61 62 case "$pm" in
62 63 apt-get)
63 apt-get update && apt-get install -y nodejs npm git ffmpeg
64 apt-get update && apt-get install -y "${REQUIRED_PACKAGES[@]}"
64 65 ;;
65 66 apt)
66 apt update && apt install -y nodejs npm git ffmpeg
67 apt update && apt install -y "${REQUIRED_PACKAGES[@]}"
67 68 ;;
68 69 dnf)
69 dnf install -y nodejs npm git ffmpeg
70 dnf install -y "${REQUIRED_PACKAGES[@]}"
70 71 ;;
71 72 yum)
72 yum install -y nodejs npm git ffmpeg
73 yum install -y "${REQUIRED_PACKAGES[@]}"
73 74 ;;
74 75 pacman)
75 pacman -Sy --noconfirm nodejs npm git ffmpeg
76 pacman -Sy --noconfirm "${REQUIRED_PACKAGES[@]}"
76 77 ;;
77 78 zypper)
78 zypper --non-interactive install --no-confirm nodejs npm git ffmpeg
79 zypper --non-interactive install --no-confirm "${REQUIRED_PACKAGES[@]}"
79 80 ;;
80 81 apk)
81 apk add --no-cache nodejs npm git ffmpeg
82 apk add --no-cache "${REQUIRED_PACKAGES[@]}"
82 83 ;;
83 84 *)
84 85 log_warn "Unsupported package manager: $pm"
@@ -112,7 +113,7 @@ maybe_install_system_dependencies() {
112 113 done
113 114
114 115 if [[ "${#available_package_managers[@]}" -eq 0 ]]; then
115 log_warn "Could not find a supported package manager. Install dependencies manually: nodejs, npm, git, ffmpeg."
116 log_warn "Could not find a supported package manager. Install dependencies manually: ${REQUIRED_PACKAGES[*]} (commands needed: ${REQUIRED_COMMANDS[*]})."
116 117 return 0
117 118 fi
118 119
@@ -125,7 +126,7 @@ maybe_install_system_dependencies() {
125 126 log_warn "Dependency installation via '$pm' failed."
126 127 done
127 128
128 log_warn "All package manager installation attempts failed. Install dependencies manually: nodejs, npm, git, ffmpeg."
129 log_warn "All package manager installation attempts failed. Install dependencies manually: ${REQUIRED_PACKAGES[*]} (commands needed: ${REQUIRED_COMMANDS[*]})."
129 130 }
130 131
131 132 maybe_install_system_dependencies
@@ -12,7 +12,8 @@ fi
12SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13SERVICE_NAME="filemanager"
13SERVICE_NAME="filemanager"
14SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
14SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
15REQUIRED_COMMANDS=(node npm git ffmpeg)
15REQUIRED_PACKAGES=(nodejs npm git ffmpeg)
16REQUIRED_COMMANDS=(node npm git ffmpeg ffprobe)
16KNOWN_PACKAGE_MANAGERS=(apt-get apt dnf yum pacman zypper apk)
17KNOWN_PACKAGE_MANAGERS=(apt-get apt dnf yum pacman zypper apk)
17
18
18# Resolve the user who owns the project directory (i.e. the user who cloned it,
19# Resolve the user who owns the project directory (i.e. the user who cloned it,
@@ -60,25 +61,25 @@ install_with_package_manager() {
60
61
61 case "$pm" in
62 case "$pm" in
62 apt-get)
63 apt-get)
63 apt-get update && apt-get install -y nodejs npm git ffmpeg
64 apt-get update && apt-get install -y "${REQUIRED_PACKAGES[@]}"
64 ;;
65 ;;
65 apt)
66 apt)
66 apt update && apt install -y nodejs npm git ffmpeg
67 apt update && apt install -y "${REQUIRED_PACKAGES[@]}"
67 ;;
68 ;;
68 dnf)
69 dnf)
69 dnf install -y nodejs npm git ffmpeg
70 dnf install -y "${REQUIRED_PACKAGES[@]}"
70 ;;
71 ;;
71 yum)
72 yum)
72 yum install -y nodejs npm git ffmpeg
73 yum install -y "${REQUIRED_PACKAGES[@]}"
73 ;;
74 ;;
74 pacman)
75 pacman)
75 pacman -Sy --noconfirm nodejs npm git ffmpeg
76 pacman -Sy --noconfirm "${REQUIRED_PACKAGES[@]}"
76 ;;
77 ;;
77 zypper)
78 zypper)
78 zypper --non-interactive install --no-confirm nodejs npm git ffmpeg
79 zypper --non-interactive install --no-confirm "${REQUIRED_PACKAGES[@]}"
79 ;;
80 ;;
80 apk)
81 apk)
81 apk add --no-cache nodejs npm git ffmpeg
82 apk add --no-cache "${REQUIRED_PACKAGES[@]}"
82 ;;
83 ;;
83 *)
84 *)
84 log_warn "Unsupported package manager: $pm"
85 log_warn "Unsupported package manager: $pm"
@@ -112,7 +113,7 @@ maybe_install_system_dependencies() {
112 done
113 done
113
114
114 if [[ "${#available_package_managers[@]}" -eq 0 ]]; then
115 if [[ "${#available_package_managers[@]}" -eq 0 ]]; then
115 log_warn "Could not find a supported package manager. Install dependencies manually: nodejs, npm, git, ffmpeg."
116 log_warn "Could not find a supported package manager. Install dependencies manually: ${REQUIRED_PACKAGES[*]} (commands needed: ${REQUIRED_COMMANDS[*]})."
116 return 0
117 return 0
117 fi
118 fi
118
119
@@ -125,7 +126,7 @@ maybe_install_system_dependencies() {
125 log_warn "Dependency installation via '$pm' failed."
126 log_warn "Dependency installation via '$pm' failed."
126 done
127 done
127
128
128 log_warn "All package manager installation attempts failed. Install dependencies manually: nodejs, npm, git, ffmpeg."
129 log_warn "All package manager installation attempts failed. Install dependencies manually: ${REQUIRED_PACKAGES[*]} (commands needed: ${REQUIRED_COMMANDS[*]})."
129}
130}
130
131
131maybe_install_system_dependencies
132maybe_install_system_dependencies