diff --git a/TODO b/TODO index 1f7c235..8e06c2a 100644 --- a/TODO +++ b/TODO @@ -8,13 +8,13 @@ TODO * Starting process should be more obfuscated * strip exif data and leave it in a .txt file next to the image it came from => exiftool -* set filesystem of OS in RO (physical switch and/or remount OS) +[Done with remount] set filesystem of OS in RO (physical switch and/or remount OS) [OK] mount source key in RO and noexec <= also nosuid and nodev [OK] mount target key with noexec <= also nosuid and nodev * convert spreadsheets in csv ? * convert documents (pdfs/*office/...) in images ? * Have a look at Ghostscript to work on PDFs (.pdf -> .eps -> .png?) -* do not run the conversions as root -> run in chroot +[do everything as user] do not run the conversions as root -> run in chroot * take eth0 down in /etc/netowrk/interfaces or in the groomer script disable the interface before anything happens * hdmi should stay up: solveable by poking the power management timer diff --git a/filesystem/opt/groomer/constraint.sh b/filesystem/opt/groomer/constraint.sh index 76a3e60..6d5a77d 100644 --- a/filesystem/opt/groomer/constraint.sh +++ b/filesystem/opt/groomer/constraint.sh @@ -1,9 +1,18 @@ -DEV_SRC='/dev/sdb' -DEV_DST='/dev/sdc1' +DEV_SRC='/dev/sdf' +DEV_DST='/dev/sdg1' # User allowed to do the following commands without password USERNAME='kitten' HOME="/home/${USERNAME}" +# Paths used in multiple scripts +SRC="${HOME}/src" + +DST="${HOME}/dst" +TEMP="${DST}/temp" +ZIPTEMP="${DST}/ziptemp" +LOGS="${DST}/logs" + + # commands SUDO='/usr/bin/sudo' ID=`/usr/bin/id -u` diff --git a/filesystem/opt/groomer/functions.sh b/filesystem/opt/groomer/functions.sh new file mode 100755 index 0000000..209c2f1 --- /dev/null +++ b/filesystem/opt/groomer/functions.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +source ./constraint.sh + +# Plain text +text(){ + echo Text file ${1} +} + +# Multimedia +audio(){ + echo Audio file ${1} +} + +image(){ + echo Image file ${1} +} + +video(){ + echo Video file ${1} +} + +# Random - Used + +application(){ + echo App file ${1} +} + +# Random - Unused + +example(){ + echo Example file ${1} +} + +message(){ + echo Message file ${1} +} + +model(){ + echo Model file ${1} +} + +multipart(){ + echo Multipart file ${1} +} + + + +main(){ + if [ -z ${1} ]; then + echo "Please specify the destination directory." + exit + fi + # first param is the destination dir + dest=${1} + + FILE_COMMAND='file -b --mime-type ' + FILE_LIST=`find ${SRC} -type f` + for file in ${FILE_LIST}; do + mime=`$FILE_COMMAND ${file}` + main=`echo ${mime} | cut -f1 -d/` + details=`echo ${mime} | cut -f2 -d/` + case "${main}" in + "text") + text ${file} + ;; + *) + echo $mime $main $details + ;; + esac + done +} + diff --git a/filesystem/opt/groomer/groomer.sh b/filesystem/opt/groomer/groomer.sh index d4d9d8f..ecdadf6 100755 --- a/filesystem/opt/groomer/groomer.sh +++ b/filesystem/opt/groomer/groomer.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -set -x +#set -x source ./constraint.sh if ! [ "${ID}" -ge "1000" ]; then @@ -9,14 +9,7 @@ if ! [ "${ID}" -ge "1000" ]; then exit fi - -SRC="${HOME}/src" -DST="${HOME}/dst" - -TEMP="${DST}/temp" -ZIPTEMP="${DST}/ziptemp" -LOGS="${DST}/logs" - +source ./functions.sh clean(){ echo Cleaning. @@ -112,6 +105,8 @@ do echo "copying to: ${target_dir}" mkdir -p "${target_dir}" + main ${target_dir} + #if [ $COPYDIRTYPDF -eq 1 ]; then # pdfCopyDirty ${SRC} $targetDir #else