linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: krisman@linux.vnet.ibm.com (Gabriel Krisman Bertazi)
Subject: [PATCH nvme-cli v1 2/2] nvme.spec/debian: Auto generate host nqn as part of install
Date: Mon, 14 Nov 2016 12:58:50 -0200	[thread overview]
Message-ID: <87d1hy3y6t.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1478602108-29571-3-git-send-email-sagi@grimberg.me> (Sagi Grimberg's message of "Tue, 8 Nov 2016 12:48:28 +0200")

Sagi Grimberg <sagi at grimberg.me> writes:

> The installation will generate a hostnqn and store it in
> /etc/nvme/hostnqn file (in case it doesn't exist).
> This file will be removed upon uninstallation (purge on for debian).
>
> Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>  debian/postinst | 20 ++++++++++++++++++++
>  debian/postrm   |  5 +++++
>  nvme.spec.in    | 12 ++++++++++++
>  3 files changed, 37 insertions(+)
>  create mode 100644 debian/postinst
>  create mode 100644 debian/postrm
>
> diff --git a/debian/postinst b/debian/postinst
> new file mode 100644
> index 000000000000..b258cf569c3e
> --- /dev/null
> +++ b/debian/postinst
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +
> +set -e
> +
> +case "$1" in
> +    configure|install)
> +	if [ ! -f /etc/nvme/hostnqn ]; then
> +		install -D /dev/null /etc/nvme/hostnqn
> +		echo $(nvme gen-hostnqn) > /etc/nvme/hostnqn
> +        fi
> +        ;;
> +
> +    upgrade|abort-upgrade)
> +        ;;
> +    *)
> +        echo "postinst called with unknown argument \`$1'" >&2
> +        exit 0
> +        ;;
> +esac
> +exit 0
> diff --git a/debian/postrm b/debian/postrm
> new file mode 100644
> index 000000000000..d678fc8a90ac
> --- /dev/null
> +++ b/debian/postrm
> @@ -0,0 +1,5 @@
> +#!/bin/sh
> +
> +if [ "$1" = "purge" ]; then
> +    rm -rf /etc/nvme
> +fi

Oh, here it is.  Didn't see your v1 before responding to the rfc. :)



> diff --git a/nvme.spec.in b/nvme.spec.in
> index a4718773a962..8bda97d819ba 100644
> --- a/nvme.spec.in
> +++ b/nvme.spec.in
> @@ -33,6 +33,18 @@ make install DESTDIR=%{buildroot} PREFIX=/usr
>  %clean
>  rm -rf $RPM_BUILD_ROOT
>
> +%post
> +if [ $1 = 1 ]; then # 1 : This package is being installed for the first time
> +	if [ ! -f /etc/nvme/hostnqn ]; then
> +		install -D /dev/null /etc/nvme/hostnqn
> +		echo $(nvme gen-hostnqn) > /etc/nvme/hostnqn
> +        fi
> +fi
> +
> +%preun
> +if [ "$1" = "remove" ]; then
> +    rm -rf /etc/nvme
> +fi
>  %changelog
>  * Thu Oct 15 2015 Keith Busch <keith.busch at intel.com>
>  - Initial RPM spec

-- 
Gabriel Krisman Bertazi

      parent reply	other threads:[~2016-11-14 14:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08 10:48 [PATCH nvme-cli v1 0/2] auto generate hostnqn file on installation Sagi Grimberg
2016-11-08 10:48 ` [PATCH nvme-cli v1 1/2] nvme-cli: Add nvme hostnqn generation option Sagi Grimberg
2016-11-08 17:36   ` J Freyensee
2016-11-16 17:11   ` Christoph Hellwig
2016-11-08 10:48 ` [PATCH nvme-cli v1 2/2] nvme.spec/debian: Auto generate host nqn as part of install Sagi Grimberg
2016-11-08 17:41   ` J Freyensee
2016-11-14 14:58   ` Gabriel Krisman Bertazi [this message]

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=87d1hy3y6t.fsf@linux.vnet.ibm.com \
    --to=krisman@linux.vnet.ibm.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).