61 lines
1.1 KiB
Bash
Executable File
61 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
err() {
|
|
echo "${1}"
|
|
zenity --error --no-wrap --text "${1}"
|
|
exit 1
|
|
}
|
|
|
|
warn() {
|
|
echo "${1}"
|
|
zenity --warning --no-wrap --text "${1}"
|
|
}
|
|
set -x
|
|
if ! command -v unzip &> /dev/null
|
|
then
|
|
err "'unzip' could not be found"
|
|
fi
|
|
|
|
if [ ${#@} -eq 0 ]; then
|
|
# no arguments
|
|
IFS=$'\n' files=($(zenity --file-selection --multiple --separator=$'\n' --title="Choose files"))
|
|
else
|
|
# arguments
|
|
echo ""
|
|
fi
|
|
|
|
for file in "${files[@]}"; do
|
|
fname="$(basename ${file%.*})"
|
|
folder="content/posts/${fname}"
|
|
if ! unzip -l "${file}"|grep -q "index.de.md"; then
|
|
err "maybe wrong archive, this is not compatible"
|
|
fi
|
|
if ! [ -d content ]; then
|
|
err "folder 'content' not found"
|
|
fi
|
|
mkdir -p "${folder}"
|
|
unzip -o -d "${folder}" "${file}"
|
|
git add "${folder}"
|
|
git commit -m "${fname}"
|
|
done
|
|
|
|
|
|
output_temp=""
|
|
|
|
for file in "${files[@]}"; do
|
|
banner="false"
|
|
fname="$(basename ${file%.*})"
|
|
folder="content/posts/${fname}"
|
|
for f in $(find "${folder}" -type f); do
|
|
if echo ${i}|grep -q "banner"; then
|
|
banner="true"
|
|
fi
|
|
done
|
|
if [ ${banner} == "false" ]; then
|
|
output_temp="${output_temp}banner missing\n "
|
|
fi
|
|
done
|
|
|
|
warn "${output_temp}"
|
|
zenity --info --text "Done"
|