Skip to content

Commit f338cbc

Browse files
andystimeclaude
andcommitted
fix: improve uninstall script to better handle root directory cleanup
When gpugo is installed as a normal user with GPU_GO_TOKEN (agent mode), the install script runs `sudo ggo agent register` which creates config files in /root/.gpugo. During uninstall, these root directories may not be cleaned up if sudo fails or is unavailable. Improvements: 1. Better error handling for root directory cleanup - Explicitly check if removal succeeded - Capture and report failures 2. Enhanced binary search for unregistration - Search in multiple common locations (not just 2) - Include ~/.local/bin and ~/bin in search path - Show searched paths if binary not found 3. Clear manual cleanup instructions - If root cleanup fails, show warning banner - List exact commands needed for manual cleanup - Help users understand what still needs to be removed 4. More informative messages - Show which directories were successfully removed - Warn about permission issues explicitly This fix addresses user reports of gpugo appearing to be "installed in both root and normal user" after uninstall. The root directories are intentionally created during agent mode install (systemd service runs as root), but now uninstall provides clear guidance when they can't be automatically removed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a05e867 commit f338cbc

1 file changed

Lines changed: 53 additions & 10 deletions

File tree

scripts/uninstall.sh

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,52 @@ remove_config() {
175175
done
176176

177177
# Root config (if running as root or with sudo)
178+
local root_cleanup_failed=false
178179
if [ "$(id -u)" -eq 0 ] || [ -n "$(get_sudo)" ]; then
179180
if [ -d "/root/.config/ggo" ]; then
180-
${SUDO} rm -rf "/root/.config/ggo"
181+
if ${SUDO} rm -rf "/root/.config/ggo" 2>/dev/null; then
182+
info "Removed /root/.config/ggo"
183+
else
184+
warn "Failed to remove /root/.config/ggo (permission denied)"
185+
root_cleanup_failed=true
186+
fi
181187
fi
182188
if [ -d "/root/.gpugo" ]; then
183-
${SUDO} rm -rf "/root/.gpugo"
189+
if ${SUDO} rm -rf "/root/.gpugo" 2>/dev/null; then
190+
info "Removed /root/.gpugo"
191+
else
192+
warn "Failed to remove /root/.gpugo (permission denied)"
193+
root_cleanup_failed=true
194+
fi
195+
fi
196+
else
197+
# Check if root directories exist but we can't remove them
198+
if [ -d "/root/.config/ggo" ] || [ -d "/root/.gpugo" ]; then
199+
warn "Root configuration directories exist but sudo is not available"
200+
root_cleanup_failed=true
184201
fi
185202
fi
186-
203+
187204
info "Configuration directories removed!"
205+
206+
# Warn about manual cleanup if root cleanup failed
207+
if [ "${root_cleanup_failed}" = "true" ]; then
208+
echo ""
209+
warn "==============================================="
210+
warn " MANUAL CLEANUP REQUIRED"
211+
warn "==============================================="
212+
warn "Some configuration directories could not be removed automatically."
213+
warn "Please run the following commands with appropriate permissions:"
214+
warn ""
215+
if [ -d "/root/.config/ggo" ]; then
216+
warn " sudo rm -rf /root/.config/ggo"
217+
fi
218+
if [ -d "/root/.gpugo" ]; then
219+
warn " sudo rm -rf /root/.gpugo"
220+
fi
221+
warn "==============================================="
222+
echo ""
223+
fi
188224
}
189225

190226
# --- Kill running processes ---
@@ -206,17 +242,24 @@ kill_processes() {
206242

207243
# --- Unregister from server ---
208244
unregister_from_server() {
209-
local binary_path="${GGO_INSTALL_DIR:-/usr/local/bin}/${BINARY_NAME}"
210-
if [ ! -f "${binary_path}" ]; then
211-
binary_path="/usr/local/bin/${BINARY_NAME}"
212-
fi
245+
# Search for ggo binary in multiple locations
246+
local binary_path=""
247+
local search_paths="${GGO_INSTALL_DIR:-/usr/local/bin}/${BINARY_NAME} /usr/local/bin/${BINARY_NAME} /usr/bin/${BINARY_NAME} /opt/bin/${BINARY_NAME} ${HOME}/.local/bin/${BINARY_NAME} ${HOME}/bin/${BINARY_NAME}"
248+
249+
for path in ${search_paths}; do
250+
if [ -f "${path}" ] && [ -x "${path}" ]; then
251+
binary_path="${path}"
252+
break
253+
fi
254+
done
213255

214-
if [ ! -f "${binary_path}" ]; then
215-
warn "ggo binary not found, skipping server unregistration"
256+
if [ -z "${binary_path}" ]; then
257+
warn "ggo binary not found in common locations, skipping server unregistration"
258+
warn "Searched: ${search_paths}"
216259
return 0
217260
fi
218261

219-
info "Unregistering agent from server..."
262+
info "Unregistering agent from server (using binary at ${binary_path})..."
220263
if "${binary_path}" agent unregister --force 2>/dev/null; then
221264
info "Agent unregistered from server"
222265
else

0 commit comments

Comments
 (0)