Index: sputnik-12.05.29/sputnik/bin/sputnik.lua
===================================================================
--- sputnik-12.05.29.orig/sputnik/bin/sputnik.lua	2012-05-29 18:37:36.000000000 +0200
+++ sputnik-12.05.29/sputnik/bin/sputnik.lua	2012-05-29 21:33:47.000000000 +0200
@@ -1,8 +1,13 @@
+#!/usr/bin/env lua5.1
 
-pcall(require, "luarocks.require")
+-- pcall(require, "luarocks.require")
 
 local function parse_args(arg)
-   local parsed = {}
+   local parsed = {
+       lua = '/usr/bin/env lua5.1',
+       datadir = '/var/www',
+       use_luarocks = '--',
+   } 
    for i,v in ipairs(arg) do
       local flag, val = v:match('^%-%-(%w+)=(.*)')
       if flag then
Index: sputnik-12.05.29/sputnik/lua/sputnik/cli/make-cgi.lua
===================================================================
--- sputnik-12.05.29.orig/sputnik/lua/sputnik/cli/make-cgi.lua	2012-05-29 18:37:36.000000000 +0200
+++ sputnik-12.05.29/sputnik/lua/sputnik/cli/make-cgi.lua	2012-05-29 21:33:47.000000000 +0200
@@ -6,6 +6,6 @@
 
    local without_luarocks = WITHOUT_LUAROCKS or args['without-luarocks']
    installer.reset_salts()
-   installer.make_wsapi_script(dir, "sputnik.ws", {without_luarocks=without_luarocks})
-   installer.make_cgi_file(dir, "sputnik.cgi",  {without_luarocks=without_luarocks})
+   installer.make_wsapi_script(args, "sputnik.ws", {without_luarocks=without_luarocks})
+   installer.make_cgi_file(args, "sputnik.cgi",  {without_luarocks=without_luarocks})
 end
Index: sputnik-12.05.29/sputnik/lua/sputnik/installer.lua
===================================================================
--- sputnik-12.05.29.orig/sputnik/lua/sputnik/installer.lua	2012-05-29 18:37:36.000000000 +0200
+++ sputnik-12.05.29/sputnik/lua/sputnik/installer.lua	2012-05-29 21:33:47.000000000 +0200
@@ -8,18 +8,18 @@
 WS_SCRIPT_TEMPLATE = [=[
 require('sputnik.wsapi_app')
 return sputnik.wsapi_app.new{
-   VERSIUM_PARAMS = { [[$dir/wiki-data/]] },
+   VERSIUM_PARAMS = { [[$datadir/wiki-data/]] },
    BASE_URL       = '/',
    PASSWORD_SALT  = '$password_salt',
    TOKEN_SALT     = '$token_salt',
 }
 ]=]
 
-CGI_TEMPLATE = [=[#! $dir/bin/lua
-$require_luarocks
+CGI_TEMPLATE = [=[#! $lua
+$use_luarocks $require_luarocks
 require('sputnik.wsapi_app')
 local my_app = sputnik.wsapi_app.new{
-   VERSIUM_PARAMS = { [[$dir/wiki-data/]] },
+   VERSIUM_PARAMS = { [[$datadir/wiki-data/]] },
    BASE_URL       = '/cgi-bin/sputnik.cgi',
    PASSWORD_SALT  = '$password_salt',
    TOKEN_SALT     = '$token_salt',
@@ -52,11 +52,11 @@
 end
 
 
-function make_script(dir, subpath, template, options)
+function make_script(args, subpath, template, options)
 
    options = options or {}
 
-   dir = dir or lfs.currentdir()
+   dir =args. dir or lfs.currentdir()
    local path = dir.."/"..subpath
 
    if lfs.attributes(path) then
@@ -81,15 +81,18 @@
                       password_salt = password_salt,
                       token_salt    = token_salt,
                       require_luarocks = require_luarocks,
+                      lua           = args.lua or dir .. '/bin/lua',
+                      datadir       = args.datadir or dir,
+                      use_luarocks  = args.use_luarocks or '',
                    }
    out:write(content)
    out:close()
 end
 
-function make_wsapi_script(dir, subpath, options)
-   make_script(dir, subpath, WS_SCRIPT_TEMPLATE, options)
+function make_wsapi_script(args, subpath, options)
+   make_script(args, subpath, WS_SCRIPT_TEMPLATE, options)
 end
 
-function make_cgi_file(dir, subpath, options)
-   make_script(dir, subpath, CGI_TEMPLATE, options)
+function make_cgi_file(args, subpath, options)
+   make_script(args, subpath, CGI_TEMPLATE, options)
 end
