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.

Need some help with a script

Featured Replies

I've set up a script to clean .DS_Store files. Got the script from this post

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

 

I've got it installed in /config/plugins/DS_Store-Cleanup/ and run it with a cron entry-

# DS_Store Cleanup for Media:
20 3 * * 1 ./config/plugins/DS_Store-Cleanup/rmdotstore.sh /mnt/user/Media

 

 

I think it's working??? If I create a test file named .DS_Store it will get deleted when running the command via telnet at least. My problem is that I don't get any notifications. Is there something I can modify to have the system send a notification (preferred) or maybe at least have a log entry?

to have something logged, just use

logger This is the log entry I want

to use the notify system in unraid, use this command:

/usr/local/emhttp/plugins/dynamix/scripts/notify

(the options will display if you just enter the command by itself

 

  • Author

Tried changing the script to this-

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && /usr/local/emhttp/plugins/dynamix/scripts/notify [-e "DS_Cleanup"] [-s "DS_Cleanup"] [-i "normal"] [-m "Cleaning DS_Store files from Media"] && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

I don't get an email though. Did I miss something?

 

Also tried running the command from telnet with the same result.

I'm guessing there's a syntax problem but I'm a noob at this so pretty much lost here.

I've never used that style with bash

 

I always use if and fi - makes more sense to me. 

 

Tried changing the script to this-

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && /usr/local/emhttp/plugins/dynamix/scripts/notify [-e "DS_Cleanup"] [-s "DS_Cleanup"] [-i "normal"] [-m "Cleaning DS_Store files from Media"] && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

I don't get an email though. Did I miss something?

 

Also tried running the command from telnet with the same result.

I'm guessing there's a syntax problem but I'm a noob at this so pretty much lost here.

duh... I'm dense.  Remove the braces from within the notify command
  • Author

I've never used that style with bash

 

I always use if and fi - makes more sense to me. 

 

Probably would for me too if I had any idea what I was doing.:D

 

I just added it on to the cron script. Worked great. Thanks

# DS_Store Cleanup for Media:
20 3 * * 1 ./config/plugins/DS_Store-Cleanup/rmdotstore.sh /mnt/user/Media  && /usr/local/emhttp/plugins/dynamix/scripts/notify -e "DS_Cleanup" -d "Removing .DS_Store files" -i "normal" -m "Cleaning DS_Store files from Media"

 

I seem to remember that I need to restart my server for the cron files to load. Is that true?

Not sure how you're doing it.  I've only ever worked with cron thru crontab (and you don't need a restart that way)

But it seems to me that since the remove script doesn't run in the background that you're going to be notified after it runs.  Would probably make more sense to be notified prior to it's start

  • Author

I added a folder to /config/plugins/

 

faty5g.jpg

 

IF I'm understanding what I'm reading on various threads, I just set it up as a simple plugin.

  • Author

You'd still have to get it installed via a plg

Not sure what you mean???

 

 

I added a folder to /config/plugins/

IF I'm understanding what I'm reading on various threads, I just set it up as a simple plugin.

 

Explain what you mean by this then

  • Author

I created a folder in plugins "DS_Store-Cleanup". Inside the folder are 2 text files "rmdotstore.cron" and "rmdotstore.sh".

I had read in the forum that I could run any script this way. All I had to do was model it after any of the plugins already on the flash drive. Wish I could find the thread.

Stole this from your post up above for my little code. Thanks for sharing. ;)

 

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "DS_Cleanup" -d "Removing .DS_Store files" -i "normal" -m "Cleaning DS_Store files from Media"

 

Of course I modified it for my own needs, but I dig the notification.

Archived

This topic is now archived and is closed to further replies.

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.