summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Streit <simon@netpanic.org>2022-04-05 10:58:30 +0200
committerSimon Streit <simon@netpanic.org>2023-06-19 21:36:36 +0200
commitf571514fc22d24c22ae97c8958885a135e5b62bc (patch)
tree8dc10758c0d3aafb9f4aef74fc509f0bd43eed69
parent222f123b6d73651eaa627b84fdf8e501cc8f0f19 (diff)
services: remove samba service.
-rw-r--r--siguix/services/samba.scm478
1 files changed, 0 insertions, 478 deletions
diff --git a/siguix/services/samba.scm b/siguix/services/samba.scm
deleted file mode 100644
index 6d810b5..0000000
--- a/siguix/services/samba.scm
+++ /dev/null
@@ -1,478 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2021 Simon Streit <simon@netpanic.org>
-;;;
-;;; This file is NOT part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (siguix services samba)
-
- #:use-module (gnu packages)
- #:use-module (gnu packages base)
- #:use-module (gnu packages admin)
- #:use-module (gnu packages samba)
-
- #:use-module (gnu services)
- #:use-module (gnu services configuration)
- #:use-module (gnu services shepherd)
- #:use-module (gnu services base)
- #:use-module (gnu system shadow)
-
- #:use-module (guix gexp)
- #:use-module (guix packages)
- #:use-module (guix modules)
- #:use-module (guix records)
-
- #:use-module (ice-9 format)
- #:use-module (ice-9 match)
- #:use-module (ice-9 textual-ports)
- #:use-module (srfi srfi-1)
-
- #:use-module (siguix packages samba) ;eventually move to guix
-
- #:export (samba-service
- samba-service-type
- samba-configuration
- samba-configuration?
- samba-configuration-package
- samba-configuration-config-file
- samba-configuration-enable-samba?
- samba-configuration-enable-smbd?
- samba-configuration-enable-nmbd?
- samba-configuration-enable-winbindd?
- samba-configuration-global-extra-config
- samba-configuration-workgroup
- samba-configuration-server-string
- samba-configuration-server-role
- samba-configuration-bind-interfaces-only?
- samba-configuration-interfaces
- samba-configuration-hosts-allow
- samba-configuration-guest-account
- samba-configuration-log-file
- samba-configuration-loggin
- samba-configuration-realm
- samba-configuration-passdb-backend
- samba-configuration-include-config
- samba-configuration-logon-path
- samba-configuration-wins-support?
- samba-configuration-wins-server
- samba-configuration-wins-proxy?
- samba-configuration-dns-proxy?
- samba-configuration-config-sections
-
- ;; ;; temp!
- ;; samba-configuration-default-config-file
-
- wsdd-service
- wsdd-service-type
- wsdd-configuration
- wsdd-configuration?
- wsdd-configuration-package
- wsdd-configuration-ipv4only?
- wsdd-configuration-ipv6only?
- wsdd-configuration-chroot
- wsdd-configuration-hoplimit
- wsdd-configuration-interfaces
- wsdd-configuration-uuid-device
- wsdd-configuration-domain
- wsdd-configuration-hostname
- wsdd-configuration-preserve-case?
- wsdd-configuration-workgroup))
-
-;;; Commentary:
-;;;
-;;; Windows network services.
-;;;
-;;; Code:
-
-(define-record-type* <samba-configuration>
- samba-configuration
- make-samba-configuration
- samba-configuration?
-
- (package samba-configuration-package
- (default samba))
- (config-file samba-configuration-config-file
- (default #f))
- (enable-samba? samba-configuration-enable-samba?
- (default #f))
- (enable-smbd? samba-configuration-enable-smbd?
- (default #t))
- (enable-nmbd? samba-configuration-enable-nmbd?
- (default #t))
- (enable-winbindd? samba-configuration-enable-winbindd?
- (default #f))
-
- ;; From here on anything goes to smb.conf
-
- ;; This will be put at the end of [global].
- (global-extra-config samba-configuration-global-extra-config
- (default #f))
- (workgroup samba-configuration-workgroup
- (default "WORKGROUP"))
- (server-string samba-configuration-server-string
- (default "Samba Server"))
- (server-role samba-configuration-server-role
- (default "standalone"))
- (bind-interfaces-only? samba-configuration-bind-interfaces-only?
- (default #f))
- (interfaces samba-configuration-interfaces
- (default '()))
- (hosts-allow samba-configuration-hosts-allow
- (default '()))
- (guest-account samba-configuration-guest-account
- (default #f))
- (log-file samba-configuration-log-file
- (default "/var/log/samba/log.%m"))
- (logging samba-configuration-loggin
- (default "file"))
- (realm samba-configuration-realm
- (default #f))
- (passdb-backend samba-configuration-passdb-backend
- (default #f))
- (include-config samba-configuration-include-config
- (default #f))
- (logon-path samba-configuration-logon-path
- (default #f))
- (wins-support? samba-configuration-wins-support?
- (default #f))
- (wins-server samba-configuration-wins-server
- (default #f))
- (wins-proxy? samba-configuration-wins-proxy?
- (default #f))
- (dns-proxy? samba-configuration-dns-proxy?
- (default #f))
- (config-sections samba-configuration-config-sections
- (default #f)))
-
-(define (samba-configuration-config-file global-extra-config
- workgroup
- server-string
- server-role
- bind-interfaces-only?
- interfaces
- hosts-allow
- guest-account
- log-file
- logging
- realm
- passdb-backend
- include-config
- logon-path
- wins-support?
- wins-server
- wins-proxy?
- dns-proxy?
- config-sections)
- (mixed-text-file
- "smb.conf"
- "# Generated by samba-service.
-[global]
-" (if workgroup
- (string-append " workgroup = " workgroup "\n") "")
-(if server-string
- (string-append " server string = " server-string "\n") "")
-(if server-role
- (string-append " server role = " server-role "\n") "")
-(if bind-interfaces-only? " bind interfaces only = yes\n" "")
-(if (not (null? interfaces))
- (string-append " interfaces = "
- (string-join (map (lambda (interface)
- (format #f "~s" interface))
- interfaces) ";") "\n") "")
-(if (not (null? hosts-allow))
- (string-append " hosts allow = "
- (string-join (map (lambda (host)
- (format #f "~s" host))
- hosts-allow) ";") "\n") "")
-(if guest-account
- (string-append " guest account = " guest-account "\n") "")
-(if log-file
- (string-append " log file = " log-file "\n") "")
-(if logging
- (string-append " logging = " logging "\n") "")
-(if realm
- (string-append " realm = " realm "\n") "")
-(if passdb-backend
- (string-append " passdb backend = " passdb-backend "\n") "")
-(if include-config
- (string-append " include config = " include-config "\n") "")
-(if logon-path
- (string-append " logon path = " logon-path "\n") "")
-(if wins-support? " wins support = yes\n" "")
-(if wins-server
- (string-append " hosts allow = "
- (string-join (map (lambda (wins)
- (format #f "~s" wins))
- wins-server) ";") "\n") "")
-(if wins-proxy? " wins proxy = yes\n" "")
-(if dns-proxy? " dns proxy = yes\n" "")
-(if global-extra-config
- (string-append
- "\n#Extra options provided by ‘global-extra-config’:\n"
- global-extra-config "\n") "")
-(if config-sections
- (string-append "\n#Contents of ‘config-sections’:\n"
- config-sections "\n") "")))
-
-(define samba-activation
- (match-lambda
- (($ <samba-configuration> package
- config-file
- _ _ _ _
- global-extra-config
- workgroup
- server-string
- server-role
- bind-interfaces-only?
- interfaces
- hosts-allow
- guest-account
- log-file
- logging
- realm
- passdb-backend
- include-config
- logon-path
- wins-support?
- wins-server
- wins-proxy?
- dns-proxy?
- config-sections)
- (with-imported-modules '((guix build utils))
- (let ((config-file
- (or config-file
- (samba-configuration-config-file global-extra-config
- workgroup
- server-string
- server-role
- bind-interfaces-only?
- interfaces
- hosts-allow
- guest-account
- log-file
- logging
- realm
- passdb-backend
- include-config
- logon-path
- wins-support?
- wins-server
- wins-proxy?
- dns-proxy?
- config-sections)))
- (lib-directory "/var/lib/samba")
- (log-directory "/var/log/samba")
- (run-directory "/var/run/samba")
- (smb.conf "/etc/samba/smb.conf"))
- #~(begin
- (use-modules (guix build utils))
-
- (mkdir-p #$log-directory)
- (mkdir-p #$run-directory)
- (mkdir-p (string-append #$lib-directory "/private"))
- (mkdir-p "/etc/samba")
- (copy-file #$config-file #$smb.conf)
- (system* (string-append #$samba "/bin/testparm")
- "--suppress-prompt" #$smb.conf)))))))
-
-(define samba-shepherd-service
- (match-lambda
- (($ <samba-configuration> package)
- (let ((config-file "/etc/samba/smb.conf"))
- (list (shepherd-service
- (documentation "Run the Samba")
- (provision '(samba))
- (requirement '(networking))
- (start #~(make-forkexec-constructor
- (list #$(file-append package "/sbin/samba")
- (string-append "--configfile="
- #$config-file)
- "--foreground"
- "--no-process-group")))
- (stop #~(make-kill-destructor))))))))
-
-(define samba-nmbd-shepherd-service
- (match-lambda
- (($ <samba-configuration> package)
- (let ((config-file "/etc/samba/smb.conf"))
- (list (shepherd-service
- (documentation "Run NetBIOS name server.")
- (provision '(samba-nmbd))
- (requirement '(networking))
- (start #~(make-forkexec-constructor
- (list #$(file-append package "/sbin/nmbd")
- (string-append "--configfile="
- #$config-file)
- "--foreground"
- "--no-process-group")))
- (stop #~(make-kill-destructor))))))))
-
-(define samba-smbd-shepherd-service
- (match-lambda
- (($ <samba-configuration> package)
- (let ((config-file "/etc/samba/smb.conf"))
- (list (shepherd-service
- (documentation "Run SMB/CIFS service")
- (provision '(samba-smbd))
- (requirement '(networking))
- (start #~(make-forkexec-constructor
- (list #$(file-append package "/sbin/smbd")
- (string-append "--configfile="
- #$config-file)
- "--foreground"
- "--no-process-group")))
- (stop #~(make-kill-destructor))))))))
-
-(define samba-winbind-shepherd-service
- (match-lambda
- (($ <samba-configuration> package)
- (let ((config-file "/etc/samba/smb.conf"))
- (list (shepherd-service
- (documentation "Run winbindd for Name Service Switch")
- (provision '(samba-winbindd))
- (requirement '(networking))
- (start #~(make-forkexec-constructor
- (list #$(file-append package "/sbin/winbindd")
- (string-append "--configfile="
- #$config-file)
- "--foreground"
- "--no-process-group")))
- (stop #~(make-kill-destructor))))))))
-
-(define (samba-shepherd-services config)
- (append ;; (samba-shepherd-service config)
- (samba-nmbd-shepherd-service config)
- (samba-smbd-shepherd-service config)
- (samba-winbind-shepherd-service config)))
-
-(define samba-service-type
- (service-type
- (name 'samba)
- (description "Samba")
- (extensions
- (list (service-extension shepherd-root-service-type
- samba-shepherd-services)
- (service-extension activation-service-type
- samba-activation)
- ;; (service-extension account-service-type
- ;; (const %samba-accounts))
- ))
- (default-value (samba-configuration))))
-
-
-;;;
-;;; WSDD
-;;;
-
-(define-record-type* <wsdd-configuration>
- wsdd-configuration
- make-wsdd-configuration
- wsdd-configuration?
- (package wsdd-configuration-package
- (default wsdd))
- (ipv4only? wsdd-configuration-ipv4only?
- (default #f))
- (ipv6only? wsdd-configuration-ipv6only?
- (default #f))
- (chroot wsdd-configuration-chroot
- (default #f))
- (hoplimit wsdd-configuration-hoplimit
- (default 1))
- (interfaces wsdd-configuration-interfaces
- (default '()))
- (uuid-device wsdd-configuration-uuid-device
- (default #f))
- (domain wsdd-configuration-domain
- (default #f))
- (hostname wsdd-configuration-hostname
- (default #f))
- (preserve-case? wsdd-configuration-preserve-case?
- (default #f))
- (workgroup wsdd-configuration-workgroup
- (default "WORKGROUP")))
-
-(define wsdd-accounts
- (list
- (user-group (name "wsdd"))
- (user-account (name "wsdd")
- (group "wsdd")
- (comment "Web Service Discovery user")
- (home-directory "/var/empty")
- (shell (file-append shadow "/sbin/nologin")))))
-
-(define wsdd-shepherd-service
- (match-lambda
- (($ <wsdd-configuration> package
- ipv4only?
- ipv6only?
- chroot
- hoplimit
- interfaces
- uuid-device
- domain
- hostname
- preserve-case?
- workgroup)
- (list (shepherd-service
- (documentation "Run a Web Service Discovery service")
- (provision '(wsdd))
- (requirement '(networking))
- (start #~(make-forkexec-constructor
- (list #$(file-append package "/bin/wsdd")
- #$@(if ipv4only?
- #~("--ipv4only")
- #~())
- #$@(if ipv6only?
- #~("--ipv6only")
- #~())
- #$@(if chroot
- #~("--chroot" #$chroot)
- #~())
- #$@(if hoplimit
- #~("--hoplimit" #$(number->string hoplimit))
- #~())
- #$@(map (lambda (interfaces)
- (string-append "--interface=" interfaces))
- interfaces)
- #$@(if uuid-device
- #~("--uuid" #$uuid-device)
- #~())
- #$@(if domain
- #~("--domain" #$domain)
- #~())
- #$@(if hostname
- #~("--hostname" #$hostname)
- #~())
- #$@(if preserve-case?
- #~("--preserve-case")
- #~())
- #$@(if workgroup
- #~("--workgroup" #$workgroup)
- #~()))
- #:user "wsdd"
- #:group "wsdd"
- #:log-file "/var/log/wsdd.log"))
- (stop #~(make-kill-destructor)))))))
-
-(define wsdd-service-type
- (service-type
- (name 'wsdd)
- (description "Web Service Discovery Daemon")
- (extensions
- (list (service-extension shepherd-root-service-type
- wsdd-shepherd-service)
- (service-extension account-service-type
- (const wsdd-accounts))))
- (default-value (wsdd-configuration))))