Dockerize paperify

This commit is contained in:
Alisina Bahadori
2020-09-07 22:52:28 +04:30
parent 8b7974336a
commit 3543d50dc7
3 changed files with 49 additions and 9 deletions

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM archlinux
RUN pacman --noconfirm -Sy qrencode \
zbar \
imagemagick \
git \
ttf-roboto \
fontconfig \
diffutils
ENV FONT=Roboto-Regular \
OUTPUT_DIR=/target/ \
INPUT_DIR=/target/
RUN mkdir /paperify
COPY . /paperify
WORKDIR /paperify
ENTRYPOINT ["/paperify/paperify.sh"]

View File

@@ -1,7 +1,15 @@
#!/bin/sh -e
outputfile="$1"
dir="$2"
if [ "$1" = "" ]; then
echo "Please provide a filename as the first argument"
exit 1
elif [ "$2" = "" ]; then
echo "Please provide the directory of the images as the second argument"
exit 1
fi
outputfile="$INPUT_DIR$1"
dir="$OUTPUT_DIR$2"
files=$(ls $dir)

View File

@@ -1,16 +1,27 @@
#!/bin/sh -e
while getopts "c:" opt; do
case $opt in
c) comment=$OPTARG ;; # Handle -c
\?) echo "Use -c \"COMMENT\" to add comment to images."; exit ;; # Handle error: unknown option or missing required argument.
esac
for ((i=1;i<=$#;i++));
do
if [ ${!i} = "-c" ]
then ((i++))
comment=${!i};
else
file="$INPUT_DIR${!i}";
fi
done
for file in $@; do :; done
if test -f "$file"; then
echo "Paperifying $file"
else
echo "File not found! $file"
exit 1
fi
filename=$(echo $file | rev | cut -f 1 -d '/' | rev)
prefix="$filename-"
dir="$filename-qr"
dir="$OUTPUT_DIR$filename-qr"
mkdir -p $dir
rm -f $dir/*