Tag Archives: htaccess

Reposado, Ubuntu and Deploy Studio – URL Rewriting

After getting Reposado running on my Ubuntu server,¬†the long, custom URLs – unique to each version of OS X – annoyed me. This also prevented me from using this repository from Deploy Studio because you can’t specify anything other than the base SUS URL in their Software update tool.

There are good URL Rewriting rules available on the github site for Reposado to correct this, but I had trouble configuring Apache2 under Ubuntu so the rewrites would behave.

These are the steps and final configuration files I ended with.

1) Enable the mod_rewrite engine

$ a2enmod rewrite

2) Place the following file in /etc/apache2/sites-enabled. I named mine 0000-reposado.

<VirtualHost *:8088>
  ServerName default
  ServerAdmin taschutt@syr.edu
  DocumentRoot "/Lake/asus/html"
  DirectoryIndex index.html index.php

  ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
  Loglevel warn

  <Directory />
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All

  <IfModule mod_mem_cache.c>
    CacheEnable mem /
    MCacheSize 4096

3) Inform Apache that you have a virtual host listening on port 8088 by editing the /etc/apache2/ports.conf file.

Find this:

NameVirtualHost *:80
Listen 80

And add this below it:

NameVirtualHost *:8088
Listen 8088

4) In the html directory in the Reposado space, create a .htaccess file with the following contents.

RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} Darwin/8
RewriteRule ^index(.*)\.sucatalog$ content/catalogs/index$1.sucatalog [L]
RewriteCond %{HTTP_USER_AGENT} Darwin/9
RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-leopard.merged-1$1.sucatalog [L]
RewriteCond %{HTTP_USER_AGENT} Darwin/10
RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-leopard-snowleopard.merged-1$1.sucatalog [L]
RewriteCond %{HTTP_USER_AGENT} Darwin/11
RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-lion-snowleopard-leopard.merged-1$1.sucatalog [L]
RewriteCond %{HTTP_USER_AGENT} Darwin/12
RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-mountainlion-lion-snowleopard-leopard.merged-1$1.sucatalog [L]

Now, when you deploy a machine with Deploy Studio and use the Software Update feature, it will pull the correct sucatalog based on the OS you’re updating. Just like Apple’s servers.