Rework TOP_DIR logic

Currently, we use a simple logic for the client scripts to find
libraries, configuration files, etc. We know they will be copied to the
autostart directory from where TOP_DIR is one step up. If a user ever
tried to run a script in its original location (e.g. in scripts/ubuntu),
this logic would fail.

This has been a theoretical problem as long as users just used osbash.sh
or st.py to run the scripts. But if users would like to run extra
scripts, logging in to the nodes and running the scripts where they
find them would be the most natural way to do it.

Right now, the main use case is the heat service which is not installed
by default but can be installed at a later time if so desired -- with
the gotcha described above.

As more services are becoming optional add-ons to the install-guide,
this becomes an issue.

This patch installs a new logic: if a script finds a file named
TOP_DIR in its parent dir, it will use the file's contents as a
pointer to the TOP_DIR location.

TOP_DIR is a file rather than a symlink because the file needs to
work on Windows file systems as well.

The file lives in the parent directory rather than the script directory
because that reduces the number of such files that are required. This
becomes more relevant once we store additional services along with their
supporting files in extras/<service_name>/.

Change-Id: Ib0ccb108e5246ff8e06d87730ce11704d719fb75
This commit is contained in:
Roger Luethi 2017-05-15 15:46:39 +02:00
parent b602967900
commit 6746b7a591
47 changed files with 47 additions and 45 deletions

View File

@ -0,0 +1 @@
..

View File

@ -0,0 +1 @@
..

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"
# Pick up VM_PROXY

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -9,7 +9,7 @@ readonly RCAUTOSTART=osbashauto
# Remove any sysvinit files that called us (written by {ks,preseed}.cfg)
rm -f /etc/init.d/osbash /etc/rc2.d/S40osbash
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
# source_deploy doesn't work here
source "$CONFIG_DIR/deploy.osbash"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -4,7 +4,7 @@ set -o errexit -o nounset
# This script copies the openrc.sh credentials files to the home directory
# in order to make them easier to find for the user.
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"
source "$CONFIG_DIR/openstack"

View File

@ -4,7 +4,7 @@ set -o errexit -o nounset
# This script installs the insecure osbash ssh keys. This allows users to
# log into the VMs using these keys instead of a password.
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -4,7 +4,7 @@ set -o errexit -o nounset
# This scripts configures hostname and networking for all nodes. The filename
# determines the node name.
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"

View File

@ -3,7 +3,7 @@
# This script executes on the pxeserver and installs the PXE services
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$CONFIG_DIR/openstack"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$LIB_DIR/functions.guest.sh"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"
source "$CONFIG_DIR/config.controller"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"

View File

@ -3,7 +3,7 @@
# This scripts executes on the pxeserver and configures the service
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -2,7 +2,7 @@
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/credentials"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
TOP_DIR=$(cd $(cat "../TOP_DIR"||echo $(dirname "$0"))/.. && pwd)
source "$TOP_DIR/config/paths"
source "$LIB_DIR/functions.guest.sh"