summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/vmgrid/XX_vmgrid.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/os-plugins/plugins/vmgrid/XX_vmgrid.sh')
-rw-r--r--src/os-plugins/plugins/vmgrid/XX_vmgrid.sh104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/src/os-plugins/plugins/vmgrid/XX_vmgrid.sh
new file mode 100644
index 00000000..16f5fbd1
--- /dev/null
+++ b/src/os-plugins/plugins/vmgrid/XX_vmgrid.sh
@@ -0,0 +1,104 @@
+# Copyright (c) 2010 - RZ Uni Freiburg
+# Copyright (c) 2010 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# script is included from init via the "." load function - thus it has all
+# variables and functions available
+
+# include default directories
+. /etc/openslx.conf
+
+CONFFILE="/initramfs/plugin-conf/vmgrid.conf"
+PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/vmgrid
+VIRTUALIZATIONPLUGIN=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization
+#RWSHARE=/mnt/${OPENSLX_DEFAULT_VARDIR}/plugins/vmgrid/share
+RWSHARE=/mnt/var/opt/openslx/plugins/vmgrid/share
+RWSHAREMNT=/mnt/var/opt/openslx/mnt/vmgrid
+BINDIR=/mnt/${OPENSLX_DEFAULT_BINDIR}
+PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/vmgrid
+VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/vmgrid
+
+if [ -f $CONFFILE ]; then
+
+ # load needed variables
+ . $CONFFILE
+
+ if [ ${vmgrid_active} -ne 0 ] ; then
+ [ ${DEBUGLEVEL} -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..."
+
+ # load general configuration
+ . /etc/initramfs-setup
+ # include functions
+ . /etc/functions
+
+ testmkd ${PLUGINCONFDIR}
+ testmkd ${VIRTDIR}
+ cp $CONFFILE ${PLUGINCONFDIR}/vmgrid.conf
+ # create link to binpath
+ ln -fs ${PLUGINDIR}/vmgrid ${BINDIR}/vmgrid
+ ln -fs ${PLUGINDIR}/run-vmgrid.sh ${BINDIR}/run-vmgrid.sh
+
+ # mount nfs virt ro share
+ if strinstr "nfs://" "${vmgrid_roshare}"; then
+ virtsrcprot=$(uri_token ${vmgrid_roshare} prot)
+ virtsrcserv=$(uri_token ${vmgrid_roshare} server)
+ virtsrcpath="$(uri_token ${vmgrid_roshare} path)"
+ if [ -n "${virtsrcprot}" -a -n "${virtsrcserv}" -a -n "${virtsrcpath}" ];
+ then
+ virtsrctarget=${VIRTDIR}
+ # mount the vmgrid source ro
+ fsmount ${virtsrcprot} ${virtsrcserv} ${virtsrcpath} ${virtsrctarget} \
+ ro
+ fi
+ fi
+
+ # create rw share
+ testmkd ${RWSHARE}
+ # bind mount id 45 to ${RWSHARE}
+ if strinstr "id45" "${vmgrid_rwshare}" ; then
+ id45part=$(grep " 45 " /etc/disk.partition | awk '{print $1}' | \
+ cut -f 3,3 -d /)
+ if [ -n "${id45part}" ]; then
+ testmkd /mnt/media/${id45part}/vmgrid
+ mount --bind -n /mnt/media/${id45part}/vmgrid ${RWSHARE} \
+ >>/tmp/vmgrid.log 2>&1
+ fi
+ # mount nfs rw share
+ elif strinstr "nfs://" "${vmgrid_rwshare}" ; then
+ rwshareprot=$(uri_token ${vmgrid_rwshare} prot)
+ rwshareserv=$(uri_token ${vmgrid_rwshare} server)
+ rwsharepath="$(uri_token ${vmgrid_rwshare} path)"
+ if [ -n "${rwshareprot}" -a -n "${rwshareserv}" -a -n "${rwsharepath}" ];
+ then
+ # mount to a dir fist to create spec host dir, then bind mount
+ testmkd ${RWSHAREMNT}
+ rwtarget=${RWSHAREMNT}
+ # mount the vmgrid source rw
+ fsmount ${rwshareprot} ${rwshareserv} ${rwsharepath} ${rwtarget} rw
+ # hostname?
+ host_name=${host_name:=$clientip}
+ testmkd ${RWSHAREMNT}/${host_name}
+ mount --bind ${RWSHAREMNT}/${host_name} ${RWSHARE} \
+ >>/tmp/vmgrid.log 2>&1
+ fi
+ else
+ testmkd /mnt/tmp/vmgrid
+ mount --bind -n /mnt/tmp/vmgrid ${RWSHARE} >>/tmp/vmgrid.log 2>&1
+ fi
+ # chmod so that everybody can write
+ chmod 1777 ${RWSHARE}
+ echo "vmgrid_rwmnt=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf
+
+ # finished ...
+ [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmgrid' os-plugin ..."
+ fi
+else
+ [ $DEBUGLEVEL -gt 0 ] && echo " * configuration of 'vmgrid' os-plugin failed"
+fi