This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdfapps.sh
executable file
·75 lines (62 loc) · 1.89 KB
/
pdfapps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
scripthome=`pwd`
while [[ $# -gt 0 ]] && [[ ."$1" = .--* ]] ;
do
opt="$1";
shift; #expose next argument
case "$opt" in
"--" ) break 2;;
"--username" )
username="$1"; shift;;
"--username="* ) # alternate format: --username=sss
username="${opt#*=}";;
"--password" )
password="$1"; shift;;
"--password="* )
password="${opt#*=}";;
"--savepath" )
savepath="$1"; shift;;
"--savepath="* ) # alternate format: --savepath=xxx
savepath="${opt#*=}";;
"--siteurl" )
siteurl="$1"; shift;;
"--siteurl="* )
siteurl="${opt#*=}";;
"--nids" )
nids="$1"; shift;;
"--nids="* )
nids="${opt#*=}";;
"--recreate" )
sflag=true;;
*) echo >&2 "Invalid option: $@"; exit 1;;
esac
done
nids=($nids)
for app in "${nids[@]}"
do
echo "---- Starting application/$app -----"
zipfile="$savepath/$app/generated_pdfs/all_pages.zip"
if [[ "$sflag" = true ]] ; then
echo "Removing $savepath/$app/generated_pdfs/all_pages.zip"
rm -vf $savepath/$app/generated_pdfs/all_pages.zip
fi
if [[ -f $zipfile ]]; then
echo "File $zipfile found - skip!"
cd $savepath/$app/generated_pdfs
ls -lah .
cd $scripthome
echo "skipping $app" >> skipped.log
else
echo "File $zipfile not found."
if [[ ! -e $savepath/$app/generated_pdfs ]]; then
mkdir -p $savepath/$app/generated_pdfs
elif [[ ! -d $savepath/$app/generated_pdfs ]]; then
echo "$savepath/$app/generated_pdfs already exists but is not a directory" 1>&2
fi
casperjs --ssl-protocol=any pdfapps.js --user=$username --password=$password --siteurl="$siteurl" --appid=$app --savepath="$savepath"
cd $savepath/$app/generated_pdfs
zip all_pages.zip *
ls -lah .
cd $scripthome
fi
done