Merge "Clean up bashate failures"

This commit is contained in:
Jenkins 2014-10-20 18:35:44 +00:00 committed by Gerrit Code Review
commit 5dba0f5637
10 changed files with 283 additions and 284 deletions

View File

@ -3,12 +3,12 @@
MODULE_PATH=/etc/puppet/modules MODULE_PATH=/etc/puppet/modules
function remove_module { function remove_module {
local SHORT_MODULE_NAME=$1 local SHORT_MODULE_NAME=$1
if [ -n "$SHORT_MODULE_NAME" ]; then if [ -n "$SHORT_MODULE_NAME" ]; then
rm -Rf "$MODULE_PATH/$SHORT_MODULE_NAME" rm -Rf "$MODULE_PATH/$SHORT_MODULE_NAME"
else else
echo "ERROR: remove_module requires a SHORT_MODULE_NAME." echo "ERROR: remove_module requires a SHORT_MODULE_NAME."
fi fi
} }
# Array of modules to be installed key:value is module:version. # Array of modules to be installed key:value is module:version.
@ -21,7 +21,7 @@ declare -A SOURCE_MODULES
#NOTE: if we previously installed kickstandproject-ntp we nuke it here #NOTE: if we previously installed kickstandproject-ntp we nuke it here
# since puppetlabs-ntp and kickstandproject-ntp install to the same dir # since puppetlabs-ntp and kickstandproject-ntp install to the same dir
if grep kickstandproject-ntp /etc/puppet/modules/ntp/Modulefile &> /dev/null; then if grep kickstandproject-ntp /etc/puppet/modules/ntp/Modulefile &> /dev/null; then
remove_module "ntp" remove_module "ntp"
fi fi
remove_module "gearman" #remove old saz-gearman remove_module "gearman" #remove old saz-gearman
@ -62,63 +62,60 @@ SOURCE_MODULES["https://github.com/puppet-community/puppet-module-puppetboard"]=
# Add modules that should be part of the openstack-infra integration test here # Add modules that should be part of the openstack-infra integration test here
if [[ "$PUPPET_INTEGRATION_TEST" -ne "1" ]]; then if [[ "$PUPPET_INTEGRATION_TEST" -ne "1" ]]; then
SOURCE_MODULES["https://git.openstack.org/openstack-infra/puppet-storyboard"]="origin/master" SOURCE_MODULES["https://git.openstack.org/openstack-infra/puppet-storyboard"]="origin/master"
fi fi
MODULE_LIST=`puppet module list` MODULE_LIST=`puppet module list`
# Transition away from old things # Transition away from old things
if [ -d /etc/puppet/modules/vcsrepo/.git ] if [ -d /etc/puppet/modules/vcsrepo/.git ]; then
then rm -rf /etc/puppet/modules/vcsrepo
rm -rf /etc/puppet/modules/vcsrepo
fi fi
# Install all the modules # Install all the modules
for MOD in ${!MODULES[*]} ; do for MOD in ${!MODULES[*]} ; do
# If the module at the current version does not exist upgrade or install it. # If the module at the current version does not exist upgrade or install it.
if ! echo $MODULE_LIST | grep "$MOD ([^v]*v${MODULES[$MOD]}" >/dev/null 2>&1 if ! echo $MODULE_LIST | grep "$MOD ([^v]*v${MODULES[$MOD]}" >/dev/null 2>&1 ; then
then # Attempt module upgrade. If that fails try installing the module.
# Attempt module upgrade. If that fails try installing the module. if ! puppet module upgrade $MOD --version ${MODULES[$MOD]} >/dev/null 2>&1 ; then
if ! puppet module upgrade $MOD --version ${MODULES[$MOD]} >/dev/null 2>&1 # This will get run in cron, so silence non-error output
then puppet module install $MOD --version ${MODULES[$MOD]} >/dev/null
# This will get run in cron, so silence non-error output fi
puppet module install $MOD --version ${MODULES[$MOD]} >/dev/null
fi fi
fi
done done
MODULE_LIST=`puppet module list` MODULE_LIST=`puppet module list`
# Make a second pass, just installing modules from source # Make a second pass, just installing modules from source
for MOD in ${!SOURCE_MODULES[*]} ; do for MOD in ${!SOURCE_MODULES[*]} ; do
# get the name of the module directory # get the name of the module directory
if [ `echo $MOD | awk -F. '{print $NF}'` = 'git' ]; then if [ `echo $MOD | awk -F. '{print $NF}'` = 'git' ]; then
echo "Remote repos of the form repo.git are not supported: ${MOD}" echo "Remote repos of the form repo.git are not supported: ${MOD}"
exit 1 exit 1
fi fi
MODULE_NAME=`echo $MOD | awk -F- '{print $NF}'` MODULE_NAME=`echo $MOD | awk -F- '{print $NF}'`
# set up git base command to use the correct path # set up git base command to use the correct path
GIT_CMD_BASE="git --git-dir=${MODULE_PATH}/${MODULE_NAME}/.git --work-tree ${MODULE_PATH}/${MODULE_NAME}" GIT_CMD_BASE="git --git-dir=${MODULE_PATH}/${MODULE_NAME}/.git --work-tree ${MODULE_PATH}/${MODULE_NAME}"
# treat any occurrence of the module as a match # treat any occurrence of the module as a match
if ! echo $MODULE_LIST | grep "${MODULE_NAME}" >/dev/null 2>&1; then if ! echo $MODULE_LIST | grep "${MODULE_NAME}" >/dev/null 2>&1; then
# clone modules that are not installed # clone modules that are not installed
git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" git clone $MOD "${MODULE_PATH}/${MODULE_NAME}"
else else
if [ ! -d ${MODULE_PATH}/${MODULE_NAME}/.git ]; then if [ ! -d ${MODULE_PATH}/${MODULE_NAME}/.git ]; then
echo "Found directory ${MODULE_PATH}/${MODULE_NAME} that is not a git repo, deleting it and reinstalling from source" echo "Found directory ${MODULE_PATH}/${MODULE_NAME} that is not a git repo, deleting it and reinstalling from source"
remove_module $MODULE_NAME remove_module $MODULE_NAME
git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" git clone $MOD "${MODULE_PATH}/${MODULE_NAME}"
elif [ `${GIT_CMD_BASE} remote show origin | grep 'Fetch URL' | awk -F'URL: ' '{print $2}'` != $MOD ]; then elif [ `${GIT_CMD_BASE} remote show origin | grep 'Fetch URL' | awk -F'URL: ' '{print $2}'` != $MOD ]; then
echo "Found remote in ${MODULE_PATH}/${MODULE_NAME} that does not match desired remote ${MOD}, deleting dir and re-cloning" echo "Found remote in ${MODULE_PATH}/${MODULE_NAME} that does not match desired remote ${MOD}, deleting dir and re-cloning"
remove_module $MODULE_NAME remove_module $MODULE_NAME
git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" git clone $MOD "${MODULE_PATH}/${MODULE_NAME}"
fi
fi
# fetch the latest refs from the repo
$GIT_CMD_BASE remote update
# make sure the correct revision is installed, I have to use rev-list b/c rev-parse does not work with tags
if [ `${GIT_CMD_BASE} rev-list HEAD --max-count=1` != `${GIT_CMD_BASE} rev-list ${SOURCE_MODULES[$MOD]} --max-count=1` ]; then
# checkout correct revision
$GIT_CMD_BASE checkout ${SOURCE_MODULES[$MOD]}
fi fi
fi
# fetch the latest refs from the repo
$GIT_CMD_BASE remote update
# make sure the correct revision is installed, I have to use rev-list b/c rev-parse does not work with tags
if [ `${GIT_CMD_BASE} rev-list HEAD --max-count=1` != `${GIT_CMD_BASE} rev-list ${SOURCE_MODULES[$MOD]} --max-count=1` ]; then
# checkout correct revision
$GIT_CMD_BASE checkout ${SOURCE_MODULES[$MOD]}
fi
done done

