▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ██
█▌ - RESCAN & TOTAL-RESCAN - █▌
█▌ █▌
█ ▐▌
█ This tutorial is how-to fix some issues with project-zs-ng_r2500-v1.2.0 ▐▌
█ 'rescan' and the use of 'total-rescan' via site command. ▐▌
█ ▐▌
█ RESCAN NOTES: ▐▌
█ TOTAL-RESCAN: ▐▌
█ INSTALL UPDATED RESCAN: ▐▌
█ CREATE SCRIPTS TO RUN TOTAL-RESCAN VIA A SITE CMD: ▐▌
█ HIDE SIGNAL FILE FROM USERS ON SITE: ▐▌
█ TOTAL-RESCAN RUN IN --NORMAL MODE: ▐▌
█ TOTAL-RESCAN SORT MP3: ▐▌
█ ADD NEW CMD TO SITE HELP: ▐▌
█ SCRIPT TO RUN TOTAL-RESCAN TWICE THROUGH SHELL: ▐▌
█ ▐▌
█ RESCAN NOTES: ▐▌
█ pzs-ng's included rescan only checks the files in the directory you ▐▌
█ select - not recursive; 1 directory per command. ▐▌
█ The command line usage default is run in '--quick' mode; recheck those ▐▌
█ not marked as verified already. ▐▌
█ In shell - example how to check the files in the directory 'whatever': ▐▌
█ /jail/glftpd/bin/rescan --chroot=/jail/glftpd --dir=/site/incoming/whatever▐▌
█ /* wild cards do not work. ▐▌
█ To use normal mode- recheck all files in that dir: ▐▌
█ /jail/glftpd/bin/rescan --chroot=/jail/glftpd --normal --dir=/site/incoming/whatever
█ Or via site cmd, while in the directory to execute the cmd on: ▐▌
█ site rescan --normal ▐▌
█ If you want it to run in --normal mode by default put in your zconfig.h: ▐▌
█ #define rescan_default_to_quick FALSE ▐▌
█ Then you can run rescan in normal mode, via site cmd: site rescan ▐▌
█ ▐▌
█ Under site rescan --help it states: ▐▌
█ --dir=<PATH> - cd to (chroot'ed) PATH before beginning to rescan. ▐▌
█ To use this cmd you need to add this directive in zconfig.h: ▐▌
█ #define rescan_chdir_flags "17ABC" ▐▌
█ Change the flags to those users you want to allow access to this cmd. ▐▌
█ This cmd allows a user to scan X directory without the need to cd to it ▐▌
█ first . Example, to rescan the directory whatever, path must start with ▐▌
█ site: ▐▌
█ site rescan --dir=/site/incoming/whatever ▐▌
█ Note that if you execute this cmd in a directory that doesn't contain ▐▌
█ files it will make a sym link to that directory stating (no-sfv). ▐▌
█ ▐▌
█ PROBLEMS: ▐▌
█ A. Zips: ▐▌
█ If you use rescan on a directory containing multiple zip files only; no ▐▌
█ file_id.diz or *.nfo, you'll need to run rescan twice for it to verify all ▐▌
█ the zip files. ▐▌
█ The reason being is it will extract the the file_id.diz, count how many ▐▌
█ should be there, create incomplete folder based on one zip, and symlink, ▐▌
█ and a symlink (no-nfo) then exit. ▐▌
█ Run it a 2nd time, and all those problems are solved except the no .nfo - ▐▌
█ as it does not extract .nfo files. ▐▌
█ ▐▌
█ To fix these issues (run twice and no nfo extraction) you'll need to use ▐▌
█ the updated rescan -see below details how to 'INSTALL UPDATED RESCAN'. ▐▌
█ If you do not want to update your rescan (why wouldn't you? :) ) then I ▐▌
█ have a simple solution so users only need to run the cmd once (which will ▐▌
█ run it twice) - see end of this tutorial 'SCRIPT TO RUN TOTAL-RESCAN TWICE ▐▌
█ THROUGH SHELL' - which could also be used to run total-rescan on multiple ▐▌
█ paths with one cmd line easily. ▐▌
█ ▐▌
█ B. Can't rescan recursively: ▐▌
█ Use total-rescan - see below details how to 'TOTAL-RESCAN'. ▐▌
█ ▐▌
█ TOTAL-RESCAN: ▐▌
█ ````````````` ▐▌
█ To recursively check site use daxxar's 'total-rescan.pl' (at the time of ▐▌
█ this tutorial latest v is 1.5rc2). This rescans a directory and all of its ▐▌
█ sub-directories that contain a .sfv and /or .zip. It can also be used as ▐▌
█ an audio file sorter. ▐▌
█ This will use the same binary 'rescan' above, but with a different set of ▐▌
█ directives. ▐▌
█ So if you aren't using the updated/fixed rescan you'll still have the same ▐▌
█ problems with zips as stated above. ▐▌
█ This can only be run as root, not via site cmd. To use this script via a ▐▌
█ site cmd - see below details how to 'CREATE SCRIPTS TO RUN TOTAL-RESCAN ▐▌
█ VIA A SITE CMD'. ▐▌
█ ▐▌
█ PREREQUISITES: ▐▌
█ su ▐▌
█ dpkg -l | grep -E 'perl|locales' ▐▌
█ Install those that weren't on your list: ▐▌
█ aptitude update ▐▌
█ aptitude install perl locales libperl-dev ▐▌
█ exit ▐▌
█ ▐▌
█ Download total-rescan HERE. If that link is down I have put it HERE, or: ▐▌
█ wget http://mewbies.com/glftpd_3rd_party_scripts/total_rescan.rar ▐▌
█ rar x total_rescan.rar ▐▌
█ gzip -d total-rescan.pl.gz ▐▌
█ su ▐▌
█ cp total-rescan.pl /jail/glftpd/bin/total-rescan.pl ▐▌
█ chmod 744 /jail/glftpd/bin/total-rescan.pl ▐▌
█ chmod 755 /jail/glftpd/bin/rescan ▐▌
█ cat /jail/glftpd/bin/total-rescan.pl ▐▌
█ For example to rescan 'incoming': ▐▌
█ /jail/glftpd/bin/./total-rescan.pl site/incoming /jail/glftpd ▐▌
█ Or to rescan all of site: ▐▌
█ /jail/glftpd/bin/./total-rescan.pl site /jail/glftpd ▐▌
█ ▐▌
█ You could also set a cron job for it to automatically run at x times, for ▐▌
█ example: ▐▌
█ crontab -e ▐▌
█ Paste in, change paths and times to your needs ▐▌
█ */30 * * * * /jail/glftpd/bin/total-rescan.pl site/ZIPS >/dev/null 2>&1 ▐▌
█ 0 2 * * * /jail/glftpd/bin/total-rescan.pl site/blahblah >/dev/null 2>&1 ▐▌
█ @weekly /jail/glftpd/bin/total-rescan.pl site/M3/archive >/dev/null 2>&1 ▐▌
█ ▐▌
█ exit ▐▌
█ ▐▌
█ INSTALL UPDATED RESCAN: ▐▌
█ ``````````````````````` ▐▌
█ There is an updated rescan, with all the zip problems mentioned above ▐▌
█ fixed -2010-02-03 11:17. ▐▌
█ Read HERE, download from HERE. ▐▌
█ ▐▌
█ Place the 'rescan.revised.tar.gz' in your home directory, ~/ ▐▌
█ tar xvzf rescan.revised.tar.gz ▐▌
█ (it will be extracted to here: ~/zipscript/src/rescan.c) ▐▌
█ find ~/ -name rescan.c ▐▌
█ Backup your original rescan.c just in case: ▐▌
█ mv ~/project-zs-ng_r2500-v1.2.0/zipscript/src/rescan.c ~/project-zs-ng_r2500-v1.2.0/zipscript/src/rescan-orginal.c
█ Copy the new one over: ▐▌
█ cp ~/zipscript/src/rescan.c ~/project-zs-ng_r2500-v1.2.0/zipscript/src/rescan.c
█ su ▐▌
█ cd /jail/glftpd/ ▐▌
█ We need to remove the directory lib (that is created by pzs-ng) so if you ▐▌
█ would like to back it up also just to be safe: ▐▌
█ rar a -m5 -v15000000kb -vn lib_backup lib/ ▐▌
█ rm /jail/glftpd/lib/ -rf ▐▌
█ cd /home/user/project-zs-ng_r2500-v1.2.0/ ▐▌
█ make distclean ▐▌
█ ./configure --with-install-path=/jail/glftpd ▐▌
█ Note this will not re-create/overwrite your existing zsconfig.h, only if ▐▌
█ it doesn't exist zsconfig.h will be created. ▐▌
█ make ▐▌
█ make install ▐▌
█ cd scripts/libcopy/ ▐▌
█ ./libcopy.sh /jail/glftpd/ ▐▌
█ ▐▌
█ Test on site now: ▐▌
█ site rescan --normal ▐▌
█ If all went well, then clean up: ▐▌
█ rm /jail/glftpd/lib_backup.rar ▐▌
█ exit ▐▌
█ rm ~/project-zs-ng_r2500-v1.2.0/zipscript/src/rescan-orginal.c ▐▌
█ rm ~/zipscript -rf ▐▌
█ ▐▌
█ If after doing you receive the error on site: ▐▌
█ site rescan --help: ▐▌
█ [1] 200- /bin/rescan: relocation error: /lib/tls/i686/cmov/libc.so.6: ▐▌
█ symbol _dl_out_of_memory, version GLIBC_PRIVATE not defined in file ▐▌
█ ld-linux.so.2 with link time reference ▐▌
█ [1] 200 Error executing command. ▐▌
█ ▐▌
█ It is most likely because you didn't remove lib directory, 'make ▐▌
█ distclean' and or didn't './libcopy.sh /jail/glftpd/'. View the same ▐▌
█ problem HERE. ▐▌
█ ▐▌
█ CREATE SCRIPTS TO RUN TOTAL-RESCAN VIA A SITE CMD: ▐▌
█ `````````````````````````````````````````````````` ▐▌
█ To be able to run total-rescan from a site cmd, as it can only be run from ▐▌
█ root, this is the summary of what we'll do: ▐▌
█ -Make a site cmd that creates a signal file and echos the user to wait ▐▌
█ one minute. ▐▌
█ -Create a cron job to check every one minute if that signal file is ▐▌
█ found; run script - that will run total-rescan, then the script will ▐▌
█ remove the signal file. If signal file isn't found, it does nothing. ▐▌
█ ▐▌
█ Easy enough, just a number or steps involved. Either download the scripts ▐▌
█ from HERE and follow to tutorial how to use, or just continue and ▐▌
█ copy/paste the scripts in. ▐▌
█ ▐▌
█ 1. SIGNAL FILE: ▐▌
█ A. Script to create an empty file for cron to search for every one minute: ▐▌
█ su ▐▌
█ Create the file: ▐▌
█ pico /jail/glftpd/bin/total_rescan_signal.sh ▐▌
█ Paste in: ▐▌
#!/bin/sh
#mewbie's total-rescan signal
VERSION="1.00"
echo "mewbie's total-rescan signal creator v"$VERSION""
echo ""
#INSTRUCTIONS
#Use this script with total_rescan_checker.sh
#This script will create the file 'tr_signal.txt' to signal root to run
#total_rescan_checker.sh which will then run total-rescan.pl
#Place this script in your /glftpd/bin/
#You need to chmod 755 this file
#Add the following lines to your glftpd.conf, without the #:
# site_cmd RESCAN2 EXEC /bin/total_rescan_signal.sh
# custom-rescan2 !8 *
#Change below to any gl /site/ path you would like the signal file
#created; it doesn't matter which path as long as it is a gl site path:
touch /site/incoming/tr_signal.txt
echo -e "Activating... wait 1 minute then refresh"
exit
█ ▐▌
█ *If your site isn't in jail (chroot) then the touch line might be, for ▐▌
█ example: ▐▌
█ touch /glftpd/site/incoming/tr_signal.txt ▐▌
█ ▐▌
█ chmod 755 /jail/glftpd/bin/total_rescan_signal.sh ▐▌
█ ▐▌
█ B. Add the cmd to your glftpd.conf, changing flag !8 * to suit your needs: ▐▌
█ pico /jail/glftpd/etc/glftpd.conf ▐▌
█ site_cmd RESCAN2 EXEC /bin/total_rescan_signal.sh ▐▌
█ custom-rescan2 !8 * ▐▌
█ ▐▌
█ Try the site cmd, logout, login: site rescan2 ▐▌
█ You should now see a 0 byte file 'tr_signal.txt' in the path you ▐▌
█ designated in 'total_rescan_signal.sh'. ▐▌
█ At this point, that is all it does - creates that file. ▐▌
█ ▐▌
█ 2. CREATE SCRIPT TO LOOK FOR SIGNAL FILE AND / RUN TOTAL-RESCAN: ▐▌
█ A. Now to create the script that will execute total-rescan only if the ▐▌
█ file 'tr_signal.txt' exist, then after remove 'tr_signal.txt': ▐▌
█ pico /jail/glftpd/bin/total_rescan_checker.sh ▐▌
█ Paste this in, changing the paths 'if and rm' to where you stated ▐▌
█ 'tr_signal.txt' should be created and change the path/s you want to be ▐▌
█ able to run total-rescan from a site cmd: ▐▌
█ ▐▌
#!/bin/sh
#mewbie's total-rescan checker
VERSION="1.00"
echo "mewbie's total-rescan checker v"$VERSION""
echo ""
#INSTRUCTIONS
#Use this script with total_rescan_signal.sh
#This script will run total-rescan.pl if tr_signal.txt exist
#Place this script in your /glftpd/bin/
#This file needs to be chmod 755
#Change path to where tr_signal.txt file will be created:
if [ -f /jail/glftpd/site/incoming/tr_signal.txt ] ; then
#Change path to what section you would like total-rescan to run:
/jail/glftpd/bin/./total-rescan.pl site/whatever /jail/glftpd
#Change path to where tr_signal.txt file will be created:
rm /jail/glftpd/site/incoming/tr_signal.txt
else
echo "tr_signal.txt does not exist in that path"
fi
exit
█ ▐▌
█ Note: If you did not update your rescan and need total-rescan to run ▐▌
█ twice, just repeat the path twice that you want rescanned, for example: ▐▌
█ /jail/glftpd/bin/./total-rescan.pl site/whatever /jail/glftpd ▐▌
█ /jail/glftpd/bin/./total-rescan.pl site/whatever /jail/glftpd ▐▌
█ ▐▌
█ chmod 755 /jail/glftpd/bin/total_rescan_checker.sh ▐▌
█ Test it: ▐▌
█ /jail/glftpd/bin/./total_rescan_checker.sh ▐▌
█ ▐▌
█ 3. ADD TO CRONTAB: ▐▌
█ This will add the run 'total_rescan_checker.sh' every 1 minute. If the ▐▌
█ signal file doesn't exist- nothing. If it does exist it will execute. ▐▌
█ crontab -e ▐▌
█ * * * * * /jail/glftpd/bin/./total_rescan_checker.sh >/dev/null 2>&1 ▐▌
█ ▐▌
█ Done. Test it by running the site command and wait 1 minute max, then ▐▌
█ refresh site: site rescan2 ▐▌
█ Note that it does not matter what directory you are when issuing the site ▐▌
█ cmd as script already states what path to rescan. ▐▌
█ ▐▌
█ HIDE SIGNAL FILE FROM USERS ON SITE: ▐▌
█ ```````````````````````````````````` ▐▌
█ If you do not want users to be able to see the signal file on the site ▐▌
█ while you wait for the script to remove it then: ▐▌
█ pico /jail/glftpd/etc/glftpd.conf ▐▌
█ Add this: ▐▌
█ hidden_files / tr_signal.txt ▐▌
█ While you're there if you want to hide the rmlog.sh that total-rescan ▐▌
█ creates add this line also: ▐▌
█ hidden_files / rmlog.sh ▐▌
█ ▐▌
█ TOTAL-RESCAN RUN IN --NORMAL MODE: ▐▌
█ `````````````````````````````````` ▐▌
█ By default it is run in --quick mode - only rechecks files not marked as ▐▌
█ verified already. ▐▌
█ So if there is a missing file 'after' an upload has already been checked ▐▌
█ as good/complete, when you rescan: ▐▌
█ it will not make the sym link incomplete ▐▌
█ it will not rewrite complete directory within ▐▌
█ it will though make the missing file and (no-nfo) sym link if .nfo is ▐▌
█ missing. ▐▌
█ To fix this and have it run in --normal mode always (slower): ▐▌
█ pico /jail/glftpd/bin/total-rescan.pl ▐▌
█ Has this: ▐▌
█ my $rescan = '/bin/rescan'; # Change if you've moved it / using another rescanner.
█ Change to: ▐▌
█ my $rescan = '/bin/rescan --normal'; # Change if you've moved it / using another rescanner.
█ ▐▌
█ Test it: ▐▌
█ /jail/glftpd/bin/./total-rescan.pl site/blahblah /jail/glftpd ▐▌
█ ▐▌
█ TOTAL-RESCAN SORT MP3: ▐▌
█ `````````````````````` ▐▌
█ You can use total-rescan to sort MP3s and not verify the files. ▐▌
█ Read total-rescan.pl for the settings. This is how I have done it: ▐▌
█ Create a copy of it, naming it anything you like: ▐▌
█ cp /jail/glftpd/bin/total-rescan.pl /jail/glftpd/bin/total-rescan-mp3.pl ▐▌
█ Then edit to your needs: ▐▌
█ pico /jail/glftpd/bin/total-rescan-mp3.pl ▐▌
█ Changing these two settings to: ▐▌
█ my $zipscan = 0; ▐▌
█ my $onlysort = 1; ▐▌
█ ▐▌
█ Then run it from shell to test in directory for example 'whatever': ▐▌
█ /jail/glftpd/bin/./total-rescan-mp3.pl site/incoming/MP3/whatever/jail/glftpd
█ ▐▌
█ Then you could cron it to have it done automatically at x times: ▐▌
█ crontab -e ▐▌
█ Paste in for example, changing to your own needs: ▐▌
█ */30 * * * * /jail/glftpd/bin/total-rescan-mp3.pl site/M3-Today >/dev/null 2>&1
█ 30 2 * * * /jail/glftpd/bin/total-rescan-mp3.pl site/incoming/M3/whatever >/dev/null 2>&1
█ @weekly /jail/glftpd/bin/total-rescan-mp3.pl site/archive/M3/blahblah >/dev/null 2>&1
█ ▐▌
█ You could also create a script, like above, to have it work as a site cmd. ▐▌
█ ▐▌
█ ADD NEW CMD TO SITE HELP: ▐▌
█ `````````````````````````````` ▐▌
█ If you want to add it to the site news: ▐▌
█ pico /jail/glftpd/ftp-data/misc/newsfile ▐▌
█ ▐▌
█ If you want to add it to site help: ▐▌
█ pico /jail/glftpd/ftp-data/help/site.help.all ▐▌
█ Paste this in (don't hit enter after the last line or there will be a ▐▌
█ gap), replacing X with the directory you stated in the script: ▐▌
█ !D!5 RESCAN2!B!5:!h!5 To rescan all the directories in X ▐▌
█ ▐▌
█ SCRIPT TO RUN TOTAL-RESCAN TWICE THROUGH SHELL: ▐▌
█ ``````````````````````````````````````````````` ▐▌
█ You only need this if you haven't used the fixed/update rescan- as the old ▐▌
█ rescan on sets of zips needs to be run twice. Or this same script could be ▐▌
█ used to have total-rescan run on a variety of paths with one simple cmd. ▐▌
█ Just add all the paths you would like to run at the same time to the ▐▌
█ script- once if you have an updated rescan. ▐▌
█ ▐▌
█ pico /jail/glftpd/bin/total_rescan_twice.sh ▐▌
#!/bin/sh
#mewbie's total-rescan run twice
VERSION="1.00"
echo "mewbie's total-rescan run twice v"$VERSION""
echo ""
#INSTRUCTIONS
#This is just a silly script to run total-rescan.pl twice with one cmd
#Place this script in your /glftpd/bin/
#This file needs to be chmod 755
#Change below to your correct paths
#Add on as many paths, twice, that you need, changing to the
#sections you would like, for example:
/jail/glftpd/bin/./total-rescan.pl site/0DAY-Today /jail/glftpd
/jail/glftpd/bin/./total-rescan.pl site/0DAY-Today /jail/glftpd
exit
█ ▐▌
█ chmod 755 /jail/glftpd/bin/total_rescan_twice.sh ▐▌
█ ▐▌
█ Test it: ▐▌
█ /jail/glftpd/bin/./total_rescan_twice.sh ▐▌
█ ▐▌
█ //---------------------------------------------------------------------- ▐▌
█ ▐▌
█ If you find mistakes, have suggestions, and or questions please post at ▐▌
█ mewbies forum HERE - thank you. ▐▌
█ ▐▌
█ Last update on 18 Jul '10 ▐▌
█ ▐▌
█▌ █▌
█▌ - mewbies.com - █▌
█▌ █▌
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██