User Tools

Site Tools


qnap:start

QNAP

Seedbox from QNAP

  • Install lftp:
ipkg update
ipkg install lftp
  • Create a script and save it as /share/MD0_DATA/homes/admin/seedbox.sh:
#!/opt/bin/bash
 
login="<username>"
pass="<password>"
host="sftp://<seedbox-server>"
remote_dir="<remote_directory>"
local_dir="<local_directory>"
 
DELETE="--Remove-source-files"
PARTS="-P1"
nPARTS=1
CONNECTIONS=5
 
 
if [[ -e /tmp/seedroots.lock ]]; then
   exit 0
fi
 
touch /tmp/seedroots.lock
 
if [ ! -d "$local_dir" ]; then
  mkdir -p $local_dir
fi
 
 
lftp -u $login,$pass $host <<EOF 
  set mirror:use-pget-n $CONNECTIONS 
  mirror -c $PARTS $DELETE --log=$local_dir/synctorrents.log $remote_dir $local_dir
  quit 0
EOF
 
 
if [[ ! -z "$DELETE" && -z $RECURSIVE ]]; then
  lftp -u $login,$pass $host << EOF
  rm -r $remote_dir
  mkdir $remote_dir
EOF
fi 
 
chown -R everyone:everyone $local_dir
 
rm -f /tmp/seedroots.lock
 
exit 0
  • Make it executable:
chmod +x /share/MD0_DATA/homes/admin/seedbox.sh
  • Add new entry in /etc/config/crontab file:
0 * * * * /bin/sh /share/MD0_DATA/homes/admin/seedbox.sh

Note: This script will run every hour.

  • Reload crontab:
crontab /etc/config/crontab
  • and restart cron:
/etc/init.d/crond.sh restart

SpiderOak

Installation

There is a installation process described on QNAP forum. It is a little obsolete, but still gives a really good intro.

Configuration

I want to run my SpiderOak in batchmode every day at 22:00, and purge all historical data every Saturday at 23:00. Also, I want to remove old log files on 1st of each month at 21:00.

Modify /etc/config/crontab file:

0 22 * * * /share/MD0_DATA/.qpkg/Optware/SpiderOak/usr/bin/SpiderOak --batchmode 2>&1 1>>/share/MD0_DATA/.qpkg/Optware/SpiderOak/conf/my.log
0 23 * * 5 /share/MD0_DATA/.qpkg/Optware/SpiderOak/usr/bin/SpiderOak --purge-historical-versions all 2>&1 1>>/share/MD0_DATA/.qpkg/Optware/SpiderOak/conf/my.log
45 23 * * 5 /share/MD0_DATA/.qpkg/Optware/SpiderOak/usr/bin/SpiderOak --purge-deleted-items=7 2>&1 1>>/share/MD0_DATA/.qpkg/Optware/SpiderOak/conf/my.log
0 21 1 * * rm -f /share/MD0_DATA/.qpkg/Optware/SpiderOak/conf/*.log

Reload crontab:

crontab /etc/config/crontab

and restart cron:

/etc/init.d/crond.sh restart

Troubleshooting

When the Cron does not work, and in /share/MD0_DATA/.qpkg/Optware/SpiderOak/conf/my.log there is an entry:

 Command line arguments not allowed during New User Setup

it means, that a symlink has been removed from /share/MD0_DATA/homes/admin

In order to fix this, please follow steps:

  • Remove /share/MD0_DATA/homes/admin/.SpiderOak
rm -r /share/MD0_DATA/homes/admin/.SpiderOak
  • Recreate symlink:
ln -s /opt/SpiderOak/conf /share/MD0_DATA/homes/admin/.SpiderOak

You can also use my little script:

#!/opt/bin/bash
 
dir="/share/homes/admin/.SpiderOak"
 
if [ -d "$dir" ] && [ ! -L "$dir" ]
then
  rm -fr "$dir"
fi
 
if [ ! -L "$dir" ]
then
  ln -s /opt/SpiderOak/conf /share/MD0_DATA/homes/admin/.SpiderOak
fi

To automate the process, and make your SpiderOak instance self correcting, save the script as /opt/SpiderOak/conf/fix_dir.sh1) and then add this line to /etc/config/crontab file:

45 21 * * * /opt/SpiderOak/conf/fix_dir.sh

Note: This should happen before you call SpideOak in batchmode at 22:00 :!:

Splunk

Autostart Splunk

  • Edit QPKG config file:
# vi /etc/config/qpkg.conf
  • Declare a new dummy package by adding something like that in above file:
[autorun]
Name = autorun
Version = 0.1
Author = Abadonna
Date = 2013-10-10
Shell = /share/MD0_DATA/.qpkg/autorun/autorun.sh
Install_Path = /share/MD0_DATA/.qpkg/autorun
QPKG_File = autorun.qpkg
Enable = TRUE
  • Create the dummy package directory:
# mkdir /share/MD0_DATA/.qpkg/autorun
  • Create /share/MD0_DATA/.qpkg/autorun/autorun.sh file:
#!/bin/sh
/opt/splunk/bin/splunk start

Note: don't forget “#!/bin/sh” at the beginning of script. :!:

  • Set the execute bit:
# chmod +x /share/MD0_DATA/.qpkg/autorun/autorun.sh
  • Restart your QNAP.
1)
Do not forget to make the script executable
qnap/start.txt · Last modified: 2014/06/28 02:49 (external edit)