diff options
author | Natanael Copa <natanael.copa@gmail.com> | 2008-03-27 13:54:16 +0000 |
---|---|---|
committer | Natanael Copa <natanael.copa@gmail.com> | 2008-03-27 13:54:16 +0000 |
commit | 3142bc1bcec3ab55677cdb2cdadf5cf23d15f4b4 (patch) | |
tree | 52ef2dc6343f07199d7c8b03cafdeae572a67ef0 | |
download | acf-ipsec-tools-3142bc1bcec3ab55677cdb2cdadf5cf23d15f4b4.tar.bz2 acf-ipsec-tools-3142bc1bcec3ab55677cdb2cdadf5cf23d15f4b4.tar.xz |
added ipsec-tools
git-svn-id: svn://svn.alpinelinux.org/acf/ipsec-tools/trunk@845 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | Makefile | 47 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | config.mk | 10 | ||||
-rw-r--r-- | ipsec-tools-controller.lua | 25 | ||||
-rw-r--r-- | ipsec-tools-model.lua | 56 | ||||
-rw-r--r-- | ipsec-tools-status-html.lsp | 55 | ||||
-rw-r--r-- | ipsec-tools.menu | 3 |
7 files changed, 198 insertions, 0 deletions
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 @@ -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 @@ +<? local form = ... ?> +<? +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(form)) +io.write("</span>") +--]] +?> + +<? +function informationform(myform,tags) + for k,v in pairs(tags) do + if (myform[v]) then + local val = myform[v] + io.write("\t<DT") + if (#val.errtxt > 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "</DT>\n") + + io.write("\t\t<DD>" .. val.value .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end + if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end + io.write("\t\t</DD>\n") + end + end +end +?> + +<H1>SYSTEM INFO</H1> +<DL> +<? +local myform = form.status +local tags = { "status", "version", } +informationform(myform,tags) +?> +</DL> + +<? ---[[ ?> +<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2> +<DL> +<? +--local myform = form.status +--local tags = { "stats", } +--informationform(myform,tags) +?> +<? --]] ?> + + +<? +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(form)) +io.write("</span>") +--]] +?> + 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 + |