[node-patches] Change in ovirt-node[master]: hooks: Add 01-sanlock-check into on-changed-boot-image

hadong0720 at gmail.com hadong0720 at gmail.com
Tue Sep 9 04:39:06 UTC 2014


hadong has uploaded a new change for review.

Change subject: hooks: Add 01-sanlock-check into on-changed-boot-image
......................................................................

hooks: Add 01-sanlock-check into on-changed-boot-image

Add 01-sanlock-check into on-changed-boot-image to create sanlock user/group ifmissing during upgrade.

Change-Id: I441ed24f4488e67d9b06be670499526960700c4a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1127122
Signed-off-by: hadong <hadong at redhat.com>
---
M ovirt-node.spec.in
A scripts/01-sanlock-check
M scripts/Makefile.am
M scripts/ovirt-init-functions.sh.in
4 files changed, 42 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/59/32659/1

diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index 8e1890c..4bbad6d 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -766,6 +766,7 @@
 %{_sysconfdir}/modprobe.d/ovirt-qla4xxx.conf
 %{_sysconfdir}/modprobe.d/bonding.conf
 %{_libexecdir}/ovirt-node/hooks
+%{_libexecdir}/ovirt-node/hooks/on-changed-boot-image/01-sanlock-check
 
 
 %doc COPYING
diff --git a/scripts/01-sanlock-check b/scripts/01-sanlock-check
new file mode 100644
index 0000000..7c328b5
--- /dev/null
+++ b/scripts/01-sanlock-check
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# 01-sanlock-check - Copyright (C) 2014 Red Hat, Inc.
+#
+# This program 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, version 2 of the License.
+#
+# This program 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.
+
+. /usr/libexec/ovirt-functions
+# Handle sanlock user creation on in place upgrade
+service sanlock stop
+if ! grep -q ^sanlock /etc/group; then
+    unmount_config /etc/group
+    groupadd -g 179 sanlock
+    persist /etc/group
+fi
+if ! grep -q ^sanlock /etc/passwd; then
+    unmount_config /etc/passwd /etc/shadow
+    useradd -u 179 -g sanlock -s /sbin/nologin -d /var/run/sanlock sanlock
+    persist /etc/shadow /etc/passwd
+fi
+service sanlock start
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 9facb20..24c09b7 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -16,6 +16,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
 localboottriggerdir=$(sysconfdir)/ovirt-config-boot.d
+onchangedbootimagedir = $(libexecdir)/ovirt-node/hooks/on-changed-boot-image
 augeasdir = $(pythondir)
 
 dist_sbin_SCRIPTS = \
@@ -43,6 +44,9 @@
 dist_localboottrigger_SCRIPTS = \
   local_boot_trigger.sh
 
+dist_onchangedbootimage_SCRIPTS = \
+  01-sanlock-check
+
 augeas_PYTHON = \
   augeas.py
 
diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index 30b7576..4187143 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -38,6 +38,7 @@
 EARLY_DIR=/etc/ovirt-early.d
 
 HOOK_ON_BOOT_DIR=/usr/libexec/ovirt-node/hooks/on-boot
+HOOK_ON_CHANGED_BOOT_IMAGE_DIR=/usr/libexec/ovirt-node/hooks/on-changed-boot-image
 
 # Drop to a shell
 emergency_shell() {
@@ -1017,6 +1018,15 @@
         done
     fi
 
+    if [[ -d "$HOOK_ON_CHANGED_BOOT_IMAGE_DIR" ]] && [[ "$(ls -A $HOOK_ON_CHANGED_BOOT_IMAGE_DIR)" ]];
+    then
+        for handler in "$HOOK_ON_CHANGED_BOOT_IMAGE_DIR"/*;
+        do
+            log "Running handler: $handler"
+            "$handler" >> $OVIRT_LOGFILE 2>&1
+        done
+    fi
+
     return 0
 }
 


-- 
To view, visit http://gerrit.ovirt.org/32659
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I441ed24f4488e67d9b06be670499526960700c4a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list