View File

@ -5,72 +5,70 @@ cd /usr/share/cacti/cli
HOST_NAME=$1 HOST_NAME=$1
HOST_TEMPLATE_ID=`php -q /usr/share/cacti/cli/add_device.php \ HOST_TEMPLATE_ID=`php -q /usr/share/cacti/cli/add_device.php \
--list-host-templates |grep "Linux Host"|cut -f 1` --list-host-templates |grep "Linux Host"|cut -f 1`
php -q add_device.php --description="$HOST_NAME" --ip="$HOST_NAME" \ php -q add_device.php --description="$HOST_NAME" --ip="$HOST_NAME" \
--template=$HOST_TEMPLATE_ID --version=2 --community="public" --template=$HOST_TEMPLATE_ID --version=2 --community="public"
HOST_ID=`php -q add_graphs.php --list-hosts |grep $HOST_NAME|cut -f 1` HOST_ID=`php -q add_graphs.php --list-hosts |grep $HOST_NAME|cut -f 1`
TREE_ID=`php -q add_tree.php --list-trees |grep "All Hosts"|cut -f 1` TREE_ID=`php -q add_tree.php --list-trees |grep "All Hosts"|cut -f 1`
php -q add_tree.php --type=node --node-type=host --tree-id=$TREE_ID \ php -q add_tree.php --type=node --node-type=host --tree-id=$TREE_ID \
--host-id=$HOST_ID --host-id=$HOST_ID
php -q poller_reindex_hosts.php --id=$HOST_ID php -q poller_reindex_hosts.php --id=$HOST_ID
php -q add_graphs.php --list-graph-templates \ php -q add_graphs.php --list-graph-templates \
--host-template-id=$HOST_TEMPLATE_ID | \ --host-template-id=$HOST_TEMPLATE_ID | \
while read line while read line ; do
do if echo $line | grep "Known" >/dev/null || [ "$line" == "" ] ; then
if echo $line | grep "Known" >/dev/null || [ "$line" == "" ] continue
then fi
continue TEMPLATE_ID=`echo $line | cut -f 1 -d ' '`
fi php -q add_graphs.php --host-id=$HOST_ID --graph-type=cg \
TEMPLATE_ID=`echo $line | cut -f 1 -d ' '` --graph-template-id=$TEMPLATE_ID
php -q add_graphs.php --host-id=$HOST_ID --graph-type=cg \ done
--graph-template-id=$TEMPLATE_ID
done
function add_ds_graph { function add_ds_graph {
TEMPLATE_NAME=$1 TEMPLATE_NAME=$1
TYPE_NAME=$2 TYPE_NAME=$2
FIELD_NAME=$3 FIELD_NAME=$3
FIELD_VALUE=$4 FIELD_VALUE=$4
TEMPLATE_ID=`php -q add_graphs.php --list-graph-templates | \ TEMPLATE_ID=`php -q add_graphs.php --list-graph-templates | \
grep "$TEMPLATE_NAME"|cut -f 1` grep "$TEMPLATE_NAME"|cut -f 1`
TYPE_ID=`php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID \ TYPE_ID=`php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID \
--list-query-types | grep "$TYPE_NAME"|cut -f 1` --list-query-types | grep "$TYPE_NAME"|cut -f 1`
php -q add_graphs.php --host-id=$HOST_ID --graph-type=ds \ php -q add_graphs.php --host-id=$HOST_ID --graph-type=ds \
--graph-template-id=$TEMPLATE_ID --snmp-query-id=$SNMP_QUERY_ID \ --graph-template-id=$TEMPLATE_ID --snmp-query-id=$SNMP_QUERY_ID \
--snmp-query-type-id=$TYPE_ID --snmp-field=$FIELD_NAME \ --snmp-query-type-id=$TYPE_ID --snmp-field=$FIELD_NAME \
--snmp-value=$FIELD_VALUE --snmp-value=$FIELD_VALUE
} }
# php -q add_graphs.php --list-graph-templates # php -q add_graphs.php --list-graph-templates
# php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID --list-query-types # php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID --list-query-types
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \ SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "SNMP - Get Mounted Partitions"|cut -f 1` grep "SNMP - Get Mounted Partitions"|cut -f 1`
add_ds_graph "Host MIB - Available Disk Space" "Available Disk Space" \ add_ds_graph "Host MIB - Available Disk Space" "Available Disk Space" \
"hrStorageDescr" "/" "hrStorageDescr" "/"
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \ SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "SNMP - Interface Statistics"|cut -f 1` grep "SNMP - Interface Statistics"|cut -f 1`
add_ds_graph "Interface - Traffic (bits/sec)" "In/Out Bits (64-bit Counters)" \ add_ds_graph "Interface - Traffic (bits/sec)" "In/Out Bits (64-bit Counters)" \
"ifOperStatus" "Up" "ifOperStatus" "Up"
add_ds_graph "Interface - Errors/Discards" "In/Out Errors/Discarded Packets" \ add_ds_graph "Interface - Errors/Discards" "In/Out Errors/Discarded Packets" \
"ifOperStatus" "Up" "ifOperStatus" "Up"
add_ds_graph "Interface - Unicast Packets" "In/Out Unicast Packets" \ add_ds_graph "Interface - Unicast Packets" "In/Out Unicast Packets" \
"ifOperStatus" "Up" "ifOperStatus" "Up"
add_ds_graph "Interface - Non-Unicast Packets" "In/Out Non-Unicast Packets" \ add_ds_graph "Interface - Non-Unicast Packets" "In/Out Non-Unicast Packets" \
"ifOperStatus" "Up" "ifOperStatus" "Up"
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \ SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "ucd/net - Get IO Devices"|cut -f 1` grep "ucd/net - Get IO Devices"|cut -f 1`
for disk in $(php -q add_graphs.php --host-id=$HOST_ID --snmp-field=diskIODevice --list-snmp-values | grep xvd[a-z]$) ; do for disk in $(php -q add_graphs.php --host-id=$HOST_ID --snmp-field=diskIODevice --list-snmp-values | grep xvd[a-z]$) ; do
add_ds_graph "ucd/net - Device IO - Operations" "IO Operations" \ add_ds_graph "ucd/net - Device IO - Operations" "IO Operations" \

