summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-10-03 20:13:44 +0000
committerTed Trask <ttrask01@yahoo.com>2008-10-03 20:13:44 +0000
commita0fc80ea045a64c0b03d9b0103da9e5644e6ca3a (patch)
treed592cb8b1075e9c45f7467acb4e7c72778ee5b2d
downloadacf-samba-a0fc80ea045a64c0b03d9b0103da9e5644e6ca3a.tar.bz2
acf-samba-a0fc80ea045a64c0b03d9b0103da9e5644e6ca3a.tar.xz
Added samba controller.
git-svn-id: svn://svn.alpinelinux.org/acf/samba/trunk@1541 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile44
-rw-r--r--README0
-rw-r--r--config.mk10
-rw-r--r--samba-controller.lua22
l---------samba-expert-html.lsp1
-rw-r--r--samba-join-html.lsp18
-rw-r--r--samba-model.lua96
l---------samba-startstop-html.lsp1
l---------samba-status-html.lsp1
-rw-r--r--samba.menu4
-rw-r--r--samba.roles2
11 files changed, 199 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c79d9ed
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=samba
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.0.1
+
+APP_DIST=\
+ samba* \
+
+
+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 -a $(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..e69de29
--- /dev/null
+++ b/README
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/samba-controller.lua b/samba-controller.lua
new file mode 100644
index 0000000..4083ce2
--- /dev/null
+++ b/samba-controller.lua
@@ -0,0 +1,22 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("controllerfunctions")
+
+default_action = "status"
+
+function status(self)
+ return self.model.getstatus()
+end
+
+function startstop(self)
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata)
+end
+
+function expert(self)
+ return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Saved")
+end
+
+function join(self)
+ return controllerfunctions.handle_form(self, self.model.get_join, self.model.set_join, self.clientdata, "Join", "Join Domain")
+end
diff --git a/samba-expert-html.lsp b/samba-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/samba-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/samba-join-html.lsp b/samba-join-html.lsp
new file mode 100644
index 0000000..81857af
--- /dev/null
+++ b/samba-join-html.lsp
@@ -0,0 +1,18 @@
+<% local form, viewlibrary, page_info = ...
+require("viewfunctions")
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
+
+<H1><%= form.label %></H1>
+<%
+ form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
+ local order = {"domain", "login", "password"}
+ displayform(form, order)
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/samba-model.lua b/samba-model.lua
new file mode 100644
index 0000000..34f6ac3
--- /dev/null
+++ b/samba-model.lua
@@ -0,0 +1,96 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("validator")
+require("fs")
+require("posix")
+require("format")
+
+-- Set variables
+local configfile = "/etc/samba/smb.conf"
+local confdfile = "/etc/conf.d/samba"
+local processname = "smbd"
+local packagename = "samba"
+local initname = "samba"
+
+local configcontent
+local config
+
+local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(initname, action)
+end
+
+function getstatus()
+ return modelfunctions.getstatus(processname, packagename, "Samba Status", initname)
+end
+
+function getconfigfile()
+ return modelfunctions.getfiledetails(configfile)
+end
+
+function setconfigfile(filedetails)
+ filedetails.value.filename.value = configfile
+ return modelfunctions.setfiledetails(filedetails)
+end
+
+function get_join()
+ local connect = {}
+ connect.domain = cfe({ label="Domain" })
+ --connect.style = cfe({ type="select", value="Active Directory", label="Domain Controller type", option={"Active Directory", "NT4-style"} })
+ connect.login = cfe({ label="Domain Controller login" })
+ connect.password = cfe({ label="Domain Controller password" })
+
+ configcontent = configcontent or fs.read_file(configfile) or ""
+ config = config or format.parse_ini_file(configcontent)
+ if config and config.global and config.global.workgroup then
+ connect.domain.value = config.global.workgroup
+ end
+
+ local f = io.popen(path.."net rpc testjoin 2<&1")
+ local status = f:read("*a")
+ f:close()
+
+ return cfe({ type="group", value=connect, label="Join a Domain", descr=status })
+end
+
+function set_join(connect)
+ configcontent = configcontent or fs.read_file(configfile) or ""
+
+ configcontent = format.update_ini_file(configcontent, "global", "security", "domain")
+ configcontent = format.update_ini_file(configcontent, "global", "workgroup", connect.value.domain.value)
+ configcontent = format.update_ini_file(configcontent, "global", "encrypt passwords", "yes")
+ configcontent = format.update_ini_file(configcontent, "global", "password server", "*")
+ fs.write_file(configfile, configcontent)
+ configcontent = nil
+ config = nil
+
+ local cmd = path
+ --if connect.value.style.value == "Active Directory" then
+ -- cmd = cmd .. "net ads join"
+ --else
+ cmd = cmd .. "net rpc join"
+ --end
+ cmd = cmd .. " -U"..connect.value.login.value.."%"..connect.value.password.value.." 2>&1"
+ local f = io.popen(cmd)
+ connect.descr = f:read("*a")
+ f:close()
+
+ -- the conf.d file doesn't automatically include winbindd
+ local content = fs.read_file(confdfile)
+ local list = format.parse_ini_file(content, "", "daemon_list")
+ if not string.find(list, "winbind") then
+ content = format.update_ini_file(content, "", "daemon_list", string.gsub(list, '"$', ' winbind"'))
+ fs.write_file(confdfile, content)
+ end
+
+ return connect
+end
diff --git a/samba-startstop-html.lsp b/samba-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/samba-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/samba-status-html.lsp b/samba-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/samba-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/samba.menu b/samba.menu
new file mode 100644
index 0000000..964d038
--- /dev/null
+++ b/samba.menu
@@ -0,0 +1,4 @@
+#CAT GROUP/DESC TAB ACTION
+Networking 35Samba Status status
+Networking 35Samba Join_Domain join
+Networking 35Samba Expert expert
diff --git a/samba.roles b/samba.roles
new file mode 100644
index 0000000..e13ebad
--- /dev/null
+++ b/samba.roles
@@ -0,0 +1,2 @@
+READ=samba:status
+UPDATE=samba:startstop,samba:expert,samba:join