Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Running Shell and Python Scripts from a CLI

Featured Replies

I'm new to unRAID and to Dockers. I'm trying to run some custom shell script and Python programs and trying to figure out the "right" way to do things... I got some tests to work but I want to make sure I'm not going to cause trouble for myself down the road.

 

I have some scripts that help organize and cleanup my photos so I'll want to be able to run them on a specific folder on a specific share.

 

I'll need to be able to:

 

  • run git and download code from a repository
  • use apt-get to install programs like exiftool
  • install/use pip to install python libs
  • sometimes run the CLI in a remote window so I can leave the process/program running undisturbed
  • sometimes SSH directly into the CLI so I can run things directly on my local computer

 

This sounds like I'd want to setup a Docker for this... I also played around using the CLI accessible from the GUI but I guess that environment is only in RAM because I lose any installs once I reboot.

On 1/25/2020 at 4:51 PM, soong said:

but I guess that environment is only in RAM because I lose any installs once I reboot.

Correct, unRAID unpacks fresh from RAM on every boot. 

 

On 1/25/2020 at 4:51 PM, soong said:
  • use apt-get to install programs like exiftool

Technically speaking this item is the only one on the list that can't be done without using Docker/VM, due to the fact that unRAID does not have apt-get (or any common package manager for that matter).

On 1/25/2020 at 4:51 PM, soong said:

This sounds like I'd want to setup a Docker for this

While this is not the only way to do things it is definitely the one i recommend. I would start by looking on docker hub for a base image of a distro you are most comfortable using, preferably an official image or one from well known maintainer (Python images are available as well).

From there you have a couple of paths. You could pull the image, spin up a container and exec in, install all the extras you want in the container, then commit it to a new image for later use. Alternatively (and my preference) would be to write a Dockerfile that makes the customization to the base image as that will make rebuilding the image with new packages easier. 

Once you have a custom image you can either run your scripts manually from the unRAID CLI or using the user scripts plugin by spinning up a containers with the correct script. Something like

docker run --rm -v /mnt/user/share-or-path-to-files:/path-in-container:rw my-custom-image /script-in-image.py --args-for-script

or if you dont want to bake the script into the image

docker run --rm -v /mnt/user/share-or-path-to-files:/path-in-container:rw  -v /mnt/user/scripts:/scripts:ro my-custom-image /scripts/my-script.py --args-for-script

You will want to look at the docker run -d and -i and -t flags as they can control if the container runs like a daemon or like a script on the console.

 

 

 

 

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.