View File

@ -23,17 +23,17 @@ source $TOP_DIR/deployrc
command="${1}" command="${1}"
case $command in case $command in
init) init)
site_init ${2} site_init ${2}
;; ;;
status) status)
site_status ${2} site_status ${2}
;; ;;
update) update)
site_update ${2} site_update ${2}
;; ;;
*) *)
print_help print_help
exit 1 exit 1
;; ;;
esac esac

View File

@ -5,4 +5,4 @@ FILE_GROUP=www-data
# allow local overrides of env variables # allow local overrides of env variables
if [ -f $TOP_DIR/localrc ]; then if [ -f $TOP_DIR/localrc ]; then
. $TOP_DIR/localrc . $TOP_DIR/localrc
fi fi

View File

@ -1,176 +1,176 @@
function print_help() { function print_help {
echo "Usage: `basename $0` command [options]" echo "Usage: `basename $0` command [options]"
echo "" echo ""
echo "Commands:" echo "Commands:"
echo " status [site] return status information about site configurations" echo " status [site] return status information about site configurations"
echo " init <site> initialize site structure" echo " init <site> initialize site structure"
echo " update <site> update to new version" echo " update <site> update to new version"
echo "" echo ""
} }
function site_init() { function site_init {
if [ ! $1 ]; then if [ ! $1 ]; then
echo "ERROR: site parameter mandatory" echo "ERROR: site parameter mandatory"
exit 1 exit 1
fi
CONF_PATH="$CONF_DIR/conf.d/$1.conf"
if [ ! -f $CONF_PATH ]; then
echo "Site configuration not found: " $1
exit 1
fi
source $CONF_PATH
if [ -f "$SITE_ROOT/w/public/index.php" ]; then
echo "Cannot override an existing deployment: $SITE_ROOT/w"
exit 1
fi
# cleanup previous broken deployment
rm -rf $SITE_ROOT/slot0
# create directory structure
for dir in slot0 slot1; do
mkdir -p $SITE_ROOT/$dir
chown $FILE_OWNER:$FILE_GROUP $SITE_ROOT/$dir
done
target_dir="$SITE_ROOT/slot0"
# fetch catalog and write actual version
fetch_catalog
RELEASE_VERSION=`catalog_get_version`
echo $RELEASE_VERSION > $SITE_ROOT/slot0/release
# fetch and extract release tarball
umask 0027
if [[ $SOURCE_TARBALL == http* ]]; then
echo "Download from http!"
curl $SOURCE_TARBALL | tar -xzv -C $target_dir --strip-components 1 --no-same-permissions
else
echo "extract from local file system"
if [ ! -f $SOURCE_TARBALL ]; then
echo "Source tarball not found: $SOURCE_TARBALL"
exit 1
fi fi
tar -xzvf $SOURCE_TARBALL -C $target_dir --strip-components 1 --no-same-permissions CONF_PATH="$CONF_DIR/conf.d/$1.conf"
fi if [ ! -f $CONF_PATH ]; then
chown -R $FILE_OWNER:$FILE_GROUP $target_dir echo "Site configuration not found: " $1
umask 0022 exit 1
# link configuration files managed by puppet
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
# convert app/storage into symlink and set permissions
mv $target_dir/app/storage $SITE_ROOT/
chmod 02770 $SITE_ROOT/storage
find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
# populate application database
cd $target_dir
php artisan migrate --env=$LARAVEL_ENV
php artisan db:seed --env=$LARAVEL_ENV
# activate site
rm -rf $SITE_ROOT/w
ln -s $SITE_ROOT/slot0 $SITE_ROOT/w
}
function site_status() {
if [ ! $1 ]; then
echo "ERROR: site parameter mandatory"
exit 1
fi
CONF_PATH="$CONF_DIR/conf.d/$1.conf"
if [ ! -f $CONF_PATH ]; then
echo "Site configuration not found: $1"
exit 0
fi
source $CONF_PATH
if [ ! -f "$SITE_ROOT/w/public/index.php" ]; then
if [ -d "$SITE_ROOT/slot0" ]; then
echo "PENDING"
else
echo "N/A"
exit 1
fi fi
else source $CONF_PATH
if [ -f "$SITE_ROOT/w/public/index.php" ]; then
echo "Cannot override an existing deployment: $SITE_ROOT/w"
exit 1
fi
# cleanup previous broken deployment
rm -rf $SITE_ROOT/slot0
# create directory structure
for dir in slot0 slot1; do
mkdir -p $SITE_ROOT/$dir
chown $FILE_OWNER:$FILE_GROUP $SITE_ROOT/$dir
done
target_dir="$SITE_ROOT/slot0"
# fetch catalog and write actual version
fetch_catalog fetch_catalog
REMOTE_VERSION=`catalog_get_version` RELEASE_VERSION=`catalog_get_version`
RELEASE_VERSION=$(head -n 1 $SITE_ROOT/w/release) echo $RELEASE_VERSION > $SITE_ROOT/slot0/release
if [ "$REMOTE_VERSION" == "$RELEASE_VERSION" ]; then # fetch and extract release tarball
echo "INSTALLED [$RELEASE_VERSION]" umask 0027
if [[ $SOURCE_TARBALL == http* ]]; then
echo "Download from http!"
curl $SOURCE_TARBALL | tar -xzv -C $target_dir --strip-components 1 --no-same-permissions
else else
echo "UPDATE AVAILABLE [$RELEASE_VERSION-$REMOTE_VERSION]" echo "extract from local file system"
if [ ! -f $SOURCE_TARBALL ]; then
echo "Source tarball not found: $SOURCE_TARBALL"
exit 1
fi
tar -xzvf $SOURCE_TARBALL -C $target_dir --strip-components 1 --no-same-permissions
fi fi
fi chown -R $FILE_OWNER:$FILE_GROUP $target_dir
umask 0022
# link configuration files managed by puppet
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
# convert app/storage into symlink and set permissions
mv $target_dir/app/storage $SITE_ROOT/
chmod 02770 $SITE_ROOT/storage
find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
# populate application database
cd $target_dir
php artisan migrate --env=$LARAVEL_ENV
php artisan db:seed --env=$LARAVEL_ENV
# activate site
rm -rf $SITE_ROOT/w
ln -s $SITE_ROOT/slot0 $SITE_ROOT/w
} }
function fetch_catalog() { function site_status {
curl --silent $SOURCE_ROOT > $SITE_ROOT/releases.lst if [ ! $1 ]; then
grep -q "^<!DOCTYPE HTML PUBLIC" $SITE_ROOT/releases.lst echo "ERROR: site parameter mandatory"
} exit 1
fi
function catalog_get_version() { CONF_PATH="$CONF_DIR/conf.d/$1.conf"
RAW_LINE=`cat $SITE_ROOT/releases.lst | grep "$RELEASE_NAME" | sed "s/<[^>]\+>//g" | sed -r "s/^$RELEASE_NAME//"` if [ ! -f $CONF_PATH ]; then
RELEASE_DATE=`echo $RAW_LINE | awk '{ print $1 " " $2}'` echo "Site configuration not found: $1"
echo $RELEASE_DATE exit 0
} fi
source $CONF_PATH
function site_update() { if [ ! -f "$SITE_ROOT/w/public/index.php" ]; then
if [ ! $1 ]; then if [ -d "$SITE_ROOT/slot0" ]; then
echo "ERROR: missing site parameter" echo "PENDING"
exit 1 else
fi echo "N/A"
CONF_PATH="$CONF_DIR/conf.d/$1.conf" exit 1
if [ ! -f $CONF_PATH ]; then fi
echo "Site configuration not found: $1" else
exit 0 fetch_catalog
fi REMOTE_VERSION=`catalog_get_version`
source $CONF_PATH RELEASE_VERSION=$(head -n 1 $SITE_ROOT/w/release)
SITE_LINK=`readlink -f $SITE_ROOT/w` if [ "$REMOTE_VERSION" == "$RELEASE_VERSION" ]; then
ACTIVE_SLOT=`basename $SITE_LINK` echo "INSTALLED [$RELEASE_VERSION]"
case $ACTIVE_SLOT in else
slot0) echo "UPDATE AVAILABLE [$RELEASE_VERSION-$REMOTE_VERSION]"
TARGET_SLOT='slot1' fi
;;
slot1)
TARGET_SLOT='slot0'
;;
*)
echo "Invalid active slot"
exit 1
esac
echo "Target slot: $TARGET_SLOT"
target_dir="$SITE_ROOT/$TARGET_SLOT"
rm -rf $target_dir
mkdir $target_dir
# fetch catalog and write actual version
fetch_catalog
RELEASE_VERSION=`catalog_get_version`
echo $RELEASE_VERSION > $target_dir/release
# fetch and extract release tarball
umask 0027
if [[ $SOURCE_TARBALL == http* ]]; then
echo "Download from http!"
curl $SOURCE_TARBALL | tar -xzv -C $target_dir --strip-components 1 --no-same-permissions
else
echo "extract from local file system"
if [ ! -f $SOURCE_TARBALL ]; then
echo "Source tarball not found: $SOURCE_TARBALL"
exit 1
fi fi
tar -xzvf $SOURCE_TARBALL -C $target_dir --strip-components 1 --no-same-permissions }
fi
chown -R $FILE_OWNER:$FILE_GROUP $target_dir function fetch_catalog {
umask 0022 curl --silent $SOURCE_ROOT > $SITE_ROOT/releases.lst
# link configuration files managed by puppet grep -q "^<!DOCTYPE HTML PUBLIC" $SITE_ROOT/releases.lst
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php }
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php function catalog_get_version {
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php RAW_LINE=`cat $SITE_ROOT/releases.lst | grep "$RELEASE_NAME" | sed "s/<[^>]\+>//g" | sed -r "s/^$RELEASE_NAME//"`
# link shared app/storage directory RELEASE_DATE=`echo $RAW_LINE | awk '{ print $1 " " $2}'`
rm -rf $target_dir/app/storage echo $RELEASE_DATE
ln -s $SITE_ROOT/storage $target_dir/app }
# populate application database
cd $target_dir function site_update {
php artisan migrate --env=$LARAVEL_ENV if [ ! $1 ]; then
# activate site echo "ERROR: missing site parameter"
rm -rf $SITE_ROOT/w exit 1
ln -s $target_dir $SITE_ROOT/w fi
CONF_PATH="$CONF_DIR/conf.d/$1.conf"
if [ ! -f $CONF_PATH ]; then
echo "Site configuration not found: $1"
exit 0
fi
source $CONF_PATH
SITE_LINK=`readlink -f $SITE_ROOT/w`
ACTIVE_SLOT=`basename $SITE_LINK`
case $ACTIVE_SLOT in
slot0)
TARGET_SLOT='slot1'
;;
slot1)
TARGET_SLOT='slot0'
;;
*)
echo "Invalid active slot"
exit 1
esac
echo "Target slot: $TARGET_SLOT"
target_dir="$SITE_ROOT/$TARGET_SLOT"
rm -rf $target_dir
mkdir $target_dir
# fetch catalog and write actual version
fetch_catalog
RELEASE_VERSION=`catalog_get_version`
echo $RELEASE_VERSION > $target_dir/release
# fetch and extract release tarball
umask 0027
if [[ $SOURCE_TARBALL == http* ]]; then
echo "Download from http!"
curl $SOURCE_TARBALL | tar -xzv -C $target_dir --strip-components 1 --no-same-permissions
else
echo "extract from local file system"
if [ ! -f $SOURCE_TARBALL ]; then
echo "Source tarball not found: $SOURCE_TARBALL"
exit 1
fi
tar -xzvf $SOURCE_TARBALL -C $target_dir --strip-components 1 --no-same-permissions
fi
chown -R $FILE_OWNER:$FILE_GROUP $target_dir
umask 0022
# link configuration files managed by puppet
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
# link shared app/storage directory
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
# populate application database
cd $target_dir
php artisan migrate --env=$LARAVEL_ENV
# activate site
rm -rf $SITE_ROOT/w
ln -s $target_dir $SITE_ROOT/w
} }

