all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob cb20eaf08b7ed8d2b5039c1170a89a4a8d5cf47d 4817 bytes (raw)
name: doc/examples/wolfgangj.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
;; wolfgangj.scm -- Personal dmd configuration of Wolfgang Jährling.
;; Copyright (C) 2002, 2003 Wolfgang Jährling <wolfgang@pro-linux.de>
;;
;; This file is part of the GNU Shepherd.
;;
;; The GNU Shepherd 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.
;;
;; The GNU Shepherd 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 the GNU Shepherd.  If not, see <http://www.gnu.org/licenses/>.

\f

;; A few notes about the computer this setup is for: It is a PC
;; running Debian GNU/Linux 3.0, on which I am usually using screen,
;; which is why I need few terminals.  I am using it to connect to the
;; internet via ISDN, but I'm also using it in my local network, in
;; which case it is running Apache.  Because I don't want to have
;; Apache running when I am online, I made Apache conflict with the
;; ISDN setup.

;; Laziness.
(define (number->symbol num)
  (string->symbol (number->string num)))

;; Even more laziness.
(define cat string-append)

;; Some values for this system.
(define getty "/sbin/getty")
(define ifconfig "/sbin/ifconfig")
(define isdnctrl "/usr/sbin/isdnctrl")

(define inet-interface "ippp0")
(define inet-dial (cat isdnctrl " dial " inet-interface))
(define inet-hangup (cat isdnctrl " hangup " inet-interface))

(define local-interface "eth0")
(define local-ip "192.168.0.9")

(define init.d-dir "/etc/init.d/")
(define apache (cat init.d-dir "apache"))
(define inet (cat init.d-dir "isdnutils"))
(define exim (cat init.d-dir "exim"))

;; Create a service providing a terminal.
(define (make-term num)
  (let ((sym (symbol-append 'term- (number->symbol num))))
    (make <service>
      #:provides (list sym)
      #:respawn? #t
      #:start (make-forkexec-constructor getty "38400"
                                         (cat "tty" (number->string num)))
      #:stop-delay? #t)))

;; Number of terminals created by default.
(define default-terms 3)

;; How many terms have been created with `add-new-term'.
(define term-counter 0)

;; Add a new terminal to the list of registered services.
(define (add-new-term)
  (set! term-counter (+ term-counter 1))
  (register-services (make-term term-counter)))

(register-services
 (make <service>
   #:provides '(term)
   #:actions (make-actions
              (create "Create a new terminal."
                      (lambda (running)
                        (add-new-term)))
              (counter-set "Set the terminal creation counter."
                           (lambda (running num)
                             (set! term-counter (string->number num))))
              (status "Display the terminal creation counter."
                      (lambda (running)
                        (local-output "Terminal counter is at ~a."
                                      term-counter)))))
 (make <service>
   #:provides '(apache insecurity)
   #:requires '(local-net)
   #:start (make-system-constructor apache " start")
   #:stop (make-system-destructor apache " stop"))
 (make <service>
   #:provides '(inet insecurity)
   #:start (make-system-constructor inet " start")
   #:stop (make-system-destructor inet " stop")
   #:actions (make-actions
              (dial "Connect to the big, evil internet."
                    (lambda (running)
                      (system inet-dial)
                      #t))
              (hangup "Cut the internet connection."
                      (lambda (running)
                        (system inet-hangup)
                        #t))))
 (make <service>
   #:provides '(local-net)
   #:start (make-system-constructor ifconfig " " local-interface " " local-ip)
   #:stop (make-system-destructor ifconfig " " local-interface " down"))
 (make <service>
   #:provides '(exim mailer-daemon)
   #:requires '(inet)
   #:start (make-system-constructor exim " start")
   #:stop (make-system-destructor exim " stop")))

;; Create a few terminals.
(letrec ((loop (lambda (i)
                 (and (not (zero? i))
                      (begin
                        (add-new-term)
                        (loop (- i 1)))))))
  (loop default-terms))

;; Go into background.
(action 'dmd 'daemonize)

;; Setup internet, a mailer and a few terms.
(for-each start
          (append '(term inet mailer-daemon)
                  (map (lambda (x)
                         (symbol-append 'term- (number->symbol x)))
                       (iota default-terms 1))))

debug log:

solving 0c16108 ...
found 0c16108 in https://yhetil.org/guix/1453927534-32056-3-git-send-email-mthl@gnu.org/

applying [1/1] https://yhetil.org/guix/1453927534-32056-3-git-send-email-mthl@gnu.org/
diff --git a/doc/examples/wolfgangj.scm b/doc/examples/wolfgangj.scm
new file mode 100644
index 0000000..0c16108

Checking patch doc/examples/wolfgangj.scm...
Applied patch doc/examples/wolfgangj.scm cleanly.

index at:
100644 cb20eaf08b7ed8d2b5039c1170a89a4a8d5cf47d	doc/examples/wolfgangj.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.