hotfix for telemetry hotfix for profiles config
This commit is contained in:
+25
-9
@@ -13,9 +13,18 @@ echo "==================================="
|
||||
SOCKTOP_HOME=$(eval echo ~socktop)
|
||||
echo "Socktop HOME: ${SOCKTOP_HOME}"
|
||||
|
||||
# Create necessary directories in the actual HOME
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/socktop/certs"
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/alacritty"
|
||||
# Check if we're running as root
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Running as root, will set permissions"
|
||||
# Create necessary directories in the actual HOME
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/socktop/certs"
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/alacritty"
|
||||
else
|
||||
echo "Running as non-root user ($(id -u)), creating directories without root"
|
||||
# Try to create directories - will work if HOME is writable
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/socktop/certs" 2>/dev/null || echo " ⚠ Could not create directories (may already exist)"
|
||||
mkdir -p "${SOCKTOP_HOME}/.config/alacritty" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Copy files from mounted locations to actual HOME if they exist
|
||||
echo "Copying configuration files..."
|
||||
@@ -56,8 +65,11 @@ else
|
||||
echo " ℹ No certificates directory found (optional)"
|
||||
fi
|
||||
|
||||
# Set proper ownership
|
||||
chown -R socktop:socktop "${SOCKTOP_HOME}/.config"
|
||||
# Set proper ownership (only if running as root)
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
chown -R socktop:socktop "${SOCKTOP_HOME}/.config"
|
||||
echo " ✓ Set ownership to socktop:socktop"
|
||||
fi
|
||||
|
||||
# Fix paths in profiles.json if it exists
|
||||
if [ -f "${SOCKTOP_HOME}/.config/socktop/profiles.json" ]; then
|
||||
@@ -70,7 +82,11 @@ fi
|
||||
echo "==================================="
|
||||
echo "Configuration initialization complete"
|
||||
echo "==================================="
|
||||
echo "Switching to socktop user..."
|
||||
|
||||
# Switch to socktop user and execute the main command
|
||||
exec runuser -u socktop -- "$@"
|
||||
# Switch to socktop user only if running as root
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Switching to socktop user..."
|
||||
exec runuser -u socktop -- "$@"
|
||||
else
|
||||
echo "Already running as non-root user ($(whoami)), continuing..."
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user