From a8b03832913061456afd218987402fed23ad076d Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 28 Mar 2008 09:03:33 +0000 Subject: Renamed ipsec-tools to ipsectools to come around a but with the menu-system git-svn-id: svn://svn.alpinelinux.org/acf/ipsec-tools/trunk@850 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 8 ++-- ipsec-tools-controller.lua | 25 ---------- ipsec-tools-model.lua | 113 -------------------------------------------- ipsec-tools-status-html.lsp | 86 --------------------------------- ipsec-tools.menu | 3 -- ipsectools-controller.lua | 25 ++++++++++ ipsectools-model.lua | 110 ++++++++++++++++++++++++++++++++++++++++++ ipsectools-status-html.lsp | 63 ++++++++++++++++++++++++ ipsectools.menu | 3 ++ 9 files changed, 205 insertions(+), 231 deletions(-) delete mode 100644 ipsec-tools-controller.lua delete mode 100644 ipsec-tools-model.lua delete mode 100644 ipsec-tools-status-html.lsp delete mode 100644 ipsec-tools.menu create mode 100644 ipsectools-controller.lua create mode 100644 ipsectools-model.lua create mode 100644 ipsectools-status-html.lsp create mode 100644 ipsectools.menu diff --git a/Makefile b/Makefile index 49bde55..d658971 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ PACKAGE=acf-$(APP_NAME) VERSION=0.1 APP_DIST=\ - ipsec-tools-controller.lua \ - ipsec-tools-model.lua \ - ipsec-tools-status-html.lsp \ - ipsec-tools.menu \ + ipsectools-controller.lua \ + ipsectools-model.lua \ + ipsectools-status-html.lsp \ + ipsectools.menu \ EXTRA_DIST=README Makefile config.mk diff --git a/ipsec-tools-controller.lua b/ipsec-tools-controller.lua deleted file mode 100644 index 2a31dd6..0000000 --- a/ipsec-tools-controller.lua +++ /dev/null @@ -1,25 +0,0 @@ -module(..., package.seeall) - --- This is the object/text used when we want to add a new record - -require("format") - -local list_redir = function (self) - self.conf.action = "status" - self.conf.type = "redir" - error (self.conf) -end - -mvc = {} -mvc.on_load = function(self, parent) - if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then - self.worker[self.conf.action] = list_redir(self) - end -end - --- ################################################################################ --- PUBLIC FUNCTIONS -function status(self) - return { status=self.model.getstatus() } -end - diff --git a/ipsec-tools-model.lua b/ipsec-tools-model.lua deleted file mode 100644 index ece5886..0000000 --- a/ipsec-tools-model.lua +++ /dev/null @@ -1,113 +0,0 @@ -module(..., package.seeall) - -require("fs") -require("procps") -require("getopts") -require("format") -require("daemoncontrol") -require("validator") - -local configfile = "/etc/racoon/racoon.conf" -local processname = "racoon" -local pkgname = "ipsec-tools" -local baseurl = "/etc/racoon/" - -local function get_version() - local cmd_output_result, cmd_output_error - local cmd = "/sbin/apk_version -vs " .. pkgname .." 2>/dev/null" - local f = io.popen( cmd ) - local cmdresult = f:read("*l") - if (cmdresult) and (#cmdresult > 0) then - cmd_output_result = string.match(cmdresult,"^%S*") or "Unknown" - else - cmd_output_error = "Program not installed" - end - f:close() - return cmd_output_result,cmd_output_error -end - -local function autostarts() - local cmd_output_result, cmd_output_error - local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null" - local f = io.popen( cmd ) - local cmdresult = f:read("*a") - if (cmdresult) and (#cmdresult > 0) then - cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')" - else - cmd_output_error = "Not programmed to autostart" - end - f:close() - return cmd_output_result,cmd_output_error - -end - -local function racoonctl(proto) - local cmd_output_result, cmd_output_error - local cmd = "/usr/sbin/racoonctl show-sa ".. proto .. " 2>/dev/null" - local f = io.popen( cmd ) - local cmdresult = f:read("*a") - if (cmdresult) and (#cmdresult > 0) then - cmd_output_result = cmdresult - else - cmd_output_error = "Not programmed to autostart" - end - f:close() - return cmd_output_result,cmd_output_error - -end - -function process_status_text(procname) - local t = procps.pidof(procname) - if #t > 0 then - return "Enabled" - else - return "Disabled" - end -end - --- ################################################################################ --- PUBLIC FUNCTIONS - - -function getstatus() - local status = {} - status.version = cfe({ name = "version", - label="Program version", - value=get_version(), - }) - status.status = cfe({ name="status", - label="Program status", - value=process_status_text(processname), - }) - local autostart_sequense, autostart_errtxt = autostarts() - status.autostart = cfe({ name="autostart", - label="Autostart sequence", - value=autostart_sequense, - errtxt=autostart_errtxt, - }) - - local racoon_sequense, racoon_errtxt = racoonctl("isakmp") - status.show_isakmp = cfe({ name="show_isakmp", - label="racoon show-sa isakmp", - value=racoon_sequense, - errtxt=racoon_errtxt, - }) - - local racoon_sequense, racoon_errtxt = racoonctl("esp") - status.show_esp = cfe({ name="show_esp", - label="racoon show-sa esp", - value=racoon_sequense, - errtxt=racoon_errtxt, - }) - - local racoon_sequense, racoon_errtxt = racoonctl("ah") - status.show_ah = cfe({ name="show_ah", - label="racoon show-sa ah", - value=racoon_sequense, - errtxt=racoon_errtxt, - }) - - return status -end - - diff --git a/ipsec-tools-status-html.lsp b/ipsec-tools-status-html.lsp deleted file mode 100644 index 34b1248..0000000 --- a/ipsec-tools-status-html.lsp +++ /dev/null @@ -1,86 +0,0 @@ - -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> - - 0) then io.write(" class='error'") end - io.write(">" .. val.label .. "\n") - - io.write("\t\t
" .. val.value .. "\n") - if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end - if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end - io.write("\t\t
\n") - end - end -end -?> - -

