From: Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 2/2] dmd: Make config file if necessary when not run as root.
Date: Mon, 3 Feb 2014 18:37:45 +0100 [thread overview]
Message-ID: <1391449065-19063-3-git-send-email-alex.sassmannshausen@gmail.com> (raw)
In-Reply-To: <1391449065-19063-1-git-send-email-alex.sassmannshausen@gmail.com>
* modules/dmd/support.scm (make-bare-init-file): new procedure to
generate basic init file.
(default-logfile): Check for init file, create it if necessary.
---
modules/dmd/support.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/modules/dmd/support.scm b/modules/dmd/support.scm
index f9c9989..f1b6248 100644
--- a/modules/dmd/support.scm
+++ b/modules/dmd/support.scm
@@ -162,6 +162,45 @@ There is NO WARRANTY, to the extent permitted by law.")))
;; dmd default subdirectory if dmd is run as a normal user.
(define user-dmddir (string-append user-homedir "/.dmd.d"))
+(define (make-bare-init-file target)
+ "Return #t if a bare init file was created at TARGET; #f otherwise.
+
+TARGET should be a string representing a filepath + name."
+ (with-output-to-file target
+ (lambda ()
+ (format #t
+";; init.scm -- default dmd configuration file.
+;; Copyright (C) 2014 A. Sassmannshausen <alex.sassmannshausen@gmail.com>
+;;
+;; This file is part of GNU dmd.
+;;
+;; GNU dmd 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 dmd 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 dmd. If not, see <http://www.gnu.org/licenses/>.
+
+;; Services known to dmd:
+;; Add new services to dmd here by providing them through the
+;; MAKE-SERVICE procedure to REGISTER SERVICES.
+ (register-services)
+
+;; Send dmd into the background
+ (action 'dmd 'daemonize)
+
+;; Services to start when dmd starts:
+;; Add the name of each service known to dmd that should be started to
+;;the list passed to FOR-EACH.
+ (for-each start '())
+"))))
+
;; Logfile.
(define default-logfile
(if (zero? (getuid))
@@ -176,7 +215,10 @@ There is NO WARRANTY, to the extent permitted by law.")))
(let ((config-file (string-append user-dmddir "/init.scm")))
(cond ((not (file-exists? user-dmddir))
(mkdir user-dmddir)
+ (make-bare-init-file config-file)
config-file)
+ ((not (file-exists? config-file))
+ (make-bare-init-file config-file))
(else config-file))))))
;; The directory where the socket resides.
--
1.7.9.5
next prev parent reply other threads:[~2014-02-03 17:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 17:37 dmd: make user-mode easier to use Alex Sassmannshausen
2014-02-03 17:37 ` =?y?q?=5BPATCH=201/2=5D=20dmd=3A=20Use=20=7E/=2Edmd=2Ed/=20by=20default=20when=20not=20run=20as=20root=2E?= Alex Sassmannshausen
2014-02-04 20:34 ` [PATCH 1/2] dmd: Use ~/.dmd.d/ by default when not run as root Ludovic Courtès
2014-02-03 17:37 ` Alex Sassmannshausen [this message]
2014-02-04 20:41 ` [PATCH 2/2] dmd: Make config file if necessary " Ludovic Courtès
2014-02-05 18:27 ` Alex Sassmannshausen
2014-02-05 20:17 ` Ludovic Courtès
2014-02-04 20:34 ` dmd: make user-mode easier to use Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1391449065-19063-3-git-send-email-alex.sassmannshausen@gmail.com \
--to=alex.sassmannshausen@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.