-
Notifications
You must be signed in to change notification settings - Fork 0
/
promupping.sh
executable file
·73 lines (57 loc) · 1.95 KB
/
promupping.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
#! /bin/sh
#================================================================
# promupping
# Notify site update to public subscription services
#================================================================
# configuration
mode="$1"
id="$2"
newfile="$3"
oldfile="$4"
ts="$5"
user="$6"
baseurl="$7"
curl="curl --silent --fail --connect-timeout 1 --max-time 1"
# set variables
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
PATH="$PATH:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
LANG=C
LC_ALL=C
export LD_LIBRARY_PATH PATH LANG LC_ALL
# ping to Google blog search
pingurl="http://blogsearch.google.co.jp/ping"
ename=`printf '%s' "$TP_TITLE" | tcucodec url`
if [ "$mode" = "comment" ] ; then
ehtmlurl=`printf '%s' "$baseurl?id=$id" | tcucodec url`
eatomurl=`printf '%s' "$baseurl?format=atom&id=$id" | tcucodec url`
else
ehtmlurl=`printf '%s' "$baseurl" | tcucodec url`
eatomurl=`printf '%s' "$baseurl?format=atom&act=timeline&order=cdate" | tcucodec url`
fi
fullurl="$pingurl?name=$ename&url=$ehtmlurl&changesURL=$eatomurl"
$curl "$fullurl" >/dev/null 2>&1
[ "$?" = 0 ] || err="$err[google]"
# ping to Yahoo Japan blog search
pingurl="http://api.my.yahoo.co.jp/rss/ping"
if [ "$mode" = "comment" ] ; then
eatomurl=`printf '%s' "$baseurl?format=atom&id=$id" | tcucodec url`
else
eatomurl=`printf '%s' "$baseurl?format=atom&act=timeline&order=cdate" | tcucodec url`
fi
fullurl="$pingurl?u=$eatomurl"
$curl "$fullurl" >/dev/null 2>&1
[ "$?" = 0 ] || err="$err[yahooj]"
# ping to a hub of Pubsubhubbub
pingurl="http://pubsubhubbub.appspot.com/publish"
if [ "$mode" = "comment" ] ; then
eatomurl=`printf '%s' "$baseurl?format=atom&id=$id" | tcucodec url`
else
eatomurl=`printf '%s' "$baseurl?format=atom&act=timeline&order=cdate" | tcucodec url`
fi
$curl -X POST --data "hub.mode=publish" --data "hub.url=$eatomurl" \
"$pingurl" >/dev/null 2>&1
[ "$?" = 0 ] || err="$err[pubsub]"
# exit normally
[ -z "$err" ] || exit 1
exit 0
# END OF FILE