comment set-x, many updates everywhere, framework ready for the conversions.

pull/10/head
Raphaël Vinot 2013-02-25 01:27:15 +01:00
parent fa2618e57e
commit 28c11ada8f
7 changed files with 71 additions and 10 deletions

3
TODO
View File

@ -25,5 +25,6 @@ TODO
* strip back libreoffice to minimum required packages. in particular, if possible,
remove libreoffice-java-common package
* Write the groomer log on the destination key
* use /etc/mime.types and file -b --mime-type <filename> to find out the type of
[Done] use /etc/mime.types and file -b --mime-type <filename> to find out the type of
the file
* Extract metadata from all the files => https://mat.boum.org/

View File

@ -2,50 +2,83 @@
source ./constraint.sh
copy(){
src_file=${1}
dst_file=${2}
mkdir -p `dirname ${dst_file}`
cp ${src_file} ${dst_file}
}
# Plain text
text(){
echo Text file ${1}
copy ${1} ${2}${1##$SRC}
}
# Multimedia
## WARNING: They are assumed safe.
audio(){
echo Audio file ${1}
copy ${1} ${2}${1##$SRC}
}
image(){
echo Image file ${1}
copy ${1} ${2}${1##$SRC}
}
video(){
echo Video file ${1}
copy ${1} ${2}${1##$SRC}
}
# Random - Used
application(){
echo App file ${1}
src_file=${1}
dst_file=${2}${1##$SRC}
mime_details=${3}
case ${mime_details} in
"pdf")
echo "Got a pdf"
# WARNING: This command randomly fails, and loop indefinitely...
pdf2ps -dSAFER -sOutputFile="%stdout" ${src_file} | ps2pdfwr - ${dst_file}
;;
*xml*)
echo "Got an XML"
text ${1} ${2}
;;
*)
echo "Unknown type."
;;
esac
}
# Random - Unused
# Random - Unused?
## WARNING: They are assumed safe.
example(){
echo Example file ${1}
copy ${1} ${2}${1##$SRC}
}
message(){
echo Message file ${1}
copy ${1} ${2}${1##$SRC}
}
model(){
echo Model file ${1}
copy ${1} ${2}${1##$SRC}
}
multipart(){
echo Multipart file ${1}
copy ${1} ${2}${1##$SRC}
}
main(){
if [ -z ${1} ]; then
echo "Please specify the destination directory."
@ -54,17 +87,43 @@ main(){
# first param is the destination dir
dest=${1}
FILE_COMMAND='file -b --mime-type '
FILE_COMMAND='file -b --mime-type'
FILE_LIST=`find ${SRC} -type f`
for file in ${FILE_LIST}; do
mime=`$FILE_COMMAND ${file}`
echo ${mime}
main=`echo ${mime} | cut -f1 -d/`
details=`echo ${mime} | cut -f2 -d/`
case "${main}" in
"text")
text ${file}
text ${file} ${dest}
;;
"audio")
audio ${file} ${dest}
;;
"image")
image ${file} ${dest}
;;
"video")
video ${file} ${dest}
;;
"application")
application ${file} ${dest} ${details}
;;
"example")
example ${file} ${dest}
;;
"message")
message ${file} ${dest}
;;
"model")
model ${file} ${dest}
;;
"multipart")
multipart ${file} ${dest}
;;
*)
echo "This should never happen... :]"
echo $mime $main $details
;;
esac

View File

@ -120,6 +120,7 @@ do
# unpack and process archives
#unpackZip ${SRC} $targetDir $TEMP
ls -lR "${target_dir}"
fi
let PARTCOUNT=${PARTCOUNT}+1
done

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
#set -x
source ./constraint.sh

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
#set -x
if [ $# -eq 3 ]; then
if ! [ "${1}" -ge "1000" ] ; then

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
#set -x
if [ $# -eq 2 ]; then
mount -o noexec,nosuid,nodev,ro "${1}" "${2}"

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
#set -x
if [ $# -eq 1 ]; then
umount $1