Omni Plugins

Create and use plugins with Omni

OmniStream supports a limited set of plugins that, if they exist, will be called before or after specific processes.

What are Omni plugins?

Omni plugins are scripts that run at the beginning or end of the up, down, sync, backup, or update processes. They can be any executable (be sure to define the language with a header like #!/bin/bash, #!/bin/python or #!/bin/perl etc.).

Currently the following commands are supported (for an up-to-date list, refer to the Readme file inside the plugins folder):

  • up-start

  • up-end

  • down-start

  • down-end

  • sync-start

  • sync-end

  • backup-start

  • backup-end

  • update-start

  • update-end

Your custom scripts will not be replaced or removed when OmniStream is updated. Make sure you place them in the ~/OmniStream/plugins folder.

How to use plugins

The possibilities are endless and your imagination is the sky, but here are a few examples of how to use the plugin feature.

Running automatic app updates

OmniStream can keep your system up to date with the command update.

You can run it as often as you like, and it will run all the standard sudo apt-get update etc. commands, as well as keep your Rclone installation up to date.

But what if you have an app that you would like to include in this command? Here's where the plugin comes handy.

Create a file named update-end with (for example) the content:

#!/bin/bash


# Update the PlexTraktSync app to latest version

pipx upgrade plextraktsync

sudo systemctl restart plextraktsync.service

Now, every time you update your system with the command update, it will finish with the above script.

Syncing files to another service

Here's an example of a script that you might find useful. It syncs the optimized Plex folder in your cloud service to your local mount in OmniStream. Adapt as you see fit!

#!/bin/bash


if pidof -o %PPID -x "$(basename $0)"; then

echo Already running!

exit 1

fi


source ~/.config/omnistream.conf


# Sync options

OPTIONS="-P --exclude .inProgress/**"

SYNCFROM="${MEDIA}/Optimized"

SYNCTO="${UNSYNCED}/Media/Offline/"


# Make sure dir exists

mkdir -p ${SYNCTO}


# Sync Command

/usr/bin/rclone sync ${OPTIONS} ${SYNCFROM} ${SYNCTO}

Name the script sync-start to run before the Turbosync process, or sync-end to run it afterwards.

Backing up specific files

Omni backs up up your entire home directory, including all your Omni containers. But what if you have a custom directory that you would like to include in the backup?

Before running the backup

Here is an example of such a script, named backup-start. Before the actual backups begin, this first clears out excessive logs, creates a backup of the /opt folder and puts that in the home directory so that the OmniStream backup includes it:

#!/bin/bash


# Clearing logs

rm ~/OmniStream/logs/*.log> /dev/null 2>&1


# Backing up System files

sudo tar -cpf ~/system.tar.gz \

--use-compress-program=pigz \

--exclude=.cache \

/opt > /dev/null 2>&1


sudo chown ${USERID}:${GROUPID} ~/system.tar.gz

After the backup has finished, the file that was generated with the “backup-start” script will be removed.

After running the backup

Create a file named backup-end to clean up the local copy of the backup:

#!/bin/bash


# Clearing local copy of system backup

rm ~/system.tar.gz

Hope these few examples give you some idea of the endless possibilities that the plugin system offers!

Any questions?

Feel free to open a support request on GitHub!