diff options
author | Christian Zoffoli <xmerlin@gentoo.org> | 2005-03-25 02:19:14 +0000 |
---|---|---|
committer | Christian Zoffoli <xmerlin@gentoo.org> | 2005-03-25 02:19:14 +0000 |
commit | 070fb9fa4562108aea15da5ab5c631b85982715e (patch) | |
tree | 33bb33b9713d309832cc4dcfac1ce133294447aa /sys-fs/gfs | |
parent | Added spanish description to the category metadata (diff) | |
download | gentoo-2-070fb9fa4562108aea15da5ab5c631b85982715e.tar.gz gentoo-2-070fb9fa4562108aea15da5ab5c631b85982715e.tar.bz2 gentoo-2-070fb9fa4562108aea15da5ab5c631b85982715e.zip |
improved init script
(Portage version: 2.0.51.19)
Diffstat (limited to 'sys-fs/gfs')
-rw-r--r-- | sys-fs/gfs/ChangeLog | 5 | ||||
-rwxr-xr-x | sys-fs/gfs/files/gfs.rc | 179 |
2 files changed, 116 insertions, 68 deletions
diff --git a/sys-fs/gfs/ChangeLog b/sys-fs/gfs/ChangeLog index e4861ca2732c..70cc1ccf11bd 100644 --- a/sys-fs/gfs/ChangeLog +++ b/sys-fs/gfs/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for sys-fs/gfs # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-fs/gfs/ChangeLog,v 1.6 2005/03/23 14:35:55 xmerlin Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/gfs/ChangeLog,v 1.7 2005/03/25 02:19:14 xmerlin Exp $ + + 25 Mar 2005; Christian Zoffoli <xmerlin@gentoo.org> files/gfs.rc: + improved init script 23 Mar 2005; Christian Zoffoli <xmerlin@gentoo.org> files/gfs.rc: added lock_harness module remove in init diff --git a/sys-fs/gfs/files/gfs.rc b/sys-fs/gfs/files/gfs.rc index 7dc350e0f4c6..07130d2b3531 100755 --- a/sys-fs/gfs/files/gfs.rc +++ b/sys-fs/gfs/files/gfs.rc @@ -1,77 +1,71 @@ #!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later -# $Header: /var/cvsroot/gentoo-x86/sys-fs/gfs/files/gfs.rc,v 1.3 2005/03/23 14:35:55 xmerlin Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/gfs/files/gfs.rc,v 1.4 2005/03/25 02:19:14 xmerlin Exp $ + +opts="${opts} mountall" depend() { use dns logger use net + after gnbd-client clvmd need cluster-manager cluster-locking-manager fenced provide cluster } -start() { - einfo "Starting gfs cluster:" - - if [ ! -f /etc/ntp.conf ] ; then - eerror "Please create /etc/ntp.conf" - eerror "Sample conf: /usr/share/ntp/ntp.conf" - eend 1 - fi +mount_gfs_filesystems() { + local remaining="" + remaining="$(awk '!/^#/ && $3 ~ /gfs/ { if ($4 !~ "noauto") print $1 }' /etc/fstab)" - local module - - # detect cluster/locking manager cman+dlm or gulm ? - if [ -d /proc/cluster/config/cman ]; then - if [ ! -d /proc/cluster/lock_dlm ]; then - modules="${modules} lock_dlm" - fi - else - if [ ! -d /proc/cluster/lock_gulm ]; then - modules="${modules} lock_gulm" - fi - fi - - if [ ! -f /proc/fs/gfs ]; then - modules="${modules} gfs" - fi + if [ -n "${remaining}" ]; then - for module in ${modules}; do - ebegin "Loading ${module} kernel module" - modprobe ${module} + local device="" + local remaining_verified="" - if [ "$?" -ne 0 ] - then - ewend 1 "Failed to load ${module} kernel module" + for device in ${remaining}; do + if [ -b ${device} ]; then + remaining_verified="${remaining_verified} ${device}" + else + if [ $(echo "${device}" | awk '$1 ~ /\/dev\/gnbd/') ]; then + ewarn "Please start /etc/init.d/gnbd-client before trying to mount GNBDs devices" + else + if [ $(echo "${device}" | awk '$1 ~ /\/dev\/vg/') ]; then + ewarn "Please start /etc/init.d/clvmd before trying to mount LVM volumes" + fi + fi + fi + done + + if [ -n "${remaining_verified}" ]; then + einfo "Mounting GFS filesystems" + device="" + for device in ${remaining_verified}; do + local target="$(awk '!/^#/ && $3 ~ /gfs/ { if ("$1" -eq "${device}" ) print $2 }' /etc/fstab)" + local mounted="$(awk '$3 ~ /gfs/ { if ("$1" -eq "${device}" ) print $2 }' /proc/mounts)" + + # mount only filesystems not already mounted + if [ -z "${mounted}" ]; then + ebegin "--> mounting ${device} on ${target}" + mount -t gfs ${device} ${target} >/dev/null + eend $? + else + einfo "--> ${device} already mounted on ${target}" + eend 0 + fi + done else - eend 0 + einfo "No GFS filesystems to automount" fi - done - - ebegin "Mounting GFS filesystems" - mount -at gfs >/dev/null - - if [ "$?" -ne 0 ] - then - ewend 1 "Could not mount all GFS filesystems!" - else - eend 0 fi - - return 0 } -stop() { - einfo "Stopping gfs cluster:" - + +umount_gfs_filesystems() { local sig retry - local remaining="$(awk '$3 ~ /gfs/ { if ($2 != "/") print $2 }' /proc/mounts | sort -r)" + local remaining="$(awk '$3 ~ /gfs/ { print $2 }' /proc/mounts | sort -r)" - if [ -z "${remaining}" ] + if [ -n "${remaining}" ] then - ebegin "Unmounting GFS filesystems" - eend 0 - else sig= retry=3 while [ -n "${remaining}" -a "${retry}" -gt 0 ] @@ -94,12 +88,52 @@ stop() { sig=-9 done fi +} + +load_modules() { + local module modules + modules=$1 + + for module in ${modules}; do + ebegin "Loading ${module} kernel module" + modprobe ${module} + eend $? "Failed to load ${module} kernel module" + done +} +unload_modules() { local module modules + modules=$1 + + for module in ${modules}; do + ebegin "Unloading ${module} kernel module" + modprobe -r ${module} + eend $? "Failed to unload ${module} kernel module" + done +} + +load_gfs_modules() { + local modules + # detect cluster/locking manager cman+dlm or gulm ? + if [ -d /proc/cluster/config/cman ]; then + if [ ! -d /proc/cluster/lock_dlm ]; then + modules="${modules} lock_dlm" + fi + else + if [ ! -d /proc/cluster/lock_gulm ]; then + modules="${modules} lock_gulm" + fi + fi + if [ ! -f /proc/fs/gfs ]; then + modules="${modules} gfs" + fi + load_modules ${modules} +} + +unload_gfs_modules() { if [ -f /proc/fs/gfs ]; then - modules="gfs" - modules="${modules} lock_harness" + modules="gfs lock_harness" fi if [ -d /proc/cluster/lock_dlm ]; then modules="${modules} lock_dlm" @@ -107,19 +141,30 @@ stop() { if [ -d /proc/cluster/lock_gulm ]; then modules="${modules} lock_gulm" fi + unload_modules ${modules} +} + +mountall() { + mount_gfs_filesystems +} + +start() { + einfo "Starting gfs cluster:" - local module - for module in ${modules}; do - ebegin "Unloading ${module} kernel module" - modprobe -r ${module} - - if [ "$?" -ne 0 ] - then - ewend 1 "Failed to unload ${module} kernel module" - else - eend 0 - fi - done + if [ ! -f /etc/ntp.conf ] ; then + eerror "Please create /etc/ntp.conf" + eerror "Sample conf: /usr/share/ntp/ntp.conf" + eend 1 + fi - return 0 + load_gfs_modules + mount_gfs_filesystems } + +stop() { + einfo "Stopping gfs cluster:" + + umount_gfs_filesystems + unload_gfs_modules +} + |