Show symbolic links AND their targets in web directory listing (apache)
Listing a directory content with ls -l
shows this output:
total 12
drwxr-xr-x 3 root root 4096 Dec 11 16:38 2.3
drwxr-xr-x 5 root root 4096 Dec 11 16:38 2.4
drwxr-xr-x 2 root root 4096 Dec 11 16:38 archive
lrwxrwxrwx 1 root root 10 Dec 11 16:38 current -> 2.4/2.4.1/
lrwxrwxrwx 1 root root 10 Dec 11 16:38 next -> 2.4/2.4.2/
lrwxrwxrwx 1 root root 10 Dec 11 16:38 previous -> 2.4/2.4.0/
Notice how it shows the symbolic links and their respective targets.
I need to know if there is a way of getting the same behaviour in apache directory browsing.
If apache is not capable of it as I suspect, is there an application (FLOSS) providing that kind of behaviour ?
I looked for a solution to this problem in the context of a continuous delivery pipeline. In the binary repository management, versions evolve this way between stages : beta -> rc -> stable.
I use Apache 2.2 to access binary from any server. I decided to use the apache Index description field.
Here is my setup :
1 ) Add fancy indexing in the virtual host config file (ie. /etc/apache2/site-available/my- vhost )
<VirtualHost *: 80 >
...
DocumentRoot /path/to/root
IndexOptions FancyIndexing
...
</ VirtualHost>
2) create a .htaccess file in the root directory (path/to/root) containing symbolic links.
# $version $lifecycle
AddDescription "2.10.0.5" beta
AddDescription "2.10.0.4" rc
AddDescription "2.9.0.9" stable
3) Then use SSH + sed to replace " infile " the version number : here is an example for the beta,
ssh user@server "cd /path/to/root; sed -i 's/AddDescription.*$lifecycle$/AddDescription \"$version\" $lifecycle/g' .htaccess" && {
echo "Success."
} || {
echo "Failed.";
}
Of course this requires some scripting but this solution is sufficiently dynamic to me. .htaccess is taken into account dynamically by Apache.
The target of the symlink is printed under the description column.
Hope this help.