summaryrefslogtreecommitdiffstats
path: root/var/www/splstr/links.sh
blob: d0ff527da0cf8fdf1dba1c92495d2290d42d3b21 (plain) (blame)
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
#!/bin/sh
echo ne poganjaj na spletnih straneh, ki jim ne zaupaš!
u=http://splet/
[ $1x != x ] && u=$1
co="--location-trusted --silent --fail --output /dev/null --max-time 5"
noop () {
	echo noop $1
}
anyproto () {
	curl http:$1 $co || echo anyproto http: fail $1
	curl https:$1 $co || echo anyproto https: fail $1
}
full () {
	curl $1 $co || echo full fail $1
}
root () {
	origin=`echo $u | cut -d/ -f1,2,3`
	curl $u$1 $co || echo root $u fail $1
}
rel () {
	dir=`echo $u | rev | cut -d/ -f2- | rev`
	curl $dir/$1 $co || echo rel $dir fail $1
}
for i in `curl $u | pup a | tr $' ' $'\n' | grep href | cut -d\" -f2`
do
	printf .
	case $i in
		mail* | xmpp* | mumble* | irc* | tel*)
			noop $i
			;;
		//*)
			anyproto $i
			;;
		http*)
			full $i
			;;
		/*)
			root $i
			;;
		*)
			rel $i
			;;
	esac
done