| Line 4... |
Line 4... |
| 4 |
DLDIR="/home/irasnyd/downloads/usenet" # "global" download dir ###
|
4 |
DLDIR="/home/irasnyd/downloads/usenet" # "global" download dir ###
|
| 5 |
GLOGDIR="/home/irasnyd/downloads/usenet/logs" # "global" logdir ###
|
5 |
GLOGDIR="/home/irasnyd/downloads/usenet/logs" # "global" logdir ###
|
| 6 |
UNEX_LOG="${GLOGDIR}/unextractable" # "global" unextractable ###
|
6 |
UNEX_LOG="${GLOGDIR}/unextractable" # "global" unextractable ###
|
| 7 |
UNREP_LOG="${GLOGDIR}/unrepairable" # "global" unrepairable ###
|
7 |
UNREP_LOG="${GLOGDIR}/unrepairable" # "global" unrepairable ###
|
| 8 |
NFODIR="/data/NFO" # "global" nfo storage ###
|
8 |
NFODIR="/data/NFO" # "global" nfo storage ###
|
| - |
|
9 |
SFVDIR="/data/NFO/sfv" # "global" sfv storage ###
|
| 9 |
################################################################################
|
10 |
################################################################################
|
| 10 |
|
11 |
|
| 11 |
################################################################################
|
12 |
################################################################################
|
| 12 |
############################### FUNCTIONS ######################################
|
13 |
############################### FUNCTIONS ######################################
|
| 13 |
|
14 |
|
| Line 137... |
Line 138... |
| 137 |
|
138 |
|
| 138 |
### the "parjoin" command ###
|
139 |
### the "parjoin" command ###
|
| 139 |
rarslave_parjoin() {
|
140 |
rarslave_parjoin() {
|
| 140 |
PJNAME="$1"
|
141 |
PJNAME="$1"
|
| 141 |
|
142 |
|
| 142 |
lxsplit -j "${PJNAME}".001
|
143 |
lxsplit -j "${PJNAME}".001 ### Attempt to join the file
|
| 143 |
par2repair "$("${PJNAME}".*{par,PAR}2 | head -n1)" && rm "${PJNAME}".???*
|
144 |
par2repair "${PJNAME}".*???2 ### Attempt to repair the joined file
|
| - |
|
145 |
|
| - |
|
146 |
RETURN_CODE=$? ### Get the return code of the repair
|
| - |
|
147 |
|
| - |
|
148 |
if [ ${RETURN_CODE} -eq 0 ]; then ### If the repair was successful
|
| - |
|
149 |
rm "${PJNAME}".???* ### then remove all the source files
|
| - |
|
150 |
else ### If the repair was not successful
|
| - |
|
151 |
rm "${PJNAME}" ### then remove the attempted file
|
| - |
|
152 |
fi
|
| - |
|
153 |
|
| 144 |
}
|
154 |
}
|
| 145 |
|
155 |
|
| 146 |
### the "parjoin" command. attempts to repair and sort into ###
|
156 |
### the "parsort" command. attempts to repair and sort into ###
|
| 147 |
### "goodfiles" and "unrepairable" ###
|
157 |
### "goodfiles" and "unrepairable" ###
|
| 148 |
rarslave_parsort() {
|
158 |
rarslave_parsort() {
|
| 149 |
PARNAME="$1"
|
159 |
PARNAME="$1"
|
| 150 |
|
160 |
|
| 151 |
par2repair "${PARNAME}" \
|
161 |
par2repair "${PARNAME}" \
|
| Line 156... |
Line 166... |
| 156 |
### the "nfosort" command. moves all NFO's to ${NFODIR} ###
|
166 |
### the "nfosort" command. moves all NFO's to ${NFODIR} ###
|
| 157 |
nfosort() {
|
167 |
nfosort() {
|
| 158 |
find "${DLDIR}" -iregex '.*\.nfo$' -exec mv '{}' "${NFODIR}" \;
|
168 |
find "${DLDIR}" -iregex '.*\.nfo$' -exec mv '{}' "${NFODIR}" \;
|
| 159 |
}
|
169 |
}
|
| 160 |
|
170 |
|
| - |
|
171 |
### the "remove extraneous" command. removes all *.1 files (repair leftovers)
|
| - |
|
172 |
### as well as moving all sfv's to ${SFVDIR}
|
| - |
|
173 |
remove_extraneous() {
|
| - |
|
174 |
find "${DLDIR}" -iregex '^.*\.1$' -exec rm '{}' \;
|
| - |
|
175 |
find "${DLDIR}" -iregex '^.*\.sfv$' -exec mv '{}' "${SFVDIR}" \;
|
| - |
|
176 |
}
|
| - |
|
177 |
|
| 161 |
### prints the beginning message ###
|
178 |
### prints the beginning message ###
|
| 162 |
print_working_message() {
|
179 |
print_working_message() {
|
| 163 |
echo '================================================================================'
|
180 |
echo '================================================================================'
|
| 164 |
echo "Working in $(pwd)"
|
181 |
echo "Working in $(pwd)"
|
| 165 |
echo '================================================================================'
|
182 |
echo '================================================================================'
|
| Line 205... |
Line 222... |
| 205 |
cleanup_logs
|
222 |
cleanup_logs
|
| 206 |
|
223 |
|
| 207 |
# run rarslave recursively on every directory . and below
|
224 |
# run rarslave recursively on every directory . and below
|
| 208 |
find ./ -type d -print0 | xargs -0 -n1 | xargs -I{} rarslave "{}"
|
225 |
find ./ -type d -print0 | xargs -0 -n1 | xargs -I{} rarslave "{}"
|
| 209 |
nfosort
|
226 |
nfosort
|
| - |
|
227 |
remove_extraneous
|
| 210 |
print_errors
|
228 |
print_errors
|
| 211 |
|
229 |
|
| 212 |
# Print Parting Message
|
230 |
# Print Parting Message
|
| 213 |
echo
|
231 |
echo
|
| 214 |
echo "All Finished. Good Bye!"
|
232 |
echo "All Finished. Good Bye!"
|