59 lines
1.1 KiB
Bash
59 lines
1.1 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
#
|
||
|
|
# Usage create-doctypes-json.sh {library-directory-root}
|
||
|
|
# e.g. create-doctypes-json.sh /sl/SLSync/library/standard
|
||
|
|
|
||
|
|
LIBDIR=$1
|
||
|
|
|
||
|
|
function usage(){
|
||
|
|
if [ "$1" != "" ]; then
|
||
|
|
echo $1
|
||
|
|
fi
|
||
|
|
echo "Usage: create-doctypes-json.sh {library-directory-root}"
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
if [ ! -d "${LIBDIR}" ]; then
|
||
|
|
usage "library-directory-root is required"
|
||
|
|
fi
|
||
|
|
|
||
|
|
GEN=`date +"%Y-%m-%dT%H:%M:%S"`
|
||
|
|
SRC=`hostname`
|
||
|
|
|
||
|
|
cat <<EOF
|
||
|
|
{
|
||
|
|
"generated":"${GEN}",
|
||
|
|
"directory":"${LIBDIR}",
|
||
|
|
"types": [
|
||
|
|
{
|
||
|
|
"Description": "Unable to determine doctype",
|
||
|
|
"MISMO_Document_Class_Subtype_Description": "",
|
||
|
|
"MISMO_Document_Class_Type": "",
|
||
|
|
"SLI_Doctype_Code": "UNKNOWN",
|
||
|
|
"Source_of_Definition": "SLEDS Tim"
|
||
|
|
}
|
||
|
|
EOF
|
||
|
|
|
||
|
|
COMMA=","
|
||
|
|
ls "${LIBDIR}" | while read dirtype; do
|
||
|
|
bn=`basename "${dirtype}"`
|
||
|
|
cat <<EOF
|
||
|
|
${COMMA}{
|
||
|
|
"Description":"",
|
||
|
|
"AKA":"",
|
||
|
|
"MISMO_Document_Class_Subtype_Description":"",
|
||
|
|
"MISMO_Document_Class_Type":"",
|
||
|
|
"Source_of_Definition":"${SRC}",
|
||
|
|
"SLI_Doctype_Code":"${bn}"
|
||
|
|
}
|
||
|
|
EOF
|
||
|
|
COMMA=","
|
||
|
|
done
|
||
|
|
|
||
|
|
cat <<EOF
|
||
|
|
]
|
||
|
|
}
|
||
|
|
EOF
|
||
|
|
|
||
|
|
exit 0
|