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@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jay Freyensee <james_p_freyensee@linux.intel.com>
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/sh
+
+if [ "$1" = "purge" ]; then
+ if [ -d /etc/nvme ]; then
+ rm -f /etc/nvme/hostnqn
+ if [ ! -n "`ls -A /etc/nvme`" ]; then
+ rm -rf /etc/nvme
+ fi
+ fi
+fi
%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
+ if [ -d /etc/nvme ]; then
+ rm -f /etc/nvme/hostnqn
+ if [ ! -n "`ls -A /etc/nvme`" ]; then
+ rm -rf /etc/nvme
+ fi
+ fi
+fi
%changelog
* Thu Oct 15 2015 Keith Busch <keith.busch@intel.com>
- Initial RPM spec