DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-01-19 22:43:36

manager2
Member
Registered: 2010-01-13
Posts: 8

unpacker script - need to modify, help needed.

Hi

I found this script to unrar downloaded files.  it is really handy and convenient to use.  however I would like to modify this script so it would not unpack files to directories they located but a certain directory (mnt/HD_a2/SHARED).  Im using "vi" command to change this script but kind of stuck at the moment as Im not sure what lines to leave unchanged.


i understand that "unpack" directory need to be changed and/or the part where unrar directory is mentioned...


if you can point me out how to proceed, i would be most grateful.

script is here: 

#!/bin/sh
##############################################################################
# ---[ unpacker.sh ] ---
# script to look for rar files inside a specific directory.
# if found, unrar them
# w 10/29/08 horto
##############################################################################
DLDIR=/mnt/HD_a2/media
LOG=/mnt/HD_a2/logs/unpack.log
UNRAR=/ffp/bin/unrar

# quick and dirty check to make sure no active downloads.
# because we don't want to unrar/delete files that may be actively downloading!
if [ `/ffp/bin/transmission-remote -l | wc -l` -gt 1 ]; then
  # stop, because a download is active.
  exit 0
 
else
  # continue; because there are no active downloads.
  # check incoming DLDIR
  for FILE in `find $DLDIR -name "*.rar"`; do
    if [ "$FILE" != "*.rar" ]; then
      # shell-fu to extract to path containing the rar
      FILENAME=`expr //$FILE : '.*/\(.*\)'`
      UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g`
      echo [`date`] Extracting "$FILE" ... >> $LOG
     
      # unrar file to the directory its sitting in
      $UNRAR x -y "$FILE" "$UNPACKDIR" >> /dev/null 2>&1
      echo [`date`]   ... done extracting. >> $LOG
     
      # cleanup - remove the rar file(s)
      # note: match .rar, .r01, .r02 ... etc
      echo [`date`] Removing "$FILENAME and rar files." >> $LOG
      for j in `find $UNPACKDIR -name "*.r??"`; do
        rm $j
      done
    fi
  done

Offline

 

#2 2010-01-24 00:26:36

kramed
Member
Registered: 2009-06-02
Posts: 34

Re: unpacker script - need to modify, help needed.

I have written a similar script to automatically scan a folder and extract any archives that have not been extracted previously. I am still testing it (and it works) but should have something released in the next few days.

Offline

 

#3 2010-01-25 14:18:39

gasman
Member
From: Swansea,UK
Registered: 2009-06-23
Posts: 94

Re: unpacker script - need to modify, help needed.

I would comment out the UNPACKDIR statement in the loop

UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g`

and create the variable UNPACKDIR in the initialisation part of the script after

UNRAR=/ffp/bin/unrar

with

UNPACKDIR=mnt/HD_a2/SHARED

You might have a problem if a file with the same name exists (bit like setup.exe in windows when unzipping).

I'm not a Linux person either, so you might want to wait for a more informed opinion. :-)


DNS-323 FW 1.08 (05/15/2009) HW:B1
2 * Seagate    ST3500630AS (500GB)  Fun_plug 0.5
DNS-323 FW 1.08  (12/18/2009) HW:B1
2 * Hitachi    HDS5C3020ALA632 (2TB)  Fun_plug 0.5

Offline

 

#4 2010-01-26 01:24:33

manager2
Member
Registered: 2010-01-13
Posts: 8

Re: unpacker script - need to modify, help needed.

thanks gasman.
unpacker works.

only thing that "cleanup" part is not functional.

so I changed line in here:

      echo [`date`] Removing "$FILENAME and rar files." >> $LOG
      for j in `find $UNPACKDIR -name "*.r??"`; do
        rm $j

... changed  "$UNPACKDIR"  to "$DLDIR"   and it seems to work now.

just tried with downloaded files. it unpacked file to specified folder "mnt/HD_a2/SHARED" and then deleted .rar files that was unpacked. 

so at the moment it'll work as needed!   smile

thanks again.

Offline

 

#5 2010-01-26 13:56:18

gasman
Member
From: Swansea,UK
Registered: 2009-06-23
Posts: 94

Re: unpacker script - need to modify, help needed.

Oops, sorry, missed the cleanup part. I *thought* that the rar files would remain in the DLDIR directory.

I did say I was not a linux person. :-)


DNS-323 FW 1.08 (05/15/2009) HW:B1
2 * Seagate    ST3500630AS (500GB)  Fun_plug 0.5
DNS-323 FW 1.08  (12/18/2009) HW:B1
2 * Hitachi    HDS5C3020ALA632 (2TB)  Fun_plug 0.5

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB