From patchwork Sat Jul 28 21:22:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 708 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 2405E5C82F2B for ; Sat, 28 Jul 2018 21:22:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,T_DKIMWL_WL_HIGH=-0.01 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-BL-Results: [127.0.9.2] [127.0.0.11] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Jul 2018 21:22:35 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id CA84CC6402F4D; Sat, 28 Jul 2018 21:22:32 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Sat, 28 Jul 2018 21:22:32 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 9432C2A844; Sat, 28 Jul 2018 21:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1532812952; bh=4nbMUUAKQqgp7Qrlx5NCG3meWAmNCgPdpAdJYnyq+3w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=smPSfm3T66CwcRZZx8fXcN3Es5aCxAQtQC5qlIEBDkl7xzt+9w1KqIxXJ1tKTwUeK BF3XmKfNoLw5ZGmwn2FCNU2yv2ms9Hh0dGdpHJvbXziEoHKJWjHud4GfE3FgrQgd4u Neh/3C5vn7HKkWC0HTFBHU5/BfAq4J7Y69kWkhEQChpVAmp7KTYzG69Q1VZhQVDpzS u8T6iFPp2oVskIDKZrCUTUBuFhFc+9gukDSHCuUfc+nTXsmdr909rHyne4z4bXhHNG Pir6nCkgOjdY32xl9XhK4BgQVTwpVLnWOo5Qc/olvSIyxbyJNWU7sIhflHaeN9R8Kk Jo8P7QOpnIovW/LCtZCYSowy8myB74n9fXwXQAgSg4wrRJ0inPa0m/WUO7rcwH4Ovm YRjTvnFBuTQowGKUSfdTIPDXqRTL1cyupArhPcuxMyUH9d2pu7dqMWPwje1EWQdwm/ r+s4Yzwni/x0EDFfPrsnuQajcbxLrfP9OVjvubqb7k280+gbxmUq0XJfnw3idd+/SF Q5RglE8lDCa3jtS3AUumDkovyxxfGclgiTGwcHKRikE164tRA18eIksOYBpl9Rc4th gpcAnWu//kh6f8sg+YfYMlwI2w1GufT5D6eTS4GYhLIkMcsZxYsNVr+W/XHPR1vDkF RummArfKmiGYfw0zlEyj3Wwk= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D0BD12A842 for ; Sat, 28 Jul 2018 21:22:29 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Jul 2018 21:22:29 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 6411FC6402F4A for ; Sat, 28 Jul 2018 21:22:28 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Jul 2018 21:22:28 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id j5-v6so8570267wrr.8 for ; Sat, 28 Jul 2018 14:22:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=vIQoltRX3HE7ea3s96T7GHvHnbk3bt63aauWRDt/VeQ=; b=TwESQqqz2EbBZxROKWNqvSQh5oH8qbOfyu5XLRRliwt35WjWoTLpmACS9P9N1k4ENw RnCc1VXnzcjD5rnK64B/xq8QXrV4iCy5pDWjHD0hMfXonqHNupDqXmHQRpjU1YZYOmbu fTlfiFIOFFS2FIDTKbCwjgDDp6LXya2/rXsrypl9NqVZKOxg2LhdnSEOvlr6umngqQ26 vSwjcOd+b2pkaHQVvuCwaFjT10+uh0sYsgrHrLQN4Divl99ukCEKbjYJSuAU5amzl5u6 W0GhvI4pTBd3o/vsWMczfBko77B9IlAypFx6u6Xs5YAh14x2qQltV7rLMScrNucueYTC o+RQ== X-Gm-Message-State: AOUpUlEE4e5Nemd4g379B8KUvbfXXRFSlswVojQYkRmuJgJRxduiQqF5 W4RYbNPpfGVK1ClV6fEeUoOV2wGh X-Google-Smtp-Source: AAOMgpdSXJevC89VxuwP0XdnGw9tbA4MV7cfiLoEbqGWed6/MM5AxlGq2dQOWIp2kDJgWPEW6IaG9Q== X-Received: by 2002:a5d:44c6:: with SMTP id z6-v6mr10564396wrr.236.1532812947642; Sat, 28 Jul 2018 14:22:27 -0700 (PDT) Received: from Mindship-03 (ip5653397a.direct-adsl.nl. [86.83.57.122]) by smtp.gmail.com with ESMTPSA id m207-v6sm11253887wma.31.2018.07.28.14.22.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Jul 2018 14:22:26 -0700 (PDT) Date: Sat, 28 Jul 2018 23:22:22 +0200 To: arch-projects@archlinux.org Message-ID: <20180728212222.GA4293@Mindship-03> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Subject: [arch-projects] [netctl][PATCH] Use drop-in directories instead of .include statements X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jouke Witteveen via arch-projects Reply-To: Arch Linux projects development discussion Cc: Jouke Witteveen Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" The .include directive in systemd unit files has effectively been deprecated since systemd v210. Its functionality is subsumed by drop-in directories. --- src/netctl.in | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/netctl.in b/src/netctl.in index b5da594..6aeed7e 100644 --- a/src/netctl.in +++ b/src/netctl.in @@ -90,43 +90,43 @@ switch_to() { } unit_enable() { - local unit="@systemdsystemconfdir@/netctl@$(systemd-escape "$1").service" - if [[ -e $unit ]]; then - report_error "A unit file for profile '$1' already exists" + local unit=$(systemd-escape --template=netctl@.service "$1") target + load_profile "$1" + + target="@systemdsystemconfdir@/multi-user.target.wants/$unit" + if [[ -e $target ]]; then + report_error "The profile '$1' is already enabled" return 1 fi - load_profile "$1" - do_readable touch "$unit" - echo ".include @systemdsystemunitdir@/netctl@.service" > "$unit" - echo -e "\n[Unit]" >> "$unit" - [[ $Description ]] && echo "Description=$Description" >> "$unit" + do_readable mkdir -p "$(dirname "$target")" + ln -vs "@systemdsystemunitdir@/netctl@.service" "$target" + + target="@systemdsystemconfdir@/$unit.d/profile.conf" + do_readable mkdir -p "$(dirname "$target")" + do_readable touch "$target" + echo "[Unit]" > "$target" + if [[ $Description ]]; then + echo "Description=$Description" >> "$target" + fi declare -p BindsToInterfaces &> /dev/null || BindsToInterfaces=$Interface if (( ${#BindsToInterfaces[@]} )); then : ${InterfaceRoot=sys/subsystem/net/devices/} printf "BindsTo=$(systemd-escape "$InterfaceRoot")%s.device\n" \ - $(systemd-escape "${BindsToInterfaces[@]}") >> "$unit" + $(systemd-escape "${BindsToInterfaces[@]}") >> "$target" printf "After=$(systemd-escape "$InterfaceRoot")%s.device\n" \ - $(systemd-escape "${BindsToInterfaces[@]}") >> "$unit" + $(systemd-escape "${BindsToInterfaces[@]}") >> "$target" fi if (( ${#After[@]} )); then printf 'After=netctl@%s.service\n' \ - $(systemd-escape "${After[@]}") >> "$unit" + $(systemd-escape "${After[@]}") >> "$target" fi - mkdir -p "@systemdsystemconfdir@/multi-user.target.wants" - echo "ln -s '$unit' '${unit/system\//system/multi-user.target.wants/}'" - ln -s "$unit" "${unit/system\//system/multi-user.target.wants/}" + report_notice "generated '$target'" } unit_disable() { - local unit="@systemdsystemconfdir@/netctl@$(systemd-escape "$1").service" - if sd_call "is-enabled --quiet" "$1" &> /dev/null; then - sd_call disable "$1" - fi - if [[ ! -f $unit ]]; then - report_error "No regular unit file found for profile '$1'" - return 1 - fi - do_debug rm "$unit" + local unit=$(systemd-escape --template=netctl@.service "$1") + rm -vfd "@systemdsystemconfdir@"{/multi-user.target.wants,}"/$unit" \ + "@systemdsystemconfdir@/$unit.d"{/profile.conf,} } wait_online() {