View File

@ -41,10 +41,10 @@ if grep '^TMPTIME=' /etc/default/rcS >/dev/null 2>&1; then
# Don't clean files if TMPTIME is negative or 'infinite' # Don't clean files if TMPTIME is negative or 'infinite'
# to mimic the way /lib/init/bootclean.sh works. # to mimic the way /lib/init/bootclean.sh works.
case "$TMPTIME" in case "$TMPTIME" in
-*|infinite|infinity) -*|infinite|infinity)
# don't use this as default # don't use this as default
;; ;;
*) *)
if [ "$TMPTIME" -gt 0 ]; then if [ "$TMPTIME" -gt 0 ]; then
TMPREAPER_TIME=${TMPTIME}d TMPREAPER_TIME=${TMPTIME}d
else else
@ -96,14 +96,14 @@ TMPREAPER_PROTECT_EXTRA=${TMPREAPER_PROTECT_EXTRA:-''}
TMPREAPER_DIRS=${TMPREAPER_DIRS:-'/tmp/.'} TMPREAPER_DIRS=${TMPREAPER_DIRS:-'/tmp/.'}
nice -n10 tmpreaper --delay=$TMPREAPER_DELAY --mtime-dir --symlinks $TMPREAPER_TIME \ nice -n10 tmpreaper --delay=$TMPREAPER_DELAY --mtime-dir --symlinks $TMPREAPER_TIME \
$TMPREAPER_ADDITIONALOPTIONS \ $TMPREAPER_ADDITIONALOPTIONS \
--ctime \ --ctime \
--protect '/tmp/.X*-{lock,unix,unix/*}' \ --protect '/tmp/.X*-{lock,unix,unix/*}' \
--protect '/tmp/.ICE-{unix,unix/*}' \ --protect '/tmp/.ICE-{unix,unix/*}' \
--protect '/tmp/.iroha_{unix,unix/*}' \ --protect '/tmp/.iroha_{unix,unix/*}' \
--protect '/tmp/.ki2-{unix,unix/*}' \ --protect '/tmp/.ki2-{unix,unix/*}' \
--protect '/tmp/lost+found' \ --protect '/tmp/lost+found' \
--protect '/tmp/journal.dat' \ --protect '/tmp/journal.dat' \
--protect '/tmp/quota.{user,group}' \ --protect '/tmp/quota.{user,group}' \
`for i in $TMPREAPER_PROTECT_EXTRA; do echo --protect "$i"; done` \ `for i in $TMPREAPER_PROTECT_EXTRA; do echo --protect "$i"; done` \
$TMPREAPER_DIRS $TMPREAPER_DIRS

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
if ! test -z $1 ; then if ! test -z $1 ; then
BASE_DIR=$1 BASE_DIR=$1
else else
BASE_DIR=`pwd` BASE_DIR=`pwd`
fi fi
MODULE_DIR=${BASE_DIR}/modules MODULE_DIR=${BASE_DIR}/modules
@ -12,5 +12,5 @@ MANIFEST_LOG=/var/log/manifest.log
cd $BASE_DIR cd $BASE_DIR
/usr/bin/git pull -q && \ /usr/bin/git pull -q && \
/bin/bash install_modules.sh && \ /bin/bash install_modules.sh && \
/usr/bin/puppet apply -l $MANIFEST_LOG --modulepath=$MODULE_PATH manifests/site.pp /usr/bin/puppet apply -l $MANIFEST_LOG --modulepath=$MODULE_PATH manifests/site.pp

