Synology Reindex script UPNP (synoindex)

Come up with a useful post-processing script? Share it here!
Post Reply
thunder1979
Newbie
Newbie
Posts: 1
Joined: May 22nd, 2012, 6:15 am

Synology Reindex script UPNP (synoindex)

Post by thunder1979 »

I had some problems with my Synology diskstation. When I downloaded new files I had to do a manual re-index and that costed me over an hour everytime because of the amount of mediafiles that had to reindex.

I created a post process script for SABNZBD that scans for the files that are created 7 days ago and add's only those files to the index.

To use -ctime you have to instal findutils on your diskstation. -mtime is already there, but -mtime is not handy when downloading older mediafiles.

start.sh

Code: Select all

#!/bin/sh
/volume1/SABNZBD/SABnzbd/scripts/index.sh 2>&1 | tee /volume1/SABNZBD/SABnzbd/scripts/logs/logje

index.sh

Code: Select all

#!/bin/sh
set -x on
date
rm /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/video/ -ctime -7 -iname "*.mpg" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/video/ -ctime -7 -iname "*.mp4" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/video/ -ctime -7 -iname "*.mkv" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/video/ -ctime -7 -iname "*.avi" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/video/ -ctime -7 -iname "*.mov" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/music/ -ctime -7 -iname "*.mp3" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/music/ -ctime -7 -iname "*.wav" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/photo/ -ctime -7 -iname "*.jpg" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/photo/ -ctime -7 -iname "*.gif" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
find /volume1/photo/ -ctime -7 -iname "*.bmp" >> /volume1/SABNZBD/SABnzbd/scripts/logs/new
chmod 777 -R /volume1/SABNZBD/SABnzbd/scripts/logs
chown sabnzbd:users -R /volume1/SABNZBD/SABnzbd/scripts/logs
while read line; do echo -e synoindex -a "'$line'"; done < /volume1/SABNZBD/SABnzbd/scripts/logs/new >> /volume1/SABNZBD/SABnzbd/scripts/process.sh
chmod 777 /volume1/SABNZBD/SABnzbd/scripts/process.sh
chown sabnzbd:users /volume1/SABNZBD/SABnzbd/scripts/process.sh
sh -x /volume1/SABNZBD/SABnzbd/scripts/process.sh
sleep 5
mv /volume1/SABNZBD/SABnzbd/scripts/logs/logje /volume1/SABNZBD/SABnzbd/scripts/logs/backup/logje_`date +"%Y-%m-%d--%H%M%S"`
cp /volume1/SABNZBD/SABnzbd/scripts/logs/new /volume1/SABNZBD/SABnzbd/scripts/logs/backup/new_`date +"%Y-%m-%d--%H%M%S"`
mv /volume1/SABNZBD/SABnzbd/scripts/process.sh /volume1/SABNZBD/SABnzbd/scripts/logs/backup/process_`date +"%Y-%m-%d--%H%M%S"`
set -x off
You have to create the follow folders on your diskstation:
/volume1/SABNZBD/SABnzbd/scripts/
/volume1/SABNZBD/SABnzbd/scripts/logs/
/volume1/SABNZBD/SABnzbd/scripts/logs/backup/

If anyone have some corrections or add-ons don't hesitate!
wsoet
Newbie
Newbie
Posts: 2
Joined: August 14th, 2011, 5:54 am

Re: Synology Reindex script UPNP (synoindex)

Post by wsoet »

I use this index script on my synology

Code: Select all

#!/bin/ash
fullpath=$1

## change owner and usergroep
/bin/chown -R admin:users "$fullpath"

## Remove index if already exist
/usr/syno/bin/synoindex -D "$fullpath"

## Add index to targetfolder
/usr/syno/bin/synoindex -A "$fullpath"

echo Mediaindex successfull at "$fullpath"
Aspergillus
Newbie
Newbie
Posts: 1
Joined: September 27th, 2012, 4:49 pm

Re: Synology Reindex script UPNP (synoindex)

Post by Aspergillus »

1. Create a script
containing the following code:

Code: Select all

#!/bin/sh
#
/usr/syno/bin/synoindex -A "$1"
This script will tell the synology indexing that a new Directory "$1" has to be indexed. $1 contains the directory that sabnzbd stored your downoad in.
So instead of indexin all it only indexes the last added folder.
Save it under for example postdownload.sh

2. Put script somewere where sabnzbd can find it

and tell sabnzbd where you put the script.
Config->folders->Post-Processing Scripts Folder
if you put the script somwhere in your volume1 use absolute path to point to the script directory like for example /volume1/downloads/scripts

3. Make sure sabnzbd knows wich script to run after download
Go to
Config->Categories
and at Default- Script you should see your script (postdownload.sh) in the dropdown. Choose it.

This works as a charm.

Tipp: Make sure you crerated the script in a Unix/Linux enabeled Editor (like PS Pad) and you use Unix Linefeed.

Regards & Good Luck
Aspi
spacewagon
Newbie
Newbie
Posts: 9
Joined: January 2nd, 2014, 6:41 am

Re: Synology Reindex script UPNP (synoindex)

Post by spacewagon »

Aspergillus wrote:1. Create a script
containing the following code:

Code: Select all

#!/bin/sh
#
/usr/syno/bin/synoindex -A "$1"
This script will tell the synology indexing that a new Directory "$1" has to be indexed. $1 contains the directory that sabnzbd stored your downoad in.
So instead of indexin all it only indexes the last added folder.
Save it under for example postdownload.sh

2. Put script somewere where sabnzbd can find it

and tell sabnzbd where you put the script.
Config->folders->Post-Processing Scripts Folder
if you put the script somwhere in your volume1 use absolute path to point to the script directory like for example /volume1/downloads/scripts

3. Make sure sabnzbd knows wich script to run after download
Go to
Config->Categories
and at Default- Script you should see your script (postdownload.sh) in the dropdown. Choose it.

This works as a charm.

Tipp: Make sure you crerated the script in a Unix/Linux enabeled Editor (like PS Pad) and you use Unix Linefeed.

Regards & Good Luck
Aspi
Thanks! It worked... but now: it doesn't. No errors or something, but the index won't update.

I guess this is since I run the new DSM 4.3 version a few weeks.

Someone any idea?
User avatar
LapinFou
Full Member
Full Member
Posts: 100
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Synology Reindex script UPNP (synoindex)

Post by LapinFou »

Maybe You could try to use my scripts ? See my signature.
Even you don't care about character issues, there is an option to move the download files to a destination folder, then to index it.
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache
Post Reply