From 3142bc1bcec3ab55677cdb2cdadf5cf23d15f4b4 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 27 Mar 2008 13:54:16 +0000 Subject: added ipsec-tools git-svn-id: svn://svn.alpinelinux.org/acf/ipsec-tools/trunk@845 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 47 +++++++++++++++++++++++++++++++++++++ README | 2 ++ config.mk | 10 ++++++++ ipsec-tools-controller.lua | 25 ++++++++++++++++++++ ipsec-tools-model.lua | 56 +++++++++++++++++++++++++++++++++++++++++++++ ipsec-tools-status-html.lsp | 55 ++++++++++++++++++++++++++++++++++++++++++++ ipsec-tools.menu | 3 +++ 7 files changed, 198 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 100644 config.mk create mode 100644 ipsec-tools-controller.lua create mode 100644 ipsec-tools-model.lua create mode 100644 ipsec-tools-status-html.lsp create mode 100644 ipsec-tools.menu diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..49bde55 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +APP_NAME=ipsec-tools +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 \ + + +EXTRA_DIST=README Makefile config.mk + +DISTFILES=$(APP_DIST) $(EXTRA_DIST) + +TAR=tar + +P=$(PACKAGE)-$(VERSION) +tarball=$(P).tar.bz2 +install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME) + +all: +clean: + rm -rf $(tarball) $(P) + +dist: $(tarball) + +install: + mkdir -p "$(install_dir)" + cp -a $(APP_DIST) "$(install_dir)" + +$(tarball): $(DISTFILES) + rm -rf $(P) + mkdir -p $(P) + cp $(DISTFILES) $(P) + $(TAR) -jcf $@ $(P) + rm -rf $(P) + +# target that creates a tar package, unpacks is and install from package +dist-install: $(tarball) + $(TAR) -jxf $(tarball) + $(MAKE) -C $(P) install DESTDIR=$(DESTDIR) + rm -rf $(P) + +include config.mk + +.PHONY: all clean dist install dist-install diff --git a/README b/README new file mode 100644 index 0000000..35eaff2 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +ACF for ipsec-tools + diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..45f4d21 --- /dev/null +++ b/config.mk @@ -0,0 +1,10 @@ +prefix=/usr +datadir=${prefix}/share +sysconfdir=${prefix}/etc +localstatedir=${prefix}/var +acfdir=${datadir}/acf +wwwdir=${acfdir}/www +cgibindir=${acfdir}/cgi-bin +appdir=${acfdir}/app +acflibdir=${acfdir}/lib +sessionsdir=${localstatedir}/lib/acf/sessions diff --git a/ipsec-tools-controller.lua b/ipsec-tools-controller.lua new file mode 100644 index 0000000..2a31dd6 --- /dev/null +++ b/ipsec-tools-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/ipsec-tools-model.lua b/ipsec-tools-model.lua new file mode 100644 index 0000000..3994007 --- /dev/null +++ b/ipsec-tools-model.lua @@ -0,0 +1,56 @@ +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 + + +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), + }) + return status +end + + diff --git a/ipsec-tools-status-html.lsp b/ipsec-tools-status-html.lsp new file mode 100644 index 0000000..f3acbb4 --- /dev/null +++ b/ipsec-tools-status-html.lsp @@ -0,0 +1,55 @@ + +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

+
+ + + + +DEBUGGING

DEBUG INFO: CFE

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