# llxcfg-ocfs2-net description "LliureX network net ocfs2" start on ( llxnetworking-done ) stop on ( llx-cluster-ocfs2-stop ) emits llx-cluster-ocfs2-stop pre-start script MAX_TIME=120 SLEEP_TIME=2 RUNNING_TIME=0 RUNNING_TIME_SEARCH_OCFS2=0 RUNNING_TIME_SEARCH_ISCSI=0 RUNNING_TIME_SEARCH_MULTIPATH=0 STOP_SERVICE_OCFS2="N" STOP_SERVICE_ISCSI="N" STOP_SERVICE_MULTIPATH="N" STOP_SERVICE="N" OCFS2_DISK_TMP="" ZNB_HOME="/net/zero-net-boot/tftp/modelo-" PXE_HOME="/var/lib/tcos/tftp/edit-" VAR_LIST="OCFS2_NET_EXPORT_DIRS OCFS2_MOUNT_FSTAB OCFS2_DISK LLIUREX_PXE_FLAVOURS" LLX_GETVAR="/usr/sbin/llxcfg-showvars" eval `${LLX_GETVAR} ${VAR_LIST}` #if [ -e /etc/default/o2cb ]; then # . /etc/default/o2cb # if [ "$O2CB_ENABLED" = "false" ] && [ -e /etc/ocfs2/ocfs2.debconf ]; then # export DEBIAN_FRONTEND=noninteractive # export DEBCONF_FRONTEND=noninteractive # debconf-set-selections /etc/ocfs2/ocfs2.debconf # dpkg-reconfigure ocfs2-tools 2>/dev/null # fi #fi if [ -x "/sbin/iscsid" ] && [ -x "/sbin/mount.ocfs2" ]; then while : ; do STOP_SERVICE_ISCSI="N" if pidof iscsid; then STOP_SERVICE_ISCSI="Y" sleep $SLEEP_TIME break fi if [ $RUNNING_TIME_SEARCH_ISCSI -gt $MAX_TIME ]; then exit 0 fi sleep $SLEEP_TIME RUNNING_TIME_SEARCH_ISCSI=$(($RUNNING_TIME_SEARCH_ISCSI + $SLEEP_TIME)) done fi if [ -x "/sbin/multipathd" ] && [ -x "/sbin/multipath" ]; then while : ; do STOP_SERVICE_MULTIPATH="N" if pidof multipathd; then STOP_SERVICE_MULTIPATH="Y" sleep $SLEEP_TIME break fi if [ $RUNNING_TIME_SEARCH_MULTIPATH -gt $MAX_TIME ]; then exit 0 fi sleep $SLEEP_TIME RUNNING_TIME_SEARCH_MULTIPATH=$(($RUNNING_TIME_SEARCH_MULTIPATH + $SLEEP_TIME)) done fi if [ -x "/sbin/mount.ocfs2" ]; then while : ; do STOP_SERVICE_OCFS2="N" if [ -e /sys/kernel/config/cluster/ocfs2 ] && [ -e /dlm ]; then STOP_SERVICE_OCFS2="Y" fi if [ "$STOP_SERVICE_OCFS2" = "Y" ]; then if [ -x "/sbin/multipath" ]; then for mpath in $(ls /dev/mapper/); do if tunefs.ocfs2 -Q "%N" /dev/mapper/$mpath 2>/dev/null >/dev/null; then COUNT_PARTS=$(/sbin/dmsetup info /dev/mapper/$mpath | awk '$1 = /Open count:/ {print $3}') MAJOR_PART=$(/sbin/dmsetup info /dev/mapper/$mpath | awk '$1 = /Major, minor:/ {print $3}' | tr -d ",") MINOR_PART=$(/sbin/dmsetup info /dev/mapper/$mpath | awk '$1 = /Major, minor:/ {print $4}' | tr -d ",") if [ $COUNT_PARTS -gt 0 ] && [ $MAJOR_PART ] && [ $MINOR_PART ]; then /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -d -p -part' -j $MAJOR_PART -m $MINOR_PART fi OCFS2_DISK_TMP="/dev/mapper/$mpath" break fi done fi if [ -z "$OCFS2_DISK_TMP" ]; then for mpath in $(sfdisk -s | tac | tail -n +2 | awk -F":" '{print $1}'); do if tunefs.ocfs2 -Q "%N" $mpath 2>/dev/null >/dev/null; then OCFS2_DISK_TMP="$mpath" break fi done fi break fi if [ $RUNNING_TIME_SEARCH_OCFS2 -gt $MAX_TIME ]; then exit 0 fi sleep $SLEEP_TIME RUNNING_TIME_SEARCH_OCFS2=$(($RUNNING_TIME_SEARCH_OCFS2 + $SLEEP_TIME)) done fi if [ -x "/sbin/mount.ocfs2" ] && [ $OCFS2_DISK_TMP ]; then [ ! -d "$OCFS2_MOUNT_FSTAB" ] && mkdir -p "$OCFS2_MOUNT_FSTAB" CHECK_MOUNT_OCFS2=$(LC_ALL=C awk -v dev="$OCFS2_DISK_TMP" -v fstab="$OCFS2_MOUNT_FSTAB" '$1 == dev && $2 == fstab && $3 == "ocfs2" { print "yes" }' /proc/mounts) if [ "$CHECK_MOUNT_OCFS2" != "yes" ]; then mount -t ocfs2 -o acl,defaults $OCFS2_DISK_TMP $OCFS2_MOUNT_FSTAB || true fi if [ "$OCFS2_DISK_TMP" != "$OCFS2_DISK" ]; then llxcfg-setvars OCFS2_DISK="$OCFS2_DISK_TMP" fi while : ; do STOP_SERVICE="N" CHECK_MOUNT_OCFS2=$(LC_ALL=C awk -v dev="$OCFS2_DISK_TMP" -v fstab="$OCFS2_MOUNT_FSTAB" '$1 == dev && $2 == fstab && $3 == "ocfs2" { print "yes" }' /proc/mounts) if [ "$CHECK_MOUNT_OCFS2" = "yes" ]; then STOP_SERVICE="Y" fi if [ "$STOP_SERVICE" = "Y" ] && [ $OCFS2_MOUNT_FSTAB ]; then #if [ "$(LC_ALL=C awk '$2 == "/export/net" { print "found" }' /proc/mounts)" = "found" ]; then # umount /export/net || true #fi for ocfs_dir in $OCFS2_NET_EXPORT_DIRS; do CHECK_OCFS2_DIR_MOUNT=$(LC_ALL=C awk -v dev="$OCFS2_DISK_TMP" -v ocfsdir="/net/$ocfs_dir" '$1 == dev && $2 == ocfsdir { print "yes" }' /proc/mounts) if [ "$CHECK_OCFS2_DIR_MOUNT" = "yes" ]; then continue fi [ ! -d /net/$ocfs_dir ] && mkdir /net/$ocfs_dir 2>/dev/null || true if [ ! -d "$OCFS2_MOUNT_FSTAB/$ocfs_dir" ]; then rsync -ax --acls /net/$ocfs_dir $OCFS2_MOUNT_FSTAB/ || true fi if [ -d $OCFS2_MOUNT_FSTAB/$ocfs_dir ]; then mount --bind $OCFS2_MOUNT_FSTAB/$ocfs_dir /net/$ocfs_dir || true mount --bind $OCFS2_MOUNT_FSTAB/$ocfs_dir /export/net/$ocfs_dir || true fi done for flavour in $LLIUREX_PXE_FLAVOURS;do case $flavour in biblio|server) flavour2="$flavour/casper/server.nfsroot" ;; client) flavour2="$flavour/casper/client.nfsroot" ;; desktop|infantil|lite|music|pime) flavour2="$flavour/casper/filesystem.nfsroot" ;; esac if [ -d "${PXE_HOME}${flavour}" ] && [ -d "${ZNB_HOME}${flavour2}" ]; then if ! mount | grep -q "^${ZNB_HOME}${flavour2}[[:blank:]]\+on[[:blank:]]\+${PXE_HOME}${flavour}\b" ; then mount --bind ${ZNB_HOME}${flavour2} ${PXE_HOME}${flavour} || true fi fi done #llxcfg-cpkg update nfs-server [ -e /etc/ocfs2/mount.ocfs2 ] && . /etc/ocfs2/mount.ocfs2 llxcfg-cpkg update pxe lliurex-update-tcospasswd generate 2>/dev/null exit 0 fi if [ $RUNNING_TIME -gt $MAX_TIME ]; then exit 0 fi sleep $SLEEP_TIME RUNNING_TIME=$(($RUNNING_TIME + $SLEEP_TIME)) done fi /sbin/initctl emit -n llx-cluster-ocfs2-stop end script