mirror of
https://gitlab.univ-nantes.fr/glicid-public/guix-glicid.git
synced 2025-04-30 06:08:37 +02:00
adding squid service
This commit is contained in:
parent
36ab8212a7
commit
5dc4932148
2 changed files with 129 additions and 0 deletions
21
glicid/packages/networking.scm
Normal file
21
glicid/packages/networking.scm
Normal file
|
@ -0,0 +1,21 @@
|
|||
(define-module (glicid packages networking)
|
||||
#:use-module ((gnu packages networking) #:prefix gnu:)
|
||||
#:use-module (guix download)
|
||||
#:use-module (guix packages)
|
||||
)
|
||||
|
||||
|
||||
(define-public squid
|
||||
(package
|
||||
(inherit gnu:squid)
|
||||
(name "squid")
|
||||
(version "5.5")
|
||||
(source
|
||||
(origin
|
||||
(method url-fetch)
|
||||
(uri (string-append "http://www.squid-cache.org/Versions/v5/squid-" version ".tar.xz"))
|
||||
(sha256 (base32 "0v0h949l4wd1hl87a8wkk1fkvj8j44wifyxi9myxdgbnci6lh7af"))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
108
glicid/services/networking.scm
Normal file
108
glicid/services/networking.scm
Normal file
|
@ -0,0 +1,108 @@
|
|||
(define-module (glicid services networking)
|
||||
#:use-module (gnu packages networking)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services shepherd)
|
||||
#:use-module (guix)
|
||||
#:use-module (guix records)
|
||||
#:use-module (ice-9 match)
|
||||
#: export (
|
||||
squid-configuration
|
||||
squid-configuration?
|
||||
squid-shepherd-service
|
||||
squid-service-type
|
||||
)
|
||||
)
|
||||
|
||||
(define-record-type* <squid-configuration>
|
||||
squid-configuration make-squid-configuration
|
||||
squid-configuration?
|
||||
(squid squid-configuration-squid
|
||||
(default squid)
|
||||
)
|
||||
(poer squid-configuration-port
|
||||
(default 3128)
|
||||
)
|
||||
(pid-file squid-configuration-pid-file
|
||||
(default "/var/run/squid/squid.pid")
|
||||
)
|
||||
(config-file squid-configuration-config-file
|
||||
(default (file-append squid "/etc/squid.conf"))
|
||||
)
|
||||
(log-file squid-configuration-log-file
|
||||
(default "/var/log/squid.log")
|
||||
)
|
||||
)
|
||||
|
||||
(define squid-shepherd-service
|
||||
(match-lambda
|
||||
(($ <squid-configuration> squid port pid-file config-file log-file)
|
||||
(list
|
||||
(shepherd-service
|
||||
(provision '(squid) )
|
||||
(documentation "Run squid.")
|
||||
(requirement '(user-processes))
|
||||
(respawn? #t)
|
||||
(start #~(make-forkexec-constructor
|
||||
(list
|
||||
#$(file-append squid "/libexec/squid")
|
||||
"-a" #$port
|
||||
"-u" #$port
|
||||
"-f" #$config-file
|
||||
)
|
||||
#:pid-file #$pid-file
|
||||
#:log-file #$log-file
|
||||
))
|
||||
(stop #~(exec-command
|
||||
(list
|
||||
#$(file-append squid "/libexec/squid")
|
||||
"-a" #$port
|
||||
"-u" #$port
|
||||
"-k" "shutdown"
|
||||
"-f" #$config-file
|
||||
)
|
||||
#:pid-file #$pid-file
|
||||
#:log-file #$log-file
|
||||
))
|
||||
(actions (list
|
||||
(shepherd-action
|
||||
(name 'reload)
|
||||
(documentation "Reload the settings file from disk.")
|
||||
(procedure #~(exec-command
|
||||
(list
|
||||
#$(file-append squid "/libexec/squid")
|
||||
"-a" #$port
|
||||
"-u" #$port
|
||||
"-k" "reconfigure"
|
||||
"-f" #$config-file
|
||||
)
|
||||
))
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define %squid-activation
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(mkdir-p "/var/run/squid")
|
||||
#t
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define squid-service-type
|
||||
(service-type (name 'squid)
|
||||
(extensions
|
||||
(list
|
||||
(service-extension shepherd-root-service-type squid-shepherd-service)
|
||||
(service-extension activation-service-type (const %squid-activation))
|
||||
)
|
||||
)
|
||||
(description "Run @uref{http://www.squid-cache.org/, squid} community developped Squid software.")
|
||||
)
|
||||
)
|
Loading…
Add table
Reference in a new issue