comparison moefetch.sh @ 230:e922fb1e858f

- fixes on openssl output - no more features will be added
author edhoprima
date Tue, 09 Mar 2010 04:37:07 +0000
parents b03fef57b465
children 4c0fd276665e
comparison
equal deleted inserted replaced
229:b03fef57b465 230:e922fb1e858f
61 esac 61 esac
62 printf "%s" "${__path}" # Return. 62 printf "%s" "${__path}" # Return.
63 } 63 }
64 64
65 # Checks md5. OpenSSL should be available on anything usable. 65 # Checks md5. OpenSSL should be available on anything usable.
66 get_md5() { cat "$(safe_path "${1}")" | openssl dgst -md5; } 66 get_md5() { cat "$(safe_path "${1}")" | openssl dgst -md5 | tail -n 1 | sed -e 's/.*\([[:xdigit:]]\{32\}\).*/\1/'; }
67 67
68 # Safely get basename. 68 # Safely get basename.
69 get_basename() { basename "$(safe_path "${1}")"; } 69 get_basename() { basename "$(safe_path "${1}")"; }
70 70
71 # Safely get filename (basename without the extension). 71 # Safely get filename (basename without the extension).
136 <xsl:value-of select="@file_url" /> 136 <xsl:value-of select="@file_url" />
137 </xsl:template> 137 </xsl:template>
138 </xsl:stylesheet> 138 </xsl:stylesheet>
139 EOF 139 EOF
140 __tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist")) 140 __tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist"))
141 __iternum=$((${__iternum} + 1)) 141 __iternum=$((__iternum + 1))
142 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list" 142 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list"
143 echo "${__tempnum} file(s) available" 143 echo "${__tempnum} file(s) available"
144 done 144 done
145 numfiles=$(echo $(wc -l < "${TEMP_PREFIX}-list")) 145 numfiles=$(echo $(wc -l < "${TEMP_PREFIX}-list"))
146 echo "${numfiles} file(s) available on server" 146 echo "${numfiles} file(s) available on server"
168 # getting rid of ls (as per suggestion) 168 # getting rid of ls (as per suggestion)
169 Count_Files() { 169 Count_Files() {
170 numfiles=0 170 numfiles=0
171 for dircontent in "${*}/"* "${*}/".*; do 171 for dircontent in "${*}/"* "${*}/".*; do
172 if [ "${dircontent}" != "${*}/*" ] || [ -e "${dircontent}" ]; then 172 if [ "${dircontent}" != "${*}/*" ] || [ -e "${dircontent}" ]; then
173 numfiles=$((${numfiles} + 1)) 173 numfiles=$((numfiles + 1))
174 fi 174 fi
175 done 175 done
176 echo $((${numfiles} - 2)) 176 echo $((numfiles - 2))
177 } 177 }
178 178
179 # check tools availability 179 # check tools availability
180 Check_Tools() { 180 Check_Tools() {
181 # verify all programs required do indeed exist 181 # verify all programs required do indeed exist
339 *) 339 *)
340 Err_Help 340 Err_Help
341 ;; 341 ;;
342 esac 342 esac
343 shift 343 shift
344 SITE=
345 TAGS=
344 __has_pass=0 346 __has_pass=0
345 __has_user=0 347 __has_user=0
346 #copypasta from http://mywiki.wooledge.org/BashFAQ/035
347 __optnum=1
348 while getopts "s:(site)n(noclean)u:(user)p:(password)" opt 348 while getopts "s:(site)n(noclean)u:(user)p:(password)" opt
349 do 349 do
350 case "$opt" in 350 case "$opt" in
351 s) SITE="$OPTARG";; 351 s) SITE="$OPTARG";;
352 n) NOCLEAN=1;; 352 n) NOCLEAN=1;;
357 u) 357 u)
358 LOGIN_USER="$OPTARG" 358 LOGIN_USER="$OPTARG"
359 __has_user=1 359 __has_user=1
360 ;; 360 ;;
361 esac 361 esac
362 __optnum="${OPTIND}" 362 done
363 done
364 shift $((${__optnum}-1))
365 TAGS="$@" 363 TAGS="$@"
366 [ -n "${SITE}" ] || SITE=${DEFAULT_SITE} 364 [ -n "${SITE}" ] || SITE=${DEFAULT_SITE}
367 [ -n "${TAGS}" ] || Err_Fatal "No tag specified" 365 [ -n "${TAGS}" ] || Err_Fatal "No tag specified"
368 # Get base folder - default, current folder or fallback to ${HOME} 366 # Get base folder - default, current folder or fallback to ${HOME}
369 [ -n "${BASE_DIR}" ] || BASE_DIR=${PWD} 367 [ -n "${BASE_DIR}" ] || BASE_DIR=${PWD}
380 } 378 }
381 379
382 # global variables goes here 380 # global variables goes here
383 init_globals() 381 init_globals()
384 { 382 {
385 cd . # Reset ${PWD} 383 _version="0.3-rc1" # version of this script
386 _version="0.3-beta3" # version of this script
387 _use_login=0 # variable to check whether a login is used or not 384 _use_login=0 # variable to check whether a login is used or not
388 SITE=
389 TAGS=
390 } 385 }
391 386
392 main() 387 main()
393 { 388 {
394 #initialize global variables 389 #initialize global variables