#!/usr/bin/ruby
#
# goprint-notify
# GoPrint notifier invoker for CUPS 1.2+ integration.
#
# Copyright (c) 2007-2008 GoPrint Systems, Inc.  All rights reserved.
#

# Find the real location
begin
  realLocation = File.readlink($0)
  realLocation.reverse!
  fileIndex = realLocation.index("/")
  realLocation = realLocation[fileIndex+1..realLocation.length]
  fileIndex = realLocation.index("/")
  realLocation = realLocation[fileIndex..realLocation.length]
  realLocation.reverse!
  GS4Home = realLocation
rescue => e
  # if the file is not a symlink the call to readlink will throw invalid arg exception 
  GS4Home = '/usr/local/gs4/'
end

# Require the notifier
require GS4Home + "lib/gpcupsnotify"

# Create the notifier
notifier = GoPrintCUPSNotifier.new(Configuration)
# Run the notifier
notifier.runNotifier(STDIN)
