-
-
Notifications
You must be signed in to change notification settings - Fork 3
How to Use Unraid Service Commands
MrD3y5eL edited this page Jan 12, 2025
·
5 revisions
This document provides examples and usage information for the Unraid integration's service commands.
To specify the entry_id
:
Find the specific entry_id through Home Assistant
- Go to Settings -> Devices & Services -> Unraid
- Click on your device entity
- Click on UNRAID under Device Info
- The URL will show:
/config/integrations/integration/unraid_[entry_id]
- Use the ID after
unraid_
in your service calls
- Example URL:
/config/integrations/integration/unraid#config_entry/1234abcd5678efgh
- Your entry_id would be:
1234abcd5678efgh
The unraid.execute_command
service executes shell commands directly on your Unraid server.
Field | Type | Required | Description |
---|---|---|---|
entry_id | string | Yes | Your Unraid Config Entry ID |
command | string | Yes | The shell command to execute |
# List contents of user share directory
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "ls -l /mnt/user/"
# Check system disk space
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "df -h"
# View last 50 lines of system log
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "tail -n 50 /var/log/syslog"
# Check array status
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "cat /proc/mdstat"
The unraid.execute_in_container
service executes commands inside Docker containers.
Field | Type | Required | Description |
---|---|---|---|
entry_id | string | Yes | Your Unraid Config Entry ID |
container | string | Yes | Docker container name |
command | string | Yes | Command to execute |
detached | boolean | No | Run in detached mode (default: false) |
# Check Plex Media Server logs
service: unraid.execute_in_container
data:
entry_id: "1234abcd5678efgh"
container: "plex"
command: "tail -n 50 /config/Plex Media Server/Logs/Plex Media Server.log"
# Restart Nginx process in container
service: unraid.execute_in_container
data:
entry_id: "1234abcd5678efgh"
container: "nginx"
command: "nginx -s reload"
# Run database backup in background
service: unraid.execute_in_container
data:
entry_id: "1234abcd5678efgh"
container: "mariadb"
command: "mysqldump -u root -p[password] --all-databases > /backup/full-backup.sql"
detached: true
The unraid.execute_user_script
service runs scripts from your Unraid user scripts directory.
Field | Type | Required | Description |
---|---|---|---|
entry_id | string | Yes | Your Unraid Config Entry ID |
script_name | string | Yes | Script filename |
background | boolean | No | Run in background (default: false) |
# Run backup script
service: unraid.execute_user_script
data:
entry_id: "1234abcd5678efgh"
script_name: "backup_appdata.sh"
# Start media organization in background
service: unraid.execute_user_script
data:
entry_id: "1234abcd5678efgh"
script_name: "organize_media.sh"
background: true
# Run maintenance script
service: unraid.execute_user_script
data:
entry_id: "1234abcd5678efgh"
script_name: "monthly_maintenance.sh"
The unraid.stop_user_script
service stops running user scripts.
Field | Type | Required | Description |
---|---|---|---|
entry_id | string | Yes | Your Unraid Config Entry ID |
script_name | string | Yes | Script filename to stop |
# Stop backup script
service: unraid.stop_user_script
data:
entry_id: "1234abcd5678efgh"
script_name: "backup_appdata.sh"
# Stop media organization script
service: unraid.stop_user_script
data:
entry_id: "1234abcd5678efgh"
script_name: "organize_media.sh"
-
Command Injection:
- Validate all user input before using in commands
- Avoid using user-provided input directly in commands
- Use proper escaping when necessary
-
Permissions:
- Ensure user scripts have appropriate permissions
- Don't run commands with unnecessary elevated privileges
- Consider using restricted user accounts for scripts
-
Automation Safety:
- Test commands manually before adding to automations
- Add error handling in your scripts
- Use the
background
option for long-running tasks
-
Monitoring:
- Check Unraid logs for command execution results
- Monitor script execution through Home Assistant's logs
- Set up notifications for script completion/failure
-
Command Fails to Execute:
- Check if the command works directly on Unraid
- Verify SSH connection is working
- Check user permissions
-
Container Commands Fail:
- Ensure container is running
- Verify container name is correct
- Check if command is available in container
-
User Scripts:
- Verify script exists in
/boot/config/plugins/user.scripts/scripts
- Check script permissions (should be executable)
- Test script manually on Unraid first
- Verify script exists in
-
Common Issues:
- Path issues: Use absolute paths in commands
- Permission denied: Check user/script permissions
- Timeout: Use
background: true
for long operations