]> scripts.mit.edu Git - wizard.git/blob - bin/get-url
Move a number of common parameters to the baton.
[wizard.git] / bin / get-url
1 #!/bin/bash
2 # This script is a gem from the Wordpress 2.0.2-2.0.3 upgrade that
3 # calculates the URL a given path will have on scripts. It does three
4 # things:
5 #   1. Resolves all symbolic links
6 #   2. Splits the path on web_scripts to home and path
7 #   3. Use home to ldap search for the name of the locker we're serving
8 #   4. Build the URL from the kaboodle
9 readlink -f $1 | sed 's,/web_scripts, ,' | (read home path; user=$(ldapsearch -LLL -h scripts.mit.edu -x -b ou=People,dc=scripts,dc=mit,dc=edu "homeDirectory=$home" uid | sed -n 's/^uid: // p'); [ -n "$user" ] && echo "http://$user.scripts.mit.edu$path")