diff options
Diffstat (limited to 'PolygLua.lua')
-rwxr-xr-x | PolygLua.lua | 104 |
1 files changed, 85 insertions, 19 deletions
diff --git a/PolygLua.lua b/PolygLua.lua index bd7bd4d..86dc8be 100755 --- a/PolygLua.lua +++ b/PolygLua.lua | |||
@@ -313,27 +313,93 @@ end | |||
313 | 313 | ||
314 | 314 | ||
315 | 315 | ||
316 | if arg[0] == './PolygLua.lua' then | 316 | _.who = __[[whoami]]:noErr():Do().lines[1] |
317 | local w = __[[whoami]]:noErr():Do().lines[1] | 317 | _.dir = __[[pwd]]:noErr():Do().lines[1] |
318 | local d = __[[pwd]]:noErr():Do().lines[1] | 318 | |
319 | local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() | 319 | |
320 | for i,l in ipairs(luas.lines) do | 320 | |
321 | local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' | 321 | if (arg[0] == './PolygLua.lua') or (arg[0] == 'PolygLua.lua') then |
322 | if _.exists(lua) then | 322 | local options = |
323 | print(lua .. ' installed') | 323 | { |
324 | else | 324 | install = |
325 | if 'root' == w then | 325 | { |
326 | print('Installing ' .. lua) | 326 | help = 'Command to install PolygLua.lua', |
327 | __('mkdir -p /usr/local/share/lua/' .. l:sub(16) .. ' ; ln -s ' .. d .. '/PolygLua.lua ' .. lua):Do() | 327 | func = function(self, options, a, args, i) |
328 | else | 328 | if 'root' ~= _.who then |
329 | print(lua .. ' NOT installed') | 329 | E'Need to be root user to install.' |
330 | else | ||
331 | print('INSTALLING PolygLua.lua!!!') | ||
332 | |||
333 | local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() | ||
334 | for i,l in ipairs(luas.lines) do | ||
335 | local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' | ||
336 | if _.exists(lua) then | ||
337 | print(lua .. ' installed') | ||
338 | else | ||
339 | if 'root' == _.who then | ||
340 | print('Installing ' .. lua) | ||
341 | __('mkdir -p /usr/local/share/lua/' .. l:sub(16) .. ' ; ln -s ' .. _.dir .. '/PolygLua.lua ' .. lua):Do() | ||
342 | else | ||
343 | print(lua .. ' NOT installed') | ||
344 | end | ||
345 | end | ||
346 | end | ||
347 | |||
348 | end | ||
349 | -- os.exit(0) | ||
330 | end | 350 | end |
331 | end | 351 | }, |
332 | end | 352 | uninstall = |
353 | { | ||
354 | help = 'Command to uninstall PolygLua.lua', | ||
355 | func = function(self, options, a, args, i) | ||
356 | if 'root' ~= _.who then | ||
357 | E'Need to be root user to uninstall.' | ||
358 | else | ||
359 | print('UNINSTALLING PolygLua.lua!!!') | ||
360 | |||
361 | local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() | ||
362 | for i,l in ipairs(luas.lines) do | ||
363 | local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' | ||
364 | if _.exists(lua) then | ||
365 | if 'root' == _.who then | ||
366 | print('Uninstalling ' .. lua) | ||
367 | __('rm ' .. lua):Do() | ||
368 | end | ||
369 | end | ||
370 | end | ||
333 | 371 | ||
334 | if 'root' ~= w then | 372 | end |
335 | E'Need to be root user to install.' | 373 | -- os.exit(0) |
336 | end | 374 | end |
375 | }, | ||
376 | purge = | ||
377 | { | ||
378 | help = 'Command to purge PolygLua.lua', | ||
379 | func = function(self, options, a, args, i) | ||
380 | if 'root' ~= _.who then | ||
381 | E'Need to be root user to purge.' | ||
382 | else | ||
383 | print('PURGING PolygLua.lua!!!') | ||
384 | |||
385 | local luas = __'ls -d1 /usr/share/lua/*':noErr():Do() | ||
386 | for i,l in ipairs(luas.lines) do | ||
387 | local lua = '/usr/local/share/lua/' .. l:sub(16) .. '/PolygLua.lua' | ||
388 | if _.exists(lua) then | ||
389 | if 'root' == _.who then | ||
390 | print('Purging ' .. lua) | ||
391 | __('rm ' .. lua):Do() | ||
392 | end | ||
393 | end | ||
394 | end | ||
395 | |||
396 | end | ||
397 | -- os.exit(0) | ||
398 | end | ||
399 | }, | ||
400 | } | ||
401 | |||
402 | _.parse(arg, options) | ||
337 | end | 403 | end |
338 | 404 | ||
339 | 405 | ||