RAR Unpack in Version 2.92
Re: RAR Unpack in Version 2.92
I checked my log. It is fine.
I did not test script with blank DECOMPRESS_TO_DIR so change it to something like I did.
If it works I will fix script for blank DECOMPRESS_TO_DIR.
I did not test script with blank DECOMPRESS_TO_DIR so change it to something like I did.
If it works I will fix script for blank DECOMPRESS_TO_DIR.
Re: RAR Unpack in Version 2.92
Trasmission app sets these variables for script to use.
That are torrent folder and name.
That are torrent folder and name.
Re: RAR Unpack in Version 2.92
You can not run it manually!!!
You have to download new torrent.
You have to download new torrent.
-
- Posts: 16
- Joined: Wed Nov 30, 2016 1:41 pm
Re: RAR Unpack in Version 2.92
ok, that's probably it. I could not understand how it would work if I ran it manually. I'll have to test it through transmission.
-
- Posts: 16
- Joined: Wed Nov 30, 2016 1:41 pm
Re: RAR Unpack in Version 2.92
Still not working at all. I'm still not sure where TR_TORRENT_DIR is set. Is it looking at the "download-dir" variable in the settings.json file?
Re: RAR Unpack in Version 2.92
No, it is dynamic and related to one torrent job.
You are missing something.
You are missing something.
-
- Posts: 3
- Joined: Sat Jan 21, 2017 7:38 am
Re: RAR Unpack in Version 2.92
I have the same issue... I've pointed the script to the QPKG directory (on mine it's QPKG_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission"), verified the correct files are present in "/usr/bin" and "usr/local/sbin" also changed the settings.json file settings to:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission/bin/unrar_unzip_script.sh",
I also set the "DECOMPRESS_TO_DIR=" to something valid and ensured the script permissions are set to 0755.
No log file is created and nothing is extracted.
Here's the script in full as I have uploaded it to my NAS:
Here's my "settings.json" file with peer port and RPC password censored.
Here's images to show that the files exist in the correct directories:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission/bin/unrar_unzip_script.sh",
I also set the "DECOMPRESS_TO_DIR=" to something valid and ensured the script permissions are set to 0755.
No log file is created and nothing is extracted.
Here's the script in full as I have uploaded it to my NAS:
Code: Select all
#!/bin/sh
set -x
TR_DIR="${TR_TORRENT_DIR}"
TR_NAME="${TR_TORRENT_NAME}"
QPKG_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission"
BIN_DIR="/usr/bin"
FIND_PATH="${BIN_DIR}/find"
LOG_FILE_PATH="${QPKG_DIR}/unpack.log" #PATH to store the log file, blank to disable
UNRAR_TRIGGERS="x -y -o+ -idp" #triggers for unrar operation, use this to control the info logged (see unrar command manual)
UNZIP_TRIGGERS="-o" #same as unrar but for zip.
DECOMPRESS_TO_DIR="/share/CACHEDEV1_DATA/Public/Extracted" #If blank will unpack in its own directory, else will unpack to a fixed directory
ACTION_TIME=$(date +%d-%m-%Y\ %H:%M:%S)
if [ -z $DECOMPRESS_TO_DIR ]; then
DESTINATION_DIR="$TR_DIR/$TR_NAME"
else
DESTINATION_DIR="$DECOMPRESS_TO_DIR"
fi
cd "$TR_DIR"
if [ -d "$TR_NAME" ]; then
cd "$TR_NAME"
IFS=$'\n'
unset RAR_FILES i
FIND_RESULTS=`$FIND_PATH -maxdepth 1 -iname "*.rar"`
for RAR_FILE in $FIND_RESULTS; do
if [[ $RAR_FILE =~ .*part.*.rar ]]; then
if [[ $RAR_FILE =~ .*part0*1.rar ]]; then
RAR_FILES[i++]=$RAR_FILE
fi
else
RAR_FILES[i++]=$RAR_FILE
fi
done
unset IFS
unset FIND_RESULTS
if [ ${#RAR_FILES} -gt 0 ]; then
mkdir -p "$DESTINATION_DIR/$TR_NAME"
for RAR_FILE in "${RAR_FILES[@]}"; do
/usr/local/sbin/unrar $UNRAR_TRIGGERS "$RAR_FILE" "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
done
fi
IFS=$'\n'
FIND_RESULTS=`$FIND_PATH -maxdepth 1 -iname "*.zip"`
for ZIP_FILE in $FIND_RESULTS; do
ZIP_FILES[i++]=$ZIP_FILE
done
if [ ${#ZIP_FILES} -gt 0 ]; then
mkdir -p "$DESTINATION_DIR/$TR_NAME"
for ZIP_FILE in "${ZIP_FILES[@]}"; do
/usr/local/sbin/unzip $UNZIP_TRIGGERS "$ZIP_FILE" -d "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unziping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
done
fi
unset IFS
#in case the torrent is a file
else
#special case when the torrent name contains the archive extension
FILENAME=`${BIN_DIR}/basename "$TR_NAME" .rar`
if [ -f "$FILENAME.rar" ]; then
echo "Special rar archive found ..."
if [ -z "$DECOMPRESS_TO_DIR" ]; then
DESTINATION_DIR="${TR_DIR}/$FILENAME"
else
DESTINATION_DIR="$DECOMPRESS_TO_DIR/$FILENAME"
fi
mkdir -p "$DESTINATION_DIR"
/usr/local/sbin/unrar $UNRAR_TRIGGERS "$FILENAME.rar" "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
else
if [ -f "$TR_NAME.rar" ]; then
mkdir -p "$DESTINATION_DIR"
/usr/local/sbin/unrar $UNRAR_TRIGGERS "$TR_NAME.rar" "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
fi
fi
FILENAME=`${BIN_DIR}/basename "$TR_NAME" .zip`
if [ -f "$FILENAME.zip" ]; then
echo "Special zip archive found ..."
mkdir -p "$DESTINATION_DIR"
/usr/local/sbin/unzip $UNZIP_TRIGGERS "$FILENAME.zip" -d "$DESTINATION_DIR" \ >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unzipping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
else
LIST_ZIP_FILE=`ls "$TR_NAME.zip" 2>/dev/null`
if [ ! -z "$LIST_ZIP_FILE" ]; then
mkdir -p "$DESTINATION_DIR"
/usr/local/sbin/unzip $UNZIP_TRIGGERS "$LIST_ZIP_FILE" -d "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unzipping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
fi
fi
fi
Code: Select all
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": true,
"blocklist-url": "http://list.iblocklist.com/?list=bt_level1",
"cache-size-mb": 2,
"dht-enabled": true,
"download-dir": "/share/Public/Downloads/BitTorrent",
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 0,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/opt/downloads/torrent/incomplete",
"incomplete-dir-enabled": false,
"lpd-enabled": true,
"message-level": 1,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 40,
"peer-limit-per-torrent": 15,
"peer-port": *CENSORED*,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "lowcost",
"pex-enabled": true,
"port-forwarding-enabled": false,
"preallocation": 1,
"prefetch-enabled": false,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-password": "*CENSORED*",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "root",
"rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": false,
"scrape-paused-torrents-enabled": false,
"script-torrent-added-enabled": false,
"script-torrent-added-filename": "",
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission/bin/unrar_unzip_script.sh",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": true,
"umask": 18,
"upload-slots-per-torrent": 14,
"utp-enabled": true,
"watch-dir": "/opt/etc/transmission/watchdir",
"watch-dir-enabled": true
}
-
- Posts: 3
- Joined: Sat Jan 21, 2017 7:38 am
Re: RAR Unpack in Version 2.92
OK, got it to work with Entware-ng on my QNAP NAS.
I pointed the script to the bin folder of Entware-ng, rather than the one in "usr/bin", so it now reads: "BIN_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin".
I also installed the "unrar", "unzip" and "coreutils-basename" packages on Entware instead of using the ones in the "/usr/bin" or "/usr/local/sbin" folders. "Find" was already installed.
In the script, the unrar and unzip packages also have to be pointed to the Entware-ng bin folder, so one example of a command that calls unrar is: "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar $UNRAR_TRIGGERS "$RAR_FILE" "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH.
I also created the log file manually in the location specified by the script and gave it read and write permissions (0666) and I moved the location of the script file itself to "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar_unzip_script.sh", ensuring it still had permissions of "rwxr-xr-x" (0755) and pointed to that in my transmission "settings.json" file instead.
The full script now looks like this:
I pointed the script to the bin folder of Entware-ng, rather than the one in "usr/bin", so it now reads: "BIN_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin".
I also installed the "unrar", "unzip" and "coreutils-basename" packages on Entware instead of using the ones in the "/usr/bin" or "/usr/local/sbin" folders. "Find" was already installed.
In the script, the unrar and unzip packages also have to be pointed to the Entware-ng bin folder, so one example of a command that calls unrar is: "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar $UNRAR_TRIGGERS "$RAR_FILE" "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH.
I also created the log file manually in the location specified by the script and gave it read and write permissions (0666) and I moved the location of the script file itself to "/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar_unzip_script.sh", ensuring it still had permissions of "rwxr-xr-x" (0755) and pointed to that in my transmission "settings.json" file instead.
The full script now looks like this:
Code: Select all
#!/bin/sh
set -x
TR_DIR="${TR_TORRENT_DIR}"
TR_NAME="${TR_TORRENT_NAME}"
QPKG_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/etc/transmission"
BIN_DIR="/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin"
FIND_PATH="${BIN_DIR}/find"
LOG_FILE_PATH="${QPKG_DIR}/unpack.log" #PATH to store the log file, blank to disable
UNRAR_TRIGGERS="x -y -o+ -idp" #triggers for unrar operation, use this to control the info logged (see unrar command manual)
UNZIP_TRIGGERS="-o" #same as unrar but for zip.
DECOMPRESS_TO_DIR="/share/CACHEDEV1_DATA/Public/Extracted" #If blank will unpack in its own directory, else will unpack to a fixed directory
ACTION_TIME=$(date +%d-%m-%Y\ %H:%M:%S)
if [ -z $DECOMPRESS_TO_DIR ]; then
DESTINATION_DIR="$TR_DIR/$TR_NAME"
else
DESTINATION_DIR="$DECOMPRESS_TO_DIR"
fi
cd "$TR_DIR"
if [ -d "$TR_NAME" ]; then
cd "$TR_NAME"
IFS=$'\n'
unset RAR_FILES i
FIND_RESULTS=`$FIND_PATH -maxdepth 1 -iname "*.rar"`
for RAR_FILE in $FIND_RESULTS; do
if [[ $RAR_FILE =~ .*part.*.rar ]]; then
if [[ $RAR_FILE =~ .*part0*1.rar ]]; then
RAR_FILES[i++]=$RAR_FILE
fi
else
RAR_FILES[i++]=$RAR_FILE
fi
done
unset IFS
unset FIND_RESULTS
if [ ${#RAR_FILES} -gt 0 ]; then
mkdir -p "$DESTINATION_DIR/$TR_NAME"
for RAR_FILE in "${RAR_FILES[@]}"; do
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar $UNRAR_TRIGGERS "$RAR_FILE" "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
done
fi
IFS=$'\n'
FIND_RESULTS=`$FIND_PATH -maxdepth 1 -iname "*.zip"`
for ZIP_FILE in $FIND_RESULTS; do
ZIP_FILES[i++]=$ZIP_FILE
done
if [ ${#ZIP_FILES} -gt 0 ]; then
mkdir -p "$DESTINATION_DIR/$TR_NAME"
for ZIP_FILE in "${ZIP_FILES[@]}"; do
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unzip $UNZIP_TRIGGERS "$ZIP_FILE" -d "$DESTINATION_DIR/$TR_NAME" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unziping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
done
fi
unset IFS
#in case the torrent is a file
else
#special case when the torrent name contains the archive extension
FILENAME=`${BIN_DIR}/basename "$TR_NAME" .rar`
if [ -f "$FILENAME.rar" ]; then
echo "Special rar archive found ..."
if [ -z "$DECOMPRESS_TO_DIR" ]; then
DESTINATION_DIR="${TR_DIR}/$FILENAME"
else
DESTINATION_DIR="$DECOMPRESS_TO_DIR/$FILENAME"
fi
mkdir -p "$DESTINATION_DIR"
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar $UNRAR_TRIGGERS "$FILENAME.rar" "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
else
if [ -f "$TR_NAME.rar" ]; then
mkdir -p "$DESTINATION_DIR"
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unrar $UNRAR_TRIGGERS "$TR_NAME.rar" "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unrarring $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unrarred $TR_NAME torrent" >> $LOG_FILE_PATH
fi
fi
fi
FILENAME=`${BIN_DIR}/basename "$TR_NAME" .zip`
if [ -f "$FILENAME.zip" ]; then
echo "Special zip archive found ..."
mkdir -p "$DESTINATION_DIR"
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unzip $UNZIP_TRIGGERS "$FILENAME.zip" -d "$DESTINATION_DIR" \ >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unzipping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
else
LIST_ZIP_FILE=`ls "$TR_NAME.zip" 2>/dev/null`
if [ ! -z "$LIST_ZIP_FILE" ]; then
mkdir -p "$DESTINATION_DIR"
/share/CACHEDEV1_DATA/.qpkg/Entware-ng/bin/unzip $UNZIP_TRIGGERS "$LIST_ZIP_FILE" -d "$DESTINATION_DIR" >> $LOG_FILE_PATH
if [ $? -gt 0 ]; then
echo $ACTION_TIME "Error unzipping $TR_NAME torrent" >> $LOG_FILE_PATH
exit 0
else
echo $ACTION_TIME "Unziped $TR_NAME torrent" >> $LOG_FILE_PATH
fi
fi
fi
fi
-
- Posts: 16
- Joined: Wed Nov 30, 2016 1:41 pm
Re: RAR Unpack in Version 2.92
For anyone still having trouble. I finally got mine working. I installed Unrar 5.1.2 qpkg.
http://www.qnapclub.eu/provider.php/qpk ... 2_x86.qpkg
Hope that helps.
http://www.qnapclub.eu/provider.php/qpk ... 2_x86.qpkg
Hope that helps.
Re: RAR Unpack in Version 2.92
Hi, sorry to revive a relatively old thread, just wanted to say the script works really well on my qnap. But i was wondering if there was a way for the original rar file to remain for seeding, at the moment its unpacking and deleting the original.
Re: RAR Unpack in Version 2.92
Sure, just remove the line removing the torrent. If you want different behavior for different torrents check Unrar and cleanup script. It uses a file "keep" to keep the torrent.bd2000 wrote:Hi, sorry to revive a relatively old thread, just wanted to say the script works really well on my qnap. But i was wondering if there was a way for the original rar file to remain for seeding, at the moment its unpacking and deleting the original.
-
- Posts: 1
- Joined: Tue Jun 20, 2017 8:51 am
Re: RAR Unpack in Version 2.92
I've never worried about such things. You can always find the right software in the format you need and even the right version. The main thing to know where to look. Often, all the software and not only I download on these resources https://yumdownload.com/utorrent. This is for those who like to play a little bit.