Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
blob: 60314ea3f0a6b29106f23e705518b37886224e4e (plain)
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
#!/bin/bash
# $Id$
# Use with cron:
# 15      21      *       *       4       /home/shtrom/bin/cloud_backup.sh
delicious_USER=<+DELICIOUS_LOGIN+>
delicious_PASS=<+DELICIOUS_PASS+>
delicious_URL=https://api.del.icio.us/v1/posts/all
#delicious_POST="include_tags=yes&include_notes=yes"

_citeulike_USER=<+CITEULIKE_LOGIN+>
#citeulike_USER=<+CITEULIKE_LOGIN+>
#citeulike_PASS=<+CITEULIKE_PASS+>
citeulike_URL="http://www.citeulike.org/bibtex/user/${_citeulike_USER}?incl_amazon=0&clean_urls=0&smart_wrap=0"

SITES="delicious citeulike"

DATE=`date +%Y-%m-%d`

function wgetit() {
	SITE=$1
	DATE=$2
	SITE_URL=$3
	SITE_USER=$4
	SITE_PASS=$5
	SITE_POST=$6
	wget -U "$0" --no-check-certificate -q -O ${SITE}.${DATE} \
		${SITE_URL} ${SITE_POST:+--post-data ${SITE_POST}} \
		${SITE_USER:+--user=${SITE_USER}} \
	       	${SITE_PASS:+--password=${SITE_PASS}}
}

function curlit() {
	SITE=$1
	DATE=$2
	SITE_URL=$3
	SITE_USER=$4
	SITE_PASS=$5
	SITE_POST=$6
	curl -A "$0" -k -s -o ${SITE}.${DATE} \
		${SITE_URL} ${SITE_POST:+--d ${SITE_POST}} \
		${SITE_USER:+--user ${SITE_USER}:${SITE_PASS}}
}

for SITE in ${SITES}; do
	eval SITE_URL=\$${SITE}_URL
	eval SITE_USER=\$${SITE}_USER
	eval SITE_PASS=\$${SITE}_PASS
	eval SITE_POST=\$${SITE}_POST
	curlit "$SITE" "$DATE" "$SITE_URL" "$SITE_USER" "$SITE_PASS" "$SITE_POST"
	RET=$?
	if [ $RET != 0 -o ! -s ${SITE}.${DATE} ];then
		echo "$0: An error occurred with site ${SITE}: ret=${RET}"
	fi
done