-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue_photo.sh
executable file
·74 lines (60 loc) · 1.11 KB
/
queue_photo.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
#!/bin/sh
queue_dir=.clickr-queue
cp=scp
printHelp()
{
echo "Usage: $0 -p /path/to/photo [-t title] [-d description]"
exit
}
while getopts "p:d:t:l:" opt; do
case $opt in
p)
PHOTO="$OPTARG"
;;
d)
DESCRIPTION="$OPTARG"
;;
t)
TITLE="$OPTARG"
;;
l)
TAGS="$OPTARG"
;;
\?)
printHelp
exit 1
;;
esac
done
if [ ! "$PHOTO" ]
then
printHelp
exit 1
fi
if [ ! "$DESCRIPTION" ]
then
DESCRIPTION=`basename "$PHOTO"`
fi
if [ ! "$TITLE" ]
then
TITLE=`basename "$PHOTO"`
fi
# Ensure there's a valid upload queue directory.
ssh $host "if [ -e \"$queue_dir\" ] && [ ! -d \"$queue_dir\" ] ; then
echo 'Something called '$queue_dir' exists! Remove please.'
exit 1
elif [ ! -e \"$queue_dir\" ]
then
mkdir -p \"$queue_dir\"
fi"
echo "Photo: "$PHOTO
echo "Title: "$TITLE
echo "Description: "$DESCRIPTION
echo "Tags: "$TAGS
$cp "$PHOTO" $host:$queue_dir
tmp=/tmp/`basename "$PHOTO"`.description
echo "TITLE $TITLE" > "$tmp"
echo "DESCRIPTION $DESCRIPTION" >> "$tmp"
echo "TAGS $TAGS" >> "$tmp"
$cp "$tmp" $host:$queue_dir