View File

@ -44,7 +44,7 @@ mv applytest/*00 applytest/head # These are the top-level variables defined in
if [[ `lsb_release -i -s` == 'CentOS' ]]; then if [[ `lsb_release -i -s` == 'CentOS' ]]; then
if [[ `lsb_release -r -s` =~ '6' ]]; then if [[ `lsb_release -r -s` =~ '6' ]]; then
CODENAME='centos6' CODENAME='centos6'
fi fi
elif [[ `lsb_release -i -s` == 'Ubuntu' ]]; then elif [[ `lsb_release -i -s` == 'Ubuntu' ]]; then
CODENAME=`lsb_release -c -s` CODENAME=`lsb_release -c -s`
@ -53,8 +53,8 @@ fi
FOUND=0 FOUND=0
for f in `find applytest -name 'puppetapplytest*' -print` ; do for f in `find applytest -name 'puppetapplytest*' -print` ; do
if grep -q "Node-OS: $CODENAME" $f; then if grep -q "Node-OS: $CODENAME" $f; then
cat applytest/head $f > $f.final cat applytest/head $f > $f.final
FOUND=1 FOUND=1
fi fi
done done

4
tools/run-bashate.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
ROOT=$(readlink -fn $(dirname $0)/.. )
find $ROOT -not -wholename \*.tox/\* -and \( -name \*.sh -or -name \*rc -or -name functions\* \) -print0 | xargs -0 bashate -v

View File

@ -24,4 +24,4 @@ ignore = E125,H
select = H231 select = H231
[testenv:bashate] [testenv:bashate]
commands = bashate -v commands = {toxinidir}/tools/run-bashate.sh