-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup_cache.sh
More file actions
executable file
·75 lines (61 loc) · 2.6 KB
/
Copy pathsetup_cache.sh
File metadata and controls
executable file
·75 lines (61 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# LEDMatrix Cache Setup Script
# This script sets up a persistent cache directory for LEDMatrix
# with proper group permissions for shared access between services
echo "Setting up LEDMatrix persistent cache directory..."
# Create the cache directory
sudo mkdir -p /var/cache/ledmatrix
# Create ledmatrix group if it doesn't exist
if ! getent group ledmatrix > /dev/null 2>&1; then
sudo groupadd ledmatrix
echo "Created ledmatrix group"
else
echo "ledmatrix group already exists"
fi
# Get the real user (not root when running with sudo)
REAL_USER=${SUDO_USER:-$USER}
# Add current user to ledmatrix group
sudo usermod -a -G ledmatrix "$REAL_USER"
echo "Added $REAL_USER to ledmatrix group"
# Add daemon user to ledmatrix group (for main LEDMatrix service)
if id daemon > /dev/null 2>&1; then
sudo usermod -a -G ledmatrix daemon
echo "Added daemon user to ledmatrix group"
fi
# Set group ownership to ledmatrix
sudo chown -R :ledmatrix /var/cache/ledmatrix
# Set directory permissions: 775 (rwxrwxr-x) with setgid bit so new files inherit group
sudo find /var/cache/ledmatrix -type d -exec chmod 775 {} \;
sudo chmod g+s /var/cache/ledmatrix
# Set file permissions: 660 (rw-rw----) for group-readable cache files
sudo find /var/cache/ledmatrix -type f -exec chmod 660 {} \;
echo ""
echo "Cache directory created: /var/cache/ledmatrix"
echo "Group ownership: ledmatrix"
echo "Permissions: 775 with setgid (group-writable, new files inherit group)"
# Test if the directory is writable by the current user
if [ -w /var/cache/ledmatrix ]; then
echo "✓ Cache directory is writable by current user ($REAL_USER)"
else
echo "✗ Cache directory is not writable by current user"
echo " Note: You may need to log out and back in for group changes to take effect"
fi
# Test if the directory is writable by daemon user (which the system runs as)
if id daemon > /dev/null 2>&1; then
if sudo -u daemon test -w /var/cache/ledmatrix; then
echo "✓ Cache directory is writable by daemon user"
else
echo "✗ Cache directory is not writable by daemon user"
echo " This might cause issues when running with sudo"
fi
fi
echo ""
echo "Setup complete! LEDMatrix will now use persistent caching."
echo "The cache will survive system restarts."
echo ""
echo "IMPORTANT: If you just added yourself to the ledmatrix group,"
echo "you may need to log out and back in (or run 'newgrp ledmatrix')"
echo "for the group membership to take effect."
echo ""
echo "If you see warnings about using temporary cache directory,"
echo "the system will automatically fall back to /tmp/ledmatrix_cache/"