Extract common functions into a separate file
This is the start of an effort to organize devstack's code to better document the requirements for configuring the individual components. Change-Id: I3476b76b9d1f9ee63687fb9898a98729118cbd84
This commit is contained in:
parent
d1ee828f33
commit
7f9aa71bce
91
functions
Normal file
91
functions
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# functions - Common functions used by DevStack components
|
||||||
|
|
||||||
|
|
||||||
|
# apt-get wrapper to set arguments correctly
|
||||||
|
# apt_get package [package ...]
|
||||||
|
function apt_get() {
|
||||||
|
[[ "$OFFLINE" = "True" ]] && return
|
||||||
|
local sudo="sudo"
|
||||||
|
[[ "$(id -u)" = "0" ]] && sudo="env"
|
||||||
|
$sudo DEBIAN_FRONTEND=noninteractive \
|
||||||
|
http_proxy=$http_proxy https_proxy=$https_proxy \
|
||||||
|
apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Gracefully cp only if source file/dir exists
|
||||||
|
# cp_it source destination
|
||||||
|
function cp_it {
|
||||||
|
if [ -e $1 ] || [ -d $1 ]; then
|
||||||
|
cp -pRL $1 $2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
||||||
|
# be owned by the installation user, we create the directory and change the
|
||||||
|
# ownership to the proper user.
|
||||||
|
# Set global RECLONE=yes to simulate a clone when dest-dir exists
|
||||||
|
# git_clone remote dest-dir branch
|
||||||
|
function git_clone {
|
||||||
|
[[ "$OFFLINE" = "True" ]] && return
|
||||||
|
|
||||||
|
GIT_REMOTE=$1
|
||||||
|
GIT_DEST=$2
|
||||||
|
GIT_BRANCH=$3
|
||||||
|
|
||||||
|
if echo $GIT_BRANCH | egrep -q "^refs"; then
|
||||||
|
# If our branch name is a gerrit style refs/changes/...
|
||||||
|
if [[ ! -d $GIT_DEST ]]; then
|
||||||
|
git clone $GIT_REMOTE $GIT_DEST
|
||||||
|
fi
|
||||||
|
cd $GIT_DEST
|
||||||
|
git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD
|
||||||
|
else
|
||||||
|
# do a full clone only if the directory doesn't exist
|
||||||
|
if [[ ! -d $GIT_DEST ]]; then
|
||||||
|
git clone $GIT_REMOTE $GIT_DEST
|
||||||
|
cd $GIT_DEST
|
||||||
|
# This checkout syntax works for both branches and tags
|
||||||
|
git checkout $GIT_BRANCH
|
||||||
|
elif [[ "$RECLONE" == "yes" ]]; then
|
||||||
|
# if it does exist then simulate what clone does if asked to RECLONE
|
||||||
|
cd $GIT_DEST
|
||||||
|
# set the url to pull from and fetch
|
||||||
|
git remote set-url origin $GIT_REMOTE
|
||||||
|
git fetch origin
|
||||||
|
# remove the existing ignored files (like pyc) as they cause breakage
|
||||||
|
# (due to the py files having older timestamps than our pyc, so python
|
||||||
|
# thinks the pyc files are correct using them)
|
||||||
|
find $GIT_DEST -name '*.pyc' -delete
|
||||||
|
git checkout -f origin/$GIT_BRANCH
|
||||||
|
# a local branch might not exist
|
||||||
|
git branch -D $GIT_BRANCH || true
|
||||||
|
git checkout -b $GIT_BRANCH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# pip install wrapper to set cache and proxy environment variables
|
||||||
|
# pip_install package [package ...]
|
||||||
|
function pip_install {
|
||||||
|
[[ "$OFFLINE" = "True" ]] && return
|
||||||
|
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip \
|
||||||
|
HTTP_PROXY=$http_proxy \
|
||||||
|
HTTPS_PROXY=$https_proxy \
|
||||||
|
pip install --use-mirrors $@
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Normalize config values to True or False
|
||||||
|
# VAR=`trueorfalse default-value test-value`
|
||||||
|
function trueorfalse() {
|
||||||
|
local default=$1
|
||||||
|
local testval=$2
|
||||||
|
|
||||||
|
[[ -z "$testval" ]] && { echo "$default"; return; }
|
||||||
|
[[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; }
|
||||||
|
[[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; }
|
||||||
|
echo "$default"
|
||||||
|
}
|
75
stack.sh
75
stack.sh
@ -35,6 +35,9 @@ fi
|
|||||||
# Keep track of the current devstack directory.
|
# Keep track of the current devstack directory.
|
||||||
TOP_DIR=$(cd $(dirname "$0") && pwd)
|
TOP_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# stack.sh keeps the list of **apt** and **pip** dependencies in external
|
# stack.sh keeps the list of **apt** and **pip** dependencies in external
|
||||||
# files, along with config templates and other useful files. You can find these
|
# files, along with config templates and other useful files. You can find these
|
||||||
# in the ``files`` directory (next to this script). We will reference this
|
# in the ``files`` directory (next to this script). We will reference this
|
||||||
@ -86,16 +89,6 @@ source ./stackrc
|
|||||||
# Destination path for installation ``DEST``
|
# Destination path for installation ``DEST``
|
||||||
DEST=${DEST:-/opt/stack}
|
DEST=${DEST:-/opt/stack}
|
||||||
|
|
||||||
# apt-get wrapper to just get arguments set correctly
|
|
||||||
function apt_get() {
|
|
||||||
[[ "$OFFLINE" = "True" ]] && return
|
|
||||||
local sudo="sudo"
|
|
||||||
[ "$(id -u)" = "0" ] && sudo="env"
|
|
||||||
$sudo DEBIAN_FRONTEND=noninteractive \
|
|
||||||
http_proxy=$http_proxy https_proxy=$https_proxy \
|
|
||||||
apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check to see if we are already running a stack.sh
|
# Check to see if we are already running a stack.sh
|
||||||
if screen -ls | egrep -q "[0-9].stack"; then
|
if screen -ls | egrep -q "[0-9].stack"; then
|
||||||
echo "You are already running a stack.sh session."
|
echo "You are already running a stack.sh session."
|
||||||
@ -155,18 +148,6 @@ else
|
|||||||
sudo mv $TEMPFILE /etc/sudoers.d/stack_sh_nova
|
sudo mv $TEMPFILE /etc/sudoers.d/stack_sh_nova
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Normalize config values to True or False
|
|
||||||
# VAR=`trueorfalse default-value test-value`
|
|
||||||
function trueorfalse() {
|
|
||||||
local default=$1
|
|
||||||
local testval=$2
|
|
||||||
|
|
||||||
[[ -z "$testval" ]] && { echo "$default"; return; }
|
|
||||||
[[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; }
|
|
||||||
[[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; }
|
|
||||||
echo "$default"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set True to configure stack.sh to run cleanly without Internet access.
|
# Set True to configure stack.sh to run cleanly without Internet access.
|
||||||
# stack.sh must have been previously run with Internet access to install
|
# stack.sh must have been previously run with Internet access to install
|
||||||
# prerequisites and initialize $DEST.
|
# prerequisites and initialize $DEST.
|
||||||
@ -526,14 +507,6 @@ function get_packages() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function pip_install {
|
|
||||||
[[ "$OFFLINE" = "True" ]] && return
|
|
||||||
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip \
|
|
||||||
HTTP_PROXY=$http_proxy \
|
|
||||||
HTTPS_PROXY=$https_proxy \
|
|
||||||
pip install --use-mirrors $@
|
|
||||||
}
|
|
||||||
|
|
||||||
# install apt requirements
|
# install apt requirements
|
||||||
apt_get update
|
apt_get update
|
||||||
apt_get install $(get_packages)
|
apt_get install $(get_packages)
|
||||||
@ -541,48 +514,6 @@ apt_get install $(get_packages)
|
|||||||
# install python requirements
|
# install python requirements
|
||||||
pip_install `cat $FILES/pips/* | uniq`
|
pip_install `cat $FILES/pips/* | uniq`
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
|
||||||
# be owned by the installation user, we create the directory and change the
|
|
||||||
# ownership to the proper user.
|
|
||||||
function git_clone {
|
|
||||||
[[ "$OFFLINE" = "True" ]] && return
|
|
||||||
|
|
||||||
GIT_REMOTE=$1
|
|
||||||
GIT_DEST=$2
|
|
||||||
GIT_BRANCH=$3
|
|
||||||
|
|
||||||
if echo $GIT_BRANCH | egrep -q "^refs"; then
|
|
||||||
# If our branch name is a gerrit style refs/changes/...
|
|
||||||
if [ ! -d $GIT_DEST ]; then
|
|
||||||
git clone $GIT_REMOTE $GIT_DEST
|
|
||||||
fi
|
|
||||||
cd $GIT_DEST
|
|
||||||
git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD
|
|
||||||
else
|
|
||||||
# do a full clone only if the directory doesn't exist
|
|
||||||
if [ ! -d $GIT_DEST ]; then
|
|
||||||
git clone $GIT_REMOTE $GIT_DEST
|
|
||||||
cd $GIT_DEST
|
|
||||||
# This checkout syntax works for both branches and tags
|
|
||||||
git checkout $GIT_BRANCH
|
|
||||||
elif [[ "$RECLONE" == "yes" ]]; then
|
|
||||||
# if it does exist then simulate what clone does if asked to RECLONE
|
|
||||||
cd $GIT_DEST
|
|
||||||
# set the url to pull from and fetch
|
|
||||||
git remote set-url origin $GIT_REMOTE
|
|
||||||
git fetch origin
|
|
||||||
# remove the existing ignored files (like pyc) as they cause breakage
|
|
||||||
# (due to the py files having older timestamps than our pyc, so python
|
|
||||||
# thinks the pyc files are correct using them)
|
|
||||||
find $GIT_DEST -name '*.pyc' -delete
|
|
||||||
git checkout -f origin/$GIT_BRANCH
|
|
||||||
# a local branch might not exist
|
|
||||||
git branch -D $GIT_BRANCH || true
|
|
||||||
git checkout -b $GIT_BRANCH
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# compute service
|
# compute service
|
||||||
git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
|
git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
|
||||||
# python client library to nova that horizon (and others) use
|
# python client library to nova that horizon (and others) use
|
||||||
|
@ -47,7 +47,10 @@ IMG_FILE=$1
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# Store cwd
|
# Store cwd
|
||||||
CWD=`pwd`
|
CWD=`pwd`
|
||||||
@ -170,35 +173,6 @@ if [ ! -r "`ls $MNTDIR/boot/vmlinuz-*-generic | head -1`" ]; then
|
|||||||
chroot $MNTDIR apt-get install -y linux-generic
|
chroot $MNTDIR apt-get install -y linux-generic
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
|
||||||
# be owned by the installation user, we create the directory and change the
|
|
||||||
# ownership to the proper user.
|
|
||||||
function git_clone {
|
|
||||||
|
|
||||||
# clone new copy or fetch latest changes
|
|
||||||
CHECKOUT=${MNTDIR}$2
|
|
||||||
if [ ! -d $CHECKOUT ]; then
|
|
||||||
mkdir -p $CHECKOUT
|
|
||||||
git clone $1 $CHECKOUT
|
|
||||||
else
|
|
||||||
pushd $CHECKOUT
|
|
||||||
git fetch
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME(ja): checkout specified version (should works for branches and tags)
|
|
||||||
|
|
||||||
pushd $CHECKOUT
|
|
||||||
# checkout the proper branch/tag
|
|
||||||
git checkout $3
|
|
||||||
# force our local version to be the same as the remote version
|
|
||||||
git reset --hard origin/$3
|
|
||||||
popd
|
|
||||||
|
|
||||||
# give ownership to the stack user
|
|
||||||
chroot $MNTDIR chown -R stack $2
|
|
||||||
}
|
|
||||||
|
|
||||||
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
|
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
|
||||||
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
|
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
|
||||||
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
|
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
|
||||||
|
@ -26,7 +26,10 @@ trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# Abort if localrc is not set
|
# Abort if localrc is not set
|
||||||
if [ ! -e $TOP_DIR/localrc ]; then
|
if [ ! -e $TOP_DIR/localrc ]; then
|
||||||
@ -43,42 +46,8 @@ DEST=${DEST:-/opt/stack}
|
|||||||
|
|
||||||
TEMPEST_DIR=$DEST/tempest
|
TEMPEST_DIR=$DEST/tempest
|
||||||
|
|
||||||
DIST_NAME=${DIST_NAME:-oneiric}
|
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
|
||||||
# be owned by the installation user, we create the directory and change the
|
|
||||||
# ownership to the proper user.
|
|
||||||
function git_clone {
|
|
||||||
|
|
||||||
GIT_REMOTE=$1
|
|
||||||
GIT_DEST=$2
|
|
||||||
GIT_BRANCH=$3
|
|
||||||
|
|
||||||
# do a full clone only if the directory doesn't exist
|
|
||||||
if [ ! -d $GIT_DEST ]; then
|
|
||||||
git clone $GIT_REMOTE $GIT_DEST
|
|
||||||
cd $2
|
|
||||||
# This checkout syntax works for both branches and tags
|
|
||||||
git checkout $GIT_BRANCH
|
|
||||||
elif [[ "$RECLONE" == "yes" ]]; then
|
|
||||||
# if it does exist then simulate what clone does if asked to RECLONE
|
|
||||||
cd $GIT_DEST
|
|
||||||
# set the url to pull from and fetch
|
|
||||||
git remote set-url origin $GIT_REMOTE
|
|
||||||
git fetch origin
|
|
||||||
# remove the existing ignored files (like pyc) as they cause breakage
|
|
||||||
# (due to the py files having older timestamps than our pyc, so python
|
|
||||||
# thinks the pyc files are correct using them)
|
|
||||||
find $GIT_DEST -name '*.pyc' -delete
|
|
||||||
git checkout -f origin/$GIT_BRANCH
|
|
||||||
# a local branch might not exist
|
|
||||||
git branch -D $GIT_BRANCH || true
|
|
||||||
git checkout -b $GIT_BRANCH
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install tests and prerequisites
|
# Install tests and prerequisites
|
||||||
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/tempest`
|
pip_install `cat $TOP_DIR/files/pips/tempest`
|
||||||
|
|
||||||
git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
|
git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
|
||||||
|
|
||||||
|
@ -8,7 +8,10 @@ fi
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
cd $TOP_DIR
|
cd $TOP_DIR
|
||||||
|
|
||||||
@ -34,7 +37,7 @@ fi
|
|||||||
|
|
||||||
# Install deps if needed
|
# Install deps if needed
|
||||||
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
|
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
|
||||||
apt-get install -y --force-yes $DEPS || true # allow this to fail gracefully for concurrent builds
|
apt_get install -y --force-yes $DEPS || true # allow this to fail gracefully for concurrent builds
|
||||||
|
|
||||||
# Where to store files and instances
|
# Where to store files and instances
|
||||||
WORK_DIR=${WORK_DIR:-/opt/uecstack}
|
WORK_DIR=${WORK_DIR:-/opt/uecstack}
|
||||||
|
@ -40,7 +40,10 @@ DEST_FILE=$1
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
cd $TOP_DIR
|
cd $TOP_DIR
|
||||||
|
|
||||||
@ -68,7 +71,7 @@ fi
|
|||||||
|
|
||||||
# Install deps if needed
|
# Install deps if needed
|
||||||
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
|
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
|
||||||
apt-get install -y --force-yes $DEPS
|
apt_get install -y --force-yes $DEPS
|
||||||
|
|
||||||
# Where to store files and instances
|
# Where to store files and instances
|
||||||
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
|
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
|
||||||
@ -113,35 +116,6 @@ if [ ! -r "`ls $MNT_DIR/boot/vmlinuz-*-generic | head -1`" ]; then
|
|||||||
chroot $MNT_DIR apt-get install -y linux-generic
|
chroot $MNT_DIR apt-get install -y linux-generic
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
|
||||||
# be owned by the installation user, we create the directory and change the
|
|
||||||
# ownership to the proper user.
|
|
||||||
function git_clone {
|
|
||||||
|
|
||||||
# clone new copy or fetch latest changes
|
|
||||||
CHECKOUT=${MNT_DIR}$2
|
|
||||||
if [ ! -d $CHECKOUT ]; then
|
|
||||||
mkdir -p $CHECKOUT
|
|
||||||
git clone $1 $CHECKOUT
|
|
||||||
else
|
|
||||||
pushd $CHECKOUT
|
|
||||||
git fetch
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME(ja): checkout specified version (should works for branches and tags)
|
|
||||||
|
|
||||||
pushd $CHECKOUT
|
|
||||||
# checkout the proper branch/tag
|
|
||||||
git checkout $3
|
|
||||||
# force our local version to be the same as the remote version
|
|
||||||
git reset --hard origin/$3
|
|
||||||
popd
|
|
||||||
|
|
||||||
# give ownership to the stack user
|
|
||||||
chroot $MNT_DIR chown -R stack $2
|
|
||||||
}
|
|
||||||
|
|
||||||
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
|
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
|
||||||
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
|
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
|
||||||
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
|
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
|
||||||
|
@ -30,7 +30,10 @@ trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# Abort if localrc is not set
|
# Abort if localrc is not set
|
||||||
if [ ! -e $TOP_DIR/localrc ]; then
|
if [ ! -e $TOP_DIR/localrc ]; then
|
||||||
|
@ -8,7 +8,10 @@ set -o errexit
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# Change dir to top of devstack
|
# Change dir to top of devstack
|
||||||
cd $TOP_DIR
|
cd $TOP_DIR
|
||||||
@ -47,13 +50,6 @@ echo stack:pass | chroot $STAGING_DIR chpasswd
|
|||||||
( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
|
( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
|
||||||
> $STAGING_DIR/etc/sudoers.d/50_stack_sh )
|
> $STAGING_DIR/etc/sudoers.d/50_stack_sh )
|
||||||
|
|
||||||
# Gracefully cp only if source file/dir exists
|
|
||||||
function cp_it {
|
|
||||||
if [ -e $1 ] || [ -d $1 ]; then
|
|
||||||
cp -pRL $1 $2
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Copy over your ssh keys and env if desired
|
# Copy over your ssh keys and env if desired
|
||||||
cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh
|
cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh
|
||||||
cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys
|
cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys
|
||||||
|
@ -6,7 +6,10 @@ ROOTSIZE=${ROOTSIZE:-2000}
|
|||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
|
||||||
|
|
||||||
|
# Import common functions
|
||||||
|
. $TOP_DIR/functions
|
||||||
|
|
||||||
# exit on error to stop unexpected errors
|
# exit on error to stop unexpected errors
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
Loading…
Reference in New Issue
Block a user