SYSTEM INFO

-
- -
- -

PROGRAM SPECIFIC OPTIONS/INFORMATION

-
- 0) then io.write(" class='error'") end -io.write(">" .. myform.label .. "\n") - -io.write("\t\t
" .. myform.value .. "
\n") -if (myform.descr) and (#myform.descr > 0) then io.write("\t\t

" .. string.gsub(myform.descr, "\n", "
") .. "

\n") end -if (#myform.errtxt > 0) then io.write("\t\t

" .. string.gsub(myform.errtxt, "\n", "
") .. "

\n") end -io.write("\t\t
\n") - -?> - 0) then io.write(" class='error'") end -io.write(">" .. myform.label .. "\n") - -io.write("\t\t
" .. myform.value .. "
\n") -if (myform.descr) and (#myform.descr > 0) then io.write("\t\t

" .. string.gsub(myform.descr, "\n", "
") .. "

\n") end -if (#myform.errtxt > 0) then io.write("\t\t

" .. string.gsub(myform.errtxt, "\n", "
") .. "

\n") end -io.write("\t\t
\n") - -?> - 0) then io.write(" class='error'") end -io.write(">" .. myform.label .. "\n") - -io.write("\t\t
" .. myform.value .. "
\n") -if (myform.descr) and (#myform.descr > 0) then io.write("\t\t

" .. string.gsub(myform.descr, "\n", "
") .. "

\n") end -if (#myform.errtxt > 0) then io.write("\t\t

" .. string.gsub(myform.errtxt, "\n", "
") .. "

\n") end -io.write("\t\t
\n") - -?> - -
- - -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -?> - diff --git a/ipsec-tools.menu b/ipsec-tools.menu deleted file mode 100644 index 17e5df1..0000000 --- a/ipsec-tools.menu +++ /dev/null @@ -1,3 +0,0 @@ -#CAT GROUP/DESC TAB ACTION -Networking 45IPsec Status status - diff --git a/ipsectools-controller.lua b/ipsectools-controller.lua new file mode 100644 index 0000000..2a31dd6 --- /dev/null +++ b/ipsectools-controller.lua @@ -0,0 +1,25 @@ +module(..., package.seeall) + +-- This is the object/text used when we want to add a new record + +require("format") + +local list_redir = function (self) + self.conf.action = "status" + self.conf.type = "redir" + error (self.conf) +end + +mvc = {} +mvc.on_load = function(self, parent) + if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then + self.worker[self.conf.action] = list_redir(self) + end +end + +-- ################################################################################ +-- PUBLIC FUNCTIONS +function status(self) + return { status=self.model.getstatus() } +end + diff --git a/ipsectools-model.lua b/ipsectools-model.lua new file mode 100644 index 0000000..5545c78 --- /dev/null +++ b/ipsectools-model.lua @@ -0,0 +1,110 @@ +module(..., package.seeall) + +require("fs") +require("procps") +require("getopts") +require("format") +require("daemoncontrol") +require("validator") + +local configfile = "/etc/racoon/racoon.conf" +local processname = "racoon" +local pkgname = "ipsec-tools" +local baseurl = "/etc/racoon/" + +local function get_version() + local cmd_output_result, cmd_output_error + local cmd = "/sbin/apk_version -vs " .. pkgname .." 2>/dev/null" + local f = io.popen( cmd ) + local cmdresult = f:read("*l") + if (cmdresult) and (#cmdresult > 0) then + cmd_output_result = string.match(cmdresult,"^%S*") or "Unknown" + else + cmd_output_error = "Program not installed" + end + f:close() + return cmd_output_result,cmd_output_error +end + +local function autostarts() + local cmd_output_result + local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null" + local f = io.popen( cmd ) + local cmdresult = f:read("*a") + if (cmdresult) and (#cmdresult > 0) then + cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')" + else + cmd_output_error = "Not programmed to autostart" + end + f:close() + return cmd_output_result + +end + +local function racoonctl() + local cmd_output_result, cmd_output_error + local cmd = "/usr/sbin/racoonctl -lll show-sa isakmp 2>/dev/null" + local f = io.popen( cmd ) + local cmd_output_result = f:read("*a") + f:close() + return cmd_output_result,cmd_output_error +end + +local function ip_xfrm(mode) + local cmd_output_result + local cmd = "/bin/ip xfrm " .. mode .. " 2>/dev/null" + local f = io.popen( cmd ) + local cmd_output_result = f:read("*a") + f:close() + return cmd_output_result +end + +function process_status_text(procname) + local t = procps.pidof(procname) + if #t > 0 then + return "Enabled" + else + return "Disabled" + end +end + +-- ################################################################################ +-- PUBLIC FUNCTIONS + + +function getstatus() + local status = {} + status.version = cfe({ name = "version", + label="Program version", + value=get_version(), + }) + status.status = cfe({ name="status", + label="Program status", + value=process_status_text(processname), + }) + local autostart_sequense, autostart_errtxt = autostarts() + status.autostart = cfe({ name="autostart", + label="Autostart sequence", + value=autostart_sequense, + errtxt=autostart_errtxt, + }) + + status.show_isakmp = cfe({ name="show_isakmp", + label="racoonctl -lll show-sa isakmp", + value=racoonctl(), + }) + + status.ip_xfrm_state = cfe({ name="show_esp", + label="ip xfrm state", + value=ip_xfrm("state"), + }) + + status.ip_xfrm_policy = cfe({ name="ip_xfrm_policy", + label="ip xfrm policy", + value=ip_xfrm("policy"), + }) + + return status +end + + diff --git a/ipsectools-status-html.lsp b/ipsectools-status-html.lsp new file mode 100644 index 0000000..6215542 --- /dev/null +++ b/ipsectools-status-html.lsp @@ -0,0 +1,63 @@ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + + 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "\n") + + io.write("\t\t
" .. val.value .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end + if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end + io.write("\t\t
\n") + end + end +end +?> + +

SYSTEM INFO

+
+ +
+ +

PROGRAM SPECIFIC OPTIONS/INFORMATION

+
+" .. myform.label .. "\n") +io.write("\t\t
" .. myform.value .. "

\n") + +local myform = form.status.ip_xfrm_state +io.write("\t\t

" .. myform.label .. "\n") +io.write("\t\t

" .. myform.value .. "

\n") + +local myform = form.status.ip_xfrm_policy +io.write("\t\t

" .. myform.label .. "\n") +io.write("\t\t

" .. myform.value .. "

\n") +?> + +
+ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + diff --git a/ipsectools.menu b/ipsectools.menu new file mode 100644 index 0000000..17e5df1 --- /dev/null +++ b/ipsectools.menu @@ -0,0 +1,3 @@ +#CAT GROUP/DESC TAB ACTION +Networking 45IPsec Status status + -- cgit v1.2.3