summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/emufe/XX_emufe.sh
blob: 22dabdf598fdaa4cf60dc0a1676397813e03b974 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (c) 2011 - RZ Uni Freiburg
# Copyright (c) 2011 - 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

ETCDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}
PLUGINCONFDIR=${ETCDIR}/plugins/emufe
BINDIR=/mnt/${OPENSLX_DEFAULT_BINDIR}
PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/emufe
VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}

# check if the configuration file is available
if [ -e /initramfs/plugin-conf/emufe.conf ]; then

  # load needed variables
  . /initramfs/plugin-conf/emufe.conf

  # Test if this plugin is activated... more or less useless with the
  # new plugin system
  if [ ${emufe_active} -ne 0 2>/dev/null ]; then
    [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'emufe' os-plugin ...";

    # copy virtualization include files and emufe.conf to config dir
    testmkd ${PLUGINCONFDIR}
    cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR}
    cp ${CONFFILE} ${PLUGINCONFDIR}
  fi

  ############################################################################
  # emulator stuff provisioning: two scenarios
  # * VM images in /usr/share/emufe - then simply link
  # * VM images via additional mount (mount source NFS, NBD, ...)

  # get source of emufe image server (get type, server and path)
  if strinstr "/" "${emufe_imagesrc}" ; then
    vmimgprot=$(uri_token ${emufe_imagesrc} prot)
    vmimgserv=$(uri_token ${emufe_imagesrc} server)
    vmimgpath="$(uri_token ${emufe_imagesrc} path)"
  fi
  if [ -n "${vmimgserv}" -a -n ${vmimgpath} -a -n ${vmimgprot} ] ; then
    mnttarget=${VIRTDIR}/emulation
    # mount the emufe image source readonly (ro)
    fsmount ${vmimgprot} ${vmimgserv} ${vmimgpath} ${mnttarget} ro
  else
    [ $DEBUGLEVEL -gt 1 ] && error "  * Incomplete information in variable \
${emufe_imagesrc}." nonfatal
  fi
else
  [ $DEBUGLEVEL -gt 0 ] && echo "  * Configuration of 'emufe' plugin failed"
fi