Sunday, 16 January 2011

Compiling Squid on OSX

In a burst of enthusiasm I decided to try to build and compile Squid on OSX.

First you need XCode and developer tools from either your DVD or the Apple web site.

Then download the source code from squid-cache.org. Current version is 3.1.10 released 22 Dec 2010. Current version are here. I downloaded the bz2, any will work. I moved it to the XCode folder on my hard disk, in the path

/XCode/squid

The run these commands:


tar xjf squid-3.1.10.tar.bz2
cd squid-3.1.10
./configure --enable-ssl
make
sudo make install

Some notes:

  • Don't have any spaces in the path to the source code else the build WILL fail!
  • The only build option I used is to enable SSL so I can proxy https. For a full list of whats available you can do
    ./configure --help
    for ease of use you can pipe this to a text file for reading:
    ./configure --help >build_options.txt
  • It can take some time, do not worry
  • You will get some errors, do not worry, as long as there is no space in the path!
  • If you do get errors, likely XCode needs re-installing
This builds squid and put in in the default location which is

/usr/local/squid

It also has the default modules, so you can play.

Next, chown the Squid's directory so it has write access to its logs and caches:

sudo chown -R nobody:wheel /usr/local/squid


Then you need to create the cache directories:

sudo /usr/local/squid/sbin/squid -z

The default config file works OK! The only out of the box change I would make is to remove the image from the error file. In the file

/usr/local/squid/etc/errorpage.css

find the line

"background: url('http://www.squid-cache.org/Artwork/SN.png') no-repeat left;"

and delete it. Save the file.

Now, start Squid:

sudo /usr/local/squid/sbin/squid

You can point you local machine to 127.0.0.1:3128 and show its working.

if you decide to enable the cache, and then do

sudo /usr/local/squid/sbin/squid -k reconfigure

you might get

"2011/01/15 14:44:08| WARNING cache_mem is larger than total disk cache space!"

do not worry, its a spurious error. Things will still work OK.

See some other postings on
Squid and OSX.

Friday, 14 January 2011

Squid - logging in regular date and time format, and other options

If you use Squid, you'll know that for the longest time it used Unix epoch system for its logs. There are various ways to convert to readable form such as using SARG, though thats not very elegant. With v2 there was an option to log in regular httpd format, by using the option "emulate_httpd_log", but that no longer works.

Now with Squid v3.x, you can choose your logging format, and you can log different detail to different logs. Great!

In your squid.conf file, add the following:
    # log formats

    access_log /usr/local/squid/var/logs/access.log squid

    access_log /usr/local/squid/var/logs/access-GMTtime.log customformat
    logformat customformat %tg.%03tu response:%tr %>a server:%Hs size:%

The line "# log formats" just tells the reader of the config file, most likely you but you never know, that this bit is to set log file options.

The next line tells squid to log in the old Squid manner, and default details.

The third line tells squid that you want to do something custom: we tell squid to also log to an additional log "access-localtime.log".

The final line defines the options we want. My example uses options chosen pretty much the old defaults details, but using GMT for human readable date / time, and I added some of the new options. For a full list consult the squid manual.

Thursday, 13 January 2011

Creating a file and folder listing in OSX

I needed to create a file and folder listing to check for duplicate and incorrectly named photos and other files.

Since OSX is based on unix, you can use the 'ls' command in terminal. Navigate to where you want to start from:

    cd ~/pictures/nikon

and then run

    ls -R > picture.listing.txt

This command moves through all the folders within 'nikon' and sends the name of each folder and file to the file picture.listing.txt.

Wednesday, 12 January 2011

What does DSDT stand for?

Well I have wondered, since its discussed on many Hackintosh sites. Well here it is:

DSDT = Differentiated System Description Table