Auto-sync: 20260113-015009

This commit is contained in:
Hutson
2026-01-13 01:50:10 -05:00
parent 1abd618b52
commit f234fe96cb
2 changed files with 166 additions and 0 deletions

View File

@@ -455,6 +455,58 @@ ssh docker-host2 'tail -f ~/crafty/data/servers/hutworld/logs/latest.log'
## Troubleshooting
### Plugin Permission Issues (IMPORTANT)
**Root Cause**: Crafty Docker container requires all files to be owned by `<user>:root` (not `<user>:<user>`) for permissions to work correctly.
**Permanent Fix**:
```bash
# Fix all permissions immediately
ssh docker-host2 'sudo chown -R hutson:root ~/crafty/data/servers/ && \
sudo find ~/crafty/data/servers/ -type d -exec chmod 2775 {} \; && \
sudo find ~/crafty/data/servers/ -type f -exec chmod 664 {} \;'
```
**Prevention**:
1. **Always upload plugins through Crafty web UI** - this ensures correct permissions
2. **Or use the import directory**: Copy to `~/crafty/data/import/` then restart container
3. **Never directly copy files** to the servers directory
**Check for permission issues**:
```bash
# Use the permission check script (recommended)
ssh docker-host2 '~/check-crafty-permissions.sh'
# Or manually check for wrong group ownership
ssh docker-host2 'find ~/crafty/data/servers -type f ! -group root -ls'
ssh docker-host2 'find ~/crafty/data/servers -type d ! -group root -ls'
```
**Permission Check Script**: Located at `~/check-crafty-permissions.sh` on docker-host2
- Automatically detects permission issues
- Offers to fix them with one command
- Ignores temporary files that are expected to have different permissions
### Crafty Shows Server Offline or "Another Instance Running"
**Cause**: This happens when the server was started manually (not through Crafty) or when Crafty loses track of the server process.
**Fix**:
```bash
# 1. Kill any orphaned server processes
ssh docker-host2 'docker exec crafty pkill -f "paper.jar"'
# 2. Restart Crafty container to clear state
ssh docker-host2 'cd ~/crafty && docker compose restart'
# 3. Wait 30-60 seconds - Crafty will auto-start the server
```
**Prevention**:
- Always use Crafty web UI to start/stop servers
- Never manually start the server with java command
- If you must restart, use the container restart method above
### Server won't start
```bash

View File

@@ -0,0 +1,114 @@
#!/bin/bash
# Crafty Permission Checker Script
# Checks for permission issues that could break plugin functionality
echo "Crafty Permission Check - $(date)"
echo "================================"
# Base directory
CRAFTY_DIR="/home/hutson/crafty/data/servers"
# Check if running on docker-host2
if [ "$(hostname)" != "docker-host2" ]; then
echo "⚠️ This script should be run on docker-host2"
echo " Use: ssh docker-host2 '~/check-crafty-permissions.sh'"
exit 1
fi
# Function to check permissions
check_permissions() {
local issues_found=0
# Check for files not owned by root group
echo -e "\n📁 Checking file ownership..."
wrong_group=$(find "$CRAFTY_DIR" -type f ! -group root 2>/dev/null)
if [ ! -z "$wrong_group" ]; then
echo "❌ Files with incorrect group (should be 'root'):"
echo "$wrong_group" | head -10
issues_found=$((issues_found + 1))
else
echo "✅ All files have correct group ownership (root)"
fi
# Check for directories not owned by root group
echo -e "\n📁 Checking directory ownership..."
wrong_dir_group=$(find "$CRAFTY_DIR" -type d ! -group root 2>/dev/null)
if [ ! -z "$wrong_dir_group" ]; then
echo "❌ Directories with incorrect group (should be 'root'):"
echo "$wrong_dir_group" | head -10
issues_found=$((issues_found + 1))
else
echo "✅ All directories have correct group ownership (root)"
fi
# Check for directories without setgid bit
echo -e "\n🔒 Checking setgid bit on directories..."
no_setgid=$(find "$CRAFTY_DIR" -type d ! -perm -g+s 2>/dev/null)
if [ ! -z "$no_setgid" ]; then
echo "⚠️ Directories without setgid bit (may cause future issues):"
echo "$no_setgid" | head -10
issues_found=$((issues_found + 1))
else
echo "✅ All directories have setgid bit set"
fi
# Check for files that crafty user can't read (excluding temp files)
echo -e "\n📖 Checking read permissions..."
unreadable=$(find "$CRAFTY_DIR" -type f ! -perm -g+r ! -name "*.tmp" 2>/dev/null)
if [ ! -z "$unreadable" ]; then
echo "❌ Files that crafty user can't read:"
echo "$unreadable" | head -10
issues_found=$((issues_found + 1))
else
echo "✅ All files are readable by crafty user"
fi
return $issues_found
}
# Function to fix permissions
fix_permissions() {
echo -e "\n🔧 Fixing permissions..."
# Fix ownership
sudo chown -R hutson:root "$CRAFTY_DIR"
# Fix directory permissions (2775 = rwxrwsr-x)
sudo find "$CRAFTY_DIR" -type d -exec chmod 2775 {} \;
# Fix file permissions (664 = rw-rw-r--)
sudo find "$CRAFTY_DIR" -type f -exec chmod 664 {} \;
echo "✅ Permissions fixed!"
}
# Main execution
echo "Checking Crafty server permissions..."
check_permissions
result=$?
if [ $result -gt 0 ]; then
echo -e "\n⚠ Found $result permission issue(s)!"
echo -n "Would you like to fix them automatically? (y/n): "
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
fix_permissions
echo -e "\n🔄 Re-checking permissions..."
check_permissions
if [ $? -eq 0 ]; then
echo -e "\n✅ All permission issues resolved!"
else
echo -e "\n❌ Some issues remain. You may need to restart the Crafty container."
fi
else
echo -e "\nTo fix manually, run:"
echo "sudo chown -R hutson:root $CRAFTY_DIR"
echo "sudo find $CRAFTY_DIR -type d -exec chmod 2775 {} \;"
echo "sudo find $CRAFTY_DIR -type f -exec chmod 664 {} \;"
fi
else
echo -e "\n✅ No permission issues found!"
fi
echo -e "\n================================"
echo "Check complete - $(date)"