From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Sassmannshausen Subject: [PATCH 2/2] dmd: Make config file if necessary when not run as root. Date: Mon, 3 Feb 2014 18:37:45 +0100 Message-ID: <1391449065-19063-3-git-send-email-alex.sassmannshausen@gmail.com> References: <1391449065-19063-1-git-send-email-alex.sassmannshausen@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WANTY-0002UO-Ja for guix-devel@gnu.org; Mon, 03 Feb 2014 12:38:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WANTR-0007js-UW for guix-devel@gnu.org; Mon, 03 Feb 2014 12:38:28 -0500 Received: from mail-ea0-x229.google.com ([2a00:1450:4013:c01::229]:56798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WANTR-0007jo-8Z for guix-devel@gnu.org; Mon, 03 Feb 2014 12:38:21 -0500 Received: by mail-ea0-f169.google.com with SMTP id h10so3934256eak.28 for ; Mon, 03 Feb 2014 09:38:20 -0800 (PST) In-Reply-To: <1391449065-19063-1-git-send-email-alex.sassmannshausen@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org * 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 +;; +;; 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 . + +;; 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