Skip to content

Commit 1083206

Browse files
authored
Warn when install dir is missing from PATH
1 parent 5a2eaa1 commit 1083206

2 files changed

Lines changed: 4 additions & 76 deletions

File tree

scripts/install.sh

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ INSTALL_DIR="/usr/local/bin"
1818
CONFIG_DIR="/etc/aks-flex-node"
1919
DATA_DIR="/var/lib/aks-flex-node"
2020
LOG_DIR="/var/log/aks-flex-node"
21-
PATH_PROFILE="/etc/profile.d/aks-flex-node-path.sh"
2221
GITHUB_API="https://api.github.com/repos/${REPO}"
2322
GITHUB_RELEASES="${GITHUB_API}/releases"
2423
ASSUME_YES=false
@@ -256,69 +255,11 @@ install_binary() {
256255
log_success "Binary installed to $INSTALL_DIR/aks-flex-node"
257256
}
258257

259-
path_update_script() {
260-
local install_dir="$1"
261-
262-
printf '%s\n' \
263-
'# Surrounding PATH with colons lets case matching guard against partial directory names,' \
264-
'# such as treating /usr/local/binary as a match for /usr/local/bin.' \
265-
'case ":${PATH:-}:" in' \
266-
" *:\"$install_dir\":*) ;;" \
267-
" *) export PATH=\"$install_dir\${PATH:+:\$PATH}\" ;;" \
268-
'esac'
269-
}
270-
271-
configure_install_dir_path() {
272-
local install_dir install_dir_was_in_path profile_dir
273-
install_dir="$INSTALL_DIR"
274-
profile_dir=$(dirname "$PATH_PROFILE")
275-
install_dir_was_in_path=false
276-
277-
case ":${PATH:-}:" in
278-
*:"$install_dir":*) install_dir_was_in_path=true ;;
279-
esac
280-
281-
if ! mkdir -p "$profile_dir"; then
282-
log_error "Failed to create PATH profile directory: $profile_dir"
283-
return 1
284-
fi
285-
286-
local expected_profile
287-
expected_profile=$(path_update_script "$install_dir")
288-
if ! printf '%s\n' "$expected_profile" > "$PATH_PROFILE"; then
289-
log_error "Failed to write PATH profile to: $PATH_PROFILE. Check permissions and available disk space."
290-
return 1
291-
fi
292-
293-
if ! printf '%s\n' "$expected_profile" | cmp -s - "$PATH_PROFILE"; then
294-
log_error "Content verification failed for PATH profile: $PATH_PROFILE. The written content does not match the expected content."
295-
return 1
296-
fi
297-
298-
if ! chmod 644 "$PATH_PROFILE"; then
299-
log_error "Failed to set permissions on PATH profile: $PATH_PROFILE"
300-
return 1
301-
fi
302-
303-
# Source only after verifying the profile so this session uses the same logic as future shells.
304-
if ! . "$PATH_PROFILE"; then
305-
log_error "Failed to source PATH profile: $PATH_PROFILE. The profile may contain shell syntax errors."
306-
return 1
307-
fi
308-
258+
warn_install_dir_not_in_path() {
309259
case ":${PATH:-}:" in
310-
*:"$install_dir":*)
311-
if ! $install_dir_was_in_path; then
312-
log_info "Added $install_dir to PATH for this installer session"
313-
fi
314-
;;
315-
*)
316-
log_error "Failed to add $install_dir to PATH after sourcing $PATH_PROFILE. The profile may be incompatible with the current shell or PATH may be read-only."
317-
return 1
318-
;;
260+
*:"$INSTALL_DIR":*) ;;
261+
*) log_warning "$INSTALL_DIR is not in PATH; add it to PATH to run aks-flex-node without the full path." ;;
319262
esac
320-
321-
log_success "Configured $INSTALL_DIR in PATH for future shell sessions"
322263
}
323264

324265
install_azure_cli_deb() {
@@ -621,7 +562,7 @@ main() {
621562

622563
# Install binary
623564
install_binary "$binary_path"
624-
configure_install_dir_path
565+
warn_install_dir_not_in_path
625566

626567
# Setup service components
627568
install_azure_cli

scripts/uninstall.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ DATA_DIR="/var/lib/aks-flex-node"
1818
LOG_DIR="/var/log/aks-flex-node"
1919
SERVICE_UNIT="aks-flex-node-agent.service"
2020
SERVICE_UNIT_PATH="/etc/systemd/system/$SERVICE_UNIT"
21-
PATH_PROFILE="/etc/profile.d/aks-flex-node-path.sh"
2221
SKIP_AZCLI="${SKIP_AZCLI:-false}"
2322

2423
# Functions
@@ -62,7 +61,6 @@ confirm_uninstall() {
6261
echo "• Configuration directory ($CONFIG_DIR)"
6362
echo "• Data directory ($DATA_DIR)"
6463
echo "• Log directory ($LOG_DIR)"
65-
echo "• PATH configuration ($PATH_PROFILE)"
6664
echo "• Host network state created by unbounded-net"
6765
echo "• Azure CLI"
6866
echo ""
@@ -165,15 +163,6 @@ remove_binary() {
165163
fi
166164
}
167165

168-
remove_path_profile() {
169-
if [[ -f "$PATH_PROFILE" ]]; then
170-
rm -f "$PATH_PROFILE"
171-
log_success "Removed PATH configuration: $PATH_PROFILE"
172-
else
173-
log_info "PATH configuration not found: $PATH_PROFILE"
174-
fi
175-
}
176-
177166
remove_azure_cli() {
178167
if [[ "$SKIP_AZCLI" == "true" || "$SKIP_AZCLI" == "1" ]]; then
179168
log_info "Skipping Azure CLI removal (SKIP_AZCLI=$SKIP_AZCLI)"
@@ -219,7 +208,6 @@ show_completion_message() {
219208
echo "✅ Service user and permissions"
220209
echo "✅ Configuration and data directories"
221210
echo "✅ Log files"
222-
echo "✅ PATH configuration"
223211
echo "✅ Host network state"
224212
echo "✅ Azure CLI"
225213
echo ""
@@ -245,7 +233,6 @@ main() {
245233
run_reset
246234
remove_directories
247235
remove_binary
248-
remove_path_profile
249236
remove_azure_cli
250237

251238
# Show completion message

0 commit comments

Comments
 (0)