]> git.armaanb.net Git - bin.git/blob - slink
xsel: new script
[bin.git] / slink
1 #!/usr/bin/env sh
2
3 awk -v path=$PATH_INFO '
4 BEGIN {
5                 if (path == "/") {
6                                 print "Content-type: text/plain\n \
7 You'\''ve reached Armaan'\''s link shortner. Not much to see here on the index"
8                                 cut = 1
9                                 exit 1
10                 }
11 }
12
13 path == $1 {
14                 printf "Content-type: text/html\n \
15 <!DOCTYPE html><html lang=\"en\"><head> \
16 <meta http-equiv=\"refresh\" content=\"0; URL=%s\"> \
17 </head><body> \
18 <p>If you are not redirected automatically, please follow this link: \
19 <a href=\"%s\">%s</a>.</p> \
20 </body></html>\n", $2, $2, $2
21                 cut = 1
22                 exit 0
23 }
24
25 END {
26                 if (cut) exit 0
27                 print "Status: 404 \
28 Content-type: text/plain\n \
29 Path not found."
30 }
31 ' ${1:-/etc/slink}