build: add freebsd support (#4049)

This commit is contained in:
David Lane
2025-11-11 23:46:11 -05:00
committed by GitHub
parent 2dbe837ebc
commit 1d6d916b7a
31 changed files with 1055 additions and 39 deletions

View File

@@ -0,0 +1,64 @@
#!/bin/sh
# FreeBSD post-install script for Sunshine
# This script sets up the necessary permissions for virtual input devices
echo "Configuring permissions for virtual input devices..."
# Create the 'input' group if it doesn't exist
if ! pw groupshow input >/dev/null 2>&1; then
echo "Creating 'input' group..."
pw groupadd input
if [ $? -eq 0 ]; then
echo "Successfully created 'input' group."
else
echo "Warning: Failed to create 'input' group. You may need to create it manually."
fi
else
echo "'input' group already exists."
fi
# Set permissions on /dev/uinput if it exists
if [ -e /dev/uinput ]; then
echo "Setting permissions on /dev/uinput..."
chown root:input /dev/uinput
chmod 660 /dev/uinput
echo "Permissions set on /dev/uinput."
else
echo "Note: /dev/uinput does not exist. It will be created when needed."
fi
# Create devfs rules for persistent permissions
echo "Creating devfs rules for persistent permissions..."
DEVFS_RULESET_FILE="/etc/devfs.rules"
RULESET_NUM=47989
# Check if our rules already exist
if ! grep -q "\[sunshine=$RULESET_NUM\]" "$DEVFS_RULESET_FILE" 2>/dev/null; then
cat >> "$DEVFS_RULESET_FILE" << EOF
[sunshine=$RULESET_NUM]
add path 'uinput' mode 0660 group input
EOF
echo "Devfs rules added to $DEVFS_RULESET_FILE"
else
echo "Devfs rules already exist in $DEVFS_RULESET_FILE"
fi
# Apply the devfs ruleset immediately (without waiting for reboot)
echo "Applying devfs ruleset to current system..."
if [ -e /dev/uinput ]; then
devfs -m /dev rule -s $RULESET_NUM apply
fi
echo ""
echo "Post-installation configuration complete!"
echo ""
echo "IMPORTANT: To use virtual input devices (keyboard, mouse, gamepads),"
echo "you must add your user to the 'input' group:"
echo ""
echo " pw groupmod input -m \$USER"
echo ""
echo "After adding yourself to the group, log out and log back in for the"
echo "changes to take effect."
echo ""

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# FreeBSD pre-deinstall script for Sunshine
# This script cleans up configuration added during installation
echo "Cleaning up Sunshine configuration..."
# Remove devfs rules
DEVFS_RULESET_FILE="/etc/devfs.rules"
RULESET_NUM=47989
# Remove rules from /etc/devfs.rules
if [ -f "$DEVFS_RULESET_FILE" ]; then
if grep -q "\[sunshine=$RULESET_NUM\]" "$DEVFS_RULESET_FILE"; then
echo "Removing devfs rules from $DEVFS_RULESET_FILE..."
# Remove the [sunshine=47989] section and its rules (match the section header and the next line)
sed -i.bak '/^\[sunshine='"$RULESET_NUM"'\]$/,/^add path.*uinput/d' "$DEVFS_RULESET_FILE"
echo "Devfs rules removed from file."
fi
fi
echo "Removing devfs ruleset from memory..."
devfs rule -s $RULESET_NUM delset 2>/dev/null || true
# Note: We intentionally do NOT:
# - Remove the 'input' group (other software may use it)
echo "Cleanup complete."
echo ""
echo "NOTE: The 'input' group has not been removed as other software may use it."
echo "If you wish to remove it manually, run: pw groupdel input"
echo ""