mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
update first time install script
This commit is contained in:
@@ -364,6 +364,19 @@ else
|
|||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
CURRENT_STEP="Harden systemd unit file permissions"
|
||||||
|
echo "Step 7.1: Setting systemd unit file permissions..."
|
||||||
|
echo "-----------------------------------------------"
|
||||||
|
for unit in "/etc/systemd/system/ledmatrix.service" "/etc/systemd/system/ledmatrix-web.service"; do
|
||||||
|
if [ -f "$unit" ]; then
|
||||||
|
chown root:root "$unit" || true
|
||||||
|
chmod 644 "$unit" || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
systemctl daemon-reload || true
|
||||||
|
echo "✓ Systemd unit file permissions set"
|
||||||
|
echo ""
|
||||||
|
|
||||||
CURRENT_STEP="Configure web interface permissions"
|
CURRENT_STEP="Configure web interface permissions"
|
||||||
echo "Step 8: Configuring web interface permissions..."
|
echo "Step 8: Configuring web interface permissions..."
|
||||||
echo "------------------------------------------------"
|
echo "------------------------------------------------"
|
||||||
@@ -457,6 +470,27 @@ fi
|
|||||||
echo "✓ File ownership configured"
|
echo "✓ File ownership configured"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
CURRENT_STEP="Normalize project file permissions"
|
||||||
|
echo "Step 10.1: Normalizing project file and directory permissions..."
|
||||||
|
echo "--------------------------------------------------------------"
|
||||||
|
|
||||||
|
# Normalize directory permissions (exclude VCS metadata)
|
||||||
|
find "$PROJECT_ROOT_DIR" -path "*/.git*" -prune -o -type d -exec chmod 755 {} +
|
||||||
|
|
||||||
|
# Set default file permissions
|
||||||
|
find "$PROJECT_ROOT_DIR" -path "*/.git*" -prune -o -type f -exec chmod 644 {} +
|
||||||
|
|
||||||
|
# Ensure shell scripts are executable
|
||||||
|
find "$PROJECT_ROOT_DIR" -path "*/.git*" -prune -o -type f -name "*.sh" -exec chmod 755 {} +
|
||||||
|
|
||||||
|
# Explicitly ensure common helper scripts are executable (in case paths change)
|
||||||
|
chmod 755 "$PROJECT_ROOT_DIR/start_display.sh" "$PROJECT_ROOT_DIR/stop_display.sh" 2>/dev/null || true
|
||||||
|
chmod 755 "$PROJECT_ROOT_DIR/fix_cache_permissions.sh" "$PROJECT_ROOT_DIR/fix_web_permissions.sh" 2>/dev/null || true
|
||||||
|
chmod 755 "$PROJECT_ROOT_DIR/install_service.sh" "$PROJECT_ROOT_DIR/install_web_service.sh" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "✓ Project file permissions normalized"
|
||||||
|
echo ""
|
||||||
|
|
||||||
CURRENT_STEP="Sound module configuration"
|
CURRENT_STEP="Sound module configuration"
|
||||||
echo "Step 11: Sound module configuration..."
|
echo "Step 11: Sound module configuration..."
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
|
|||||||
@@ -6,15 +6,22 @@
|
|||||||
|
|
||||||
echo "Fixing LEDMatrix cache directory permissions..."
|
echo "Fixing LEDMatrix cache directory permissions..."
|
||||||
|
|
||||||
CACHE_DIRS=(
|
|
||||||
"/var/cache/ledmatrix"
|
|
||||||
"/home/ledpi/.ledmatrix_cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the real user (not root when running with sudo)
|
# Get the real user (not root when running with sudo)
|
||||||
REAL_USER=${SUDO_USER:-$USER}
|
REAL_USER=${SUDO_USER:-$USER}
|
||||||
|
# Resolve the home directory of the real user robustly
|
||||||
|
if command -v getent >/dev/null 2>&1; then
|
||||||
|
REAL_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
|
||||||
|
else
|
||||||
|
REAL_HOME=$(eval echo ~"$REAL_USER")
|
||||||
|
fi
|
||||||
REAL_GROUP=$(id -gn "$REAL_USER")
|
REAL_GROUP=$(id -gn "$REAL_USER")
|
||||||
|
|
||||||
|
# Known cache directories for LEDMatrix. Use the actual user's home instead of a hard-coded path.
|
||||||
|
CACHE_DIRS=(
|
||||||
|
"/var/cache/ledmatrix"
|
||||||
|
"$REAL_HOME/.ledmatrix_cache"
|
||||||
|
)
|
||||||
|
|
||||||
for CACHE_DIR in "${CACHE_DIRS[@]}"; do
|
for CACHE_DIR in "${CACHE_DIRS[@]}"; do
|
||||||
echo ""
|
echo ""
|
||||||
echo "Checking cache directory: $CACHE_DIR"
|
echo "Checking cache directory: $CACHE_DIR"
|
||||||
@@ -25,6 +32,7 @@ for CACHE_DIR in "${CACHE_DIRS[@]}"; do
|
|||||||
echo " - Current permissions:"
|
echo " - Current permissions:"
|
||||||
ls -ld "$CACHE_DIR"
|
ls -ld "$CACHE_DIR"
|
||||||
echo " - Fixing permissions..."
|
echo " - Fixing permissions..."
|
||||||
|
# Make directory writable by services regardless of user context
|
||||||
sudo chmod 777 "$CACHE_DIR"
|
sudo chmod 777 "$CACHE_DIR"
|
||||||
sudo chown "$REAL_USER":"$REAL_GROUP" "$CACHE_DIR"
|
sudo chown "$REAL_USER":"$REAL_GROUP" "$CACHE_DIR"
|
||||||
echo " - Updated permissions:"
|
echo " - Updated permissions:"
|
||||||
|
|||||||
Reference in New Issue
Block a user