Skip to content

Commit 88af669

Browse files
committed
feat: enhance plugin command documentation with full command reference and usage examples
1 parent 44121ed commit 88af669

1 file changed

Lines changed: 153 additions & 7 deletions

File tree

docs/plugin-command.md

Lines changed: 153 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ nav_order: 7
88

99
The `plugin` command is the CLI tool for managing Unraid plugins. It handles installation, updates, removal, and status checks.
1010

11-
{: .placeholder-image }
12-
> 📷 **Screenshot needed:** *Plugin command help output*
13-
>
14-
> ![Plugin command](../assets/images/screenshots/terminal-plugin-help.png)
11+
```
12+
Usage: plugin install PLUGIN-FILE [forced]
13+
plugin remove PLUGIN
14+
plugin check PLUGIN
15+
plugin checkall
16+
plugin update PLUGIN
17+
plugin [attribute name] PLUGIN-FILE
18+
```
1519

1620
## Basic Usage
1721

@@ -254,6 +258,148 @@ echo "Author: $(plugin author $PLG)"
254258

255259
## See Also
256260

257-
- [PLG File Reference](plg-file.md)
258-
- [Packaging](packaging.md)
259-
- [Troubleshooting](troubleshooting.md)
261+
- [PLG File Reference](plg-file)
262+
- [Build and Packaging](build-and-packaging)
263+
264+
## Full Command Reference
265+
266+
<details markdown="block">
267+
<summary>Complete <code>plugin</code> command help output</summary>
268+
269+
```
270+
Process plugin files.
271+
272+
Usage: plugin install PLUGIN-FILE [forced]
273+
install a plugin
274+
275+
PLUGIN-FILE is a plugin definition XML file with ".plg" extension.
276+
277+
PLUGIN-FILE can be a local file, or a URL. If a URL, the plugin file is first downloaded to /tmp/plugins.
278+
279+
forced is optional and can be used to install a lower version than currently running.
280+
281+
This command will process all FILE elements in PLUGIN-FILE which are tagged with the "install" method (or
282+
that have no method tag).
283+
284+
This command has two major use cases:
285+
286+
1) Invoked at system startup by /etc/rc.d/rc.local on each .plg file found int /boot/config/plugins.
287+
288+
Upon success we register the plugin as "installed" by creating a symlink to it in /var/log/plugins.
289+
290+
If any kind of error, we move the file to /boot/config/plugins-error.
291+
292+
If a symlink already exists for the plugin file, this indicates a plugin replacing a "built-in" plugin. In
293+
this case, if the version of PLUGIN-FILE is newer than the built-in plugin, we go ahead and install normally;
294+
otherwise, we move to /boot/config/plugins-stale.
295+
296+
2) Invoked manually or via Plugin Manager for a .plg file not in /boot/config/plugins.
297+
298+
If a symlink already exists for the plugin file, this indicates a plugin update. In this case, if the version of
299+
PLUGIN-FILE is newer than the built-in plugin, we go ahead and install normally and then move the old plugin
300+
to /boot/config/plugins-stale.
301+
302+
Upon success we copy PLUGIN-FILE to /boot/config/plugins and register it as "installed" by creating a
303+
symlink to it in /var/log/plugins.
304+
305+
Usage: plugin remove PLUGIN
306+
remove a plugin
307+
308+
PLUGIN is the file basename of a plugin, e.g., "myplugin.plg".
309+
310+
If PLUGIN is found in /var/log/plugins then this command will process all FILE elements in PLUGIN which are
311+
tagged with the "remove" method. Upon success we delete /var/log/plugins/PLUGIN and move the plugin
312+
file to /boot/config/plugins-removed
313+
314+
Usage: plugin check PLUGIN
315+
check and output the latest version of PLUGIN
316+
317+
We extract the pluginURL attribute from PLUGIN and use it to download (presumably the latest
318+
version of) the plugin file to /tmp/plugins/ directory, and then output the version string.
319+
320+
Usage: plugin checkall
321+
check all installed plugins
322+
323+
Runs 'plugin check PLUGIN' for each plugin file linked-to in /var/log/plugins.
324+
325+
Usage: plugin update PLUGIN
326+
update the plugin
327+
328+
We look for the new plugin in /tmp/plugins/ directory. If found then we first execute the "install"
329+
method of each FILE in the new plugin. (If necessary, a plugin can detect that this is an
330+
"update" by checking for the existence of /var/log/plugins/PLUGIN.) If successful, we
331+
delete the "old" plugin file from /boot/config/plugins/, copy the "new" plugin file from
332+
/tmp/plugins/ to /boot/config/plugins/, and finally create the new symlink.
333+
334+
Note: to support `plugin check` and `plugin update` the plugin file must contain both "pluginURL" and
335+
"version" attributes.
336+
337+
Usage: plugin [attribute name] PLUGIN-FILE
338+
339+
Any method which is not one of the actions listed above is assumed to be the name of an attribute of
340+
the <PLUGIN> tag within PLUGIN-FILE. If the attribute exists, its value (a string) is output and the command
341+
exit status is 0. If the attribute does not exist, command exit status is 1.
342+
343+
The plugin manager recognizes this set of attributes for the <PLUGIN> tag:
344+
345+
name - MANDATORY plugin name, e.g., "myplugin" or "my-plugin" etc.
346+
This tag defines the name of the plugin. The name should omit embedded information such as architecture,
347+
version, author, etc.
348+
349+
The plugin should create a directory under `/usr/local/emhttp/plugins` named after
350+
the plugin, e.g., `/usr/local/emhttp/plugins/myplugin`. Any webGui pages, icons, README files, etc, should
351+
be created inside this directory.
352+
353+
The plugin should also create a directory under `/boot/config/plugins` named after the plugin, e.g.,
354+
`/boot/config/plugins/myplugin`. Here is where you store plugin-specific files such as a configuration
355+
file and icon file. Note that this directory exists on the users USB Flash device and writes should be
356+
minimized.
357+
358+
Upon successful installation, the plugin manager will copy the input plugin file to `/boot/config/plugins`
359+
on the users USB Flash device, and create a symlink in `/var/log/plugins` also named after the plugin,
360+
e.g., `/var/log/plugins/myplugin`. Each time the unRaid server is re-booted, all plugins stored
361+
in `/boot/config/plugins` are automatically installed; plugin authors should be aware of this behavior.
362+
363+
author - OPTIONAL
364+
Whatever you put here will show up under the **Author** column in the Plugin List. If this attribute
365+
is omitted we display "anonymous".
366+
367+
version - MANDATORY
368+
Use a string suitable for comparison to determine if one version is older/same/newer than another version.
369+
Any format is acceptable but LimeTech uses "YYYY.MM.DD", e.g., "2014.02.18" (if multiple versions happen
370+
to get posted on the same day we add a letter suffix, e.g., "2014.02.18a").
371+
372+
pluginURL - OPTIONAL but MANDATORY if you want "check for updates" to work with your plugin
373+
This is the URL of the plugin file to download and extract the **version** attribute from to determine if
374+
this is a new version.
375+
376+
More attributes may be defined in the future.
377+
378+
Here is the set of directories and files used by the plugin system:
379+
380+
/boot/config/plugins/
381+
This directory contains the plugin files for plugins to be (re)installed at boot-time. Upon
382+
successful `plugin install`, the plugin file is copied here (if not here already). Upon successful
383+
`plugin remove`, the plugin file is deleted from here.
384+
385+
/boot/config/plugins-error/
386+
This directory contains plugin files that failed to install.
387+
388+
/boot/config/plugins-removed/
389+
This directory contains plugin files that have been removed.
390+
391+
/boot/config/plugins-stale/
392+
This directory contains plugin files that failed to install because a newer version of the same plugin is
393+
already installed.
394+
395+
/tmp/plugins/
396+
This directory is used as a target for downloaded plugin files. The `plugin check` operation
397+
downloads the plugin file here and the `plugin update` operation looks for the plugin to update here.
398+
399+
/var/log/plugins/
400+
This directory contains a symlink named after the plugin name (not the plugin file name) which points to
401+
the actual plugin file used to install the plugin. The existence of this file indicates successful
402+
install of the plugin.
403+
```
404+
405+
</details>

0 commit comments

Comments
 (0)