fix(install): prompt to install system dependencies
@@ -258,6 +258,10 @@
258
258
- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
259
259
- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
260
260
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.
264
261
265
## tests/auth.routes.test.js
262
266
- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
263
267
- session lifecycle / session expires after 1 hour of inactivity - Verifies server-side idle timeout enforcement.
@@ -258,6 +258,10 @@258
- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
258
- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
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
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.
264
261
## tests/auth.routes.test.js
265
## tests/auth.routes.test.js
262
- 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.
263
- session lifecycle / session expires after 1 hour of inactivity - Verifies server-side idle timeout enforcement.
267
- session lifecycle / session expires after 1 hour of inactivity - Verifies server-side idle timeout enforcement.
@@ -12,6 +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)
16
KNOWN_PACKAGE_MANAGERS=(apt-get apt dnf yum pacman zypper apk)
15
17
16
18
# Resolve the user who owns the project directory (i.e. the user who cloned it,
17
19
# not root). Falls back to the SUDO_USER env var, then 'pi'.
@@ -20,6 +22,114 @@ RUN_AS="${SUDO_USER:-pi}"
20
22
echo "[install] Project directory : $SCRIPT_DIR"
21
23
echo "[install] Service will run as user: $RUN_AS"
22
24
25
log_warn() {
26
echo "[install][warn] $*" >&2
27
}
28
29
collect_missing_commands() {
30
local missing=()
31
local cmd
32
for cmd in "${REQUIRED_COMMANDS[@]}"; do
33
if ! command -v "$cmd" >/dev/null 2>&1; then
34
missing+=("$cmd")
35
fi
36
done
37
printf '%s\n' "${missing[@]}"
38
}
39
40
confirm_dependency_install() {
41
if [[ ! -t 0 ]]; then
42
log_warn "Non-interactive shell detected; skipping optional dependency installation prompt."
43
return 1
44
fi
45
46
local reply
47
read -r -p "[install] Install required system dependencies now? [Y/n] " reply
48
case "${reply,,}" in
49
""|y|yes)
50
return 0
51
;;
52
*)
53
return 1
54
;;
55
esac
56
}
57
58
install_with_package_manager() {
59
local pm="$1"
60
61
case "$pm" in
62
apt-get)
63
apt-get update && apt-get install -y nodejs npm git ffmpeg
64
;;
65
apt)
66
apt update && apt install -y nodejs npm git ffmpeg
67
;;
68
dnf)
69
dnf install -y nodejs npm git ffmpeg
70
;;
71
yum)
72
yum install -y nodejs npm git ffmpeg
73
;;
74
pacman)
75
pacman -Sy --noconfirm nodejs npm git ffmpeg
76
;;
77
zypper)
78
zypper --non-interactive install --no-confirm nodejs npm git ffmpeg
79
;;
80
apk)
81
apk add --no-cache nodejs npm git ffmpeg
82
;;
83
*)
84
log_warn "Unsupported package manager: $pm"
85
return 1
86
;;
87
esac
88
}
89
90
maybe_install_system_dependencies() {
91
mapfile -t missing_commands < <(collect_missing_commands)
92
93
if [[ "${#missing_commands[@]}" -eq 0 ]]; then
94
echo "[install] Required system dependencies already available (${REQUIRED_COMMANDS[*]})."
95
return 0
96
fi
97
98
echo "[install] Missing commands detected: ${missing_commands[*]}"
99
if ! confirm_dependency_install; then
100
echo "[install] Skipping system dependency installation by user choice."
101
return 0
102
fi
103
104
local available_package_managers=()
105
local pm
106
for pm in "${KNOWN_PACKAGE_MANAGERS[@]}"; do
107
if command -v "$pm" >/dev/null 2>&1; then
108
available_package_managers+=("$pm")
109
else
110
log_warn "Known package manager '$pm' not found on this system."
111
fi
112
done
113
114
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
return 0
117
fi
118
119
for pm in "${available_package_managers[@]}"; do
120
echo "[install] Trying dependency installation via '$pm'..."
121
if install_with_package_manager "$pm"; then
122
echo "[install] Dependencies installed successfully via '$pm'."
123
return 0
124
fi
125
log_warn "Dependency installation via '$pm' failed."
126
done
127
128
log_warn "All package manager installation attempts failed. Install dependencies manually: nodejs, npm, git, ffmpeg."
129
}
130
131
maybe_install_system_dependencies
132
23
133
# Make sure start.sh is executable
24
134
chmod +x "$SCRIPT_DIR/start.sh"
25
135
@@ -12,6 +12,8 @@ fi12
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"12
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"13
SERVICE_NAME="filemanager"13
SERVICE_NAME="filemanager"14
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"14
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"15
REQUIRED_COMMANDS=(node npm git ffmpeg)16
KNOWN_PACKAGE_MANAGERS=(apt-get apt dnf yum pacman zypper apk)15
17
16
# Resolve the user who owns the project directory (i.e. the user who cloned it,18
# Resolve the user who owns the project directory (i.e. the user who cloned it,17
# not root). Falls back to the SUDO_USER env var, then 'pi'.19
# not root). Falls back to the SUDO_USER env var, then 'pi'.@@ -20,6 +22,114 @@ RUN_AS="${SUDO_USER:-pi}"20
echo "[install] Project directory : $SCRIPT_DIR"22
echo "[install] Project directory : $SCRIPT_DIR"21
echo "[install] Service will run as user: $RUN_AS"23
echo "[install] Service will run as user: $RUN_AS"22
24
25
log_warn() {26
echo "[install][warn] $*" >&227
}28
29
collect_missing_commands() {30
local missing=()31
local cmd32
for cmd in "${REQUIRED_COMMANDS[@]}"; do33
if ! command -v "$cmd" >/dev/null 2>&1; then34
missing+=("$cmd")35
fi36
done37
printf '%s\n' "${missing[@]}"38
}39
40
confirm_dependency_install() {41
if [[ ! -t 0 ]]; then42
log_warn "Non-interactive shell detected; skipping optional dependency installation prompt."43
return 144
fi45
46
local reply47
read -r -p "[install] Install required system dependencies now? [Y/n] " reply48
case "${reply,,}" in49
""|y|yes)50
return 051
;;52
*)53
return 154
;;55
esac56
}57
58
install_with_package_manager() {59
local pm="$1"60
61
case "$pm" in62
apt-get)63
apt-get update && apt-get install -y nodejs npm git ffmpeg64
;;65
apt)66
apt update && apt install -y nodejs npm git ffmpeg67
;;68
dnf)69
dnf install -y nodejs npm git ffmpeg70
;;71
yum)72
yum install -y nodejs npm git ffmpeg73
;;74
pacman)75
pacman -Sy --noconfirm nodejs npm git ffmpeg76
;;77
zypper)78
zypper --non-interactive install --no-confirm nodejs npm git ffmpeg79
;;80
apk)81
apk add --no-cache nodejs npm git ffmpeg82
;;83
*)84
log_warn "Unsupported package manager: $pm"85
return 186
;;87
esac88
}89
90
maybe_install_system_dependencies() {91
mapfile -t missing_commands < <(collect_missing_commands)92
93
if [[ "${#missing_commands[@]}" -eq 0 ]]; then94
echo "[install] Required system dependencies already available (${REQUIRED_COMMANDS[*]})."95
return 096
fi97
98
echo "[install] Missing commands detected: ${missing_commands[*]}"99
if ! confirm_dependency_install; then100
echo "[install] Skipping system dependency installation by user choice."101
return 0102
fi103
104
local available_package_managers=()105
local pm106
for pm in "${KNOWN_PACKAGE_MANAGERS[@]}"; do107
if command -v "$pm" >/dev/null 2>&1; then108
available_package_managers+=("$pm")109
else110
log_warn "Known package manager '$pm' not found on this system."111
fi112
done113
114
if [[ "${#available_package_managers[@]}" -eq 0 ]]; then115
log_warn "Could not find a supported package manager. Install dependencies manually: nodejs, npm, git, ffmpeg."116
return 0117
fi118
119
for pm in "${available_package_managers[@]}"; do120
echo "[install] Trying dependency installation via '$pm'..."121
if install_with_package_manager "$pm"; then122
echo "[install] Dependencies installed successfully via '$pm'."123
return 0124
fi125
log_warn "Dependency installation via '$pm' failed."126
done127
128
log_warn "All package manager installation attempts failed. Install dependencies manually: nodejs, npm, git, ffmpeg."129
}130
131
maybe_install_system_dependencies132
23
# Make sure start.sh is executable133
# Make sure start.sh is executable24
chmod +x "$SCRIPT_DIR/start.sh"134
chmod +x "$SCRIPT_DIR/start.sh"25
135