diff --git a/install_modules.sh b/install_modules.sh index 44df5547a8..bb30e81481 100755 --- a/install_modules.sh +++ b/install_modules.sh @@ -3,12 +3,12 @@ MODULE_PATH=/etc/puppet/modules function remove_module { - local SHORT_MODULE_NAME=$1 - if [ -n "$SHORT_MODULE_NAME" ]; then - rm -Rf "$MODULE_PATH/$SHORT_MODULE_NAME" - else - echo "ERROR: remove_module requires a SHORT_MODULE_NAME." - fi + local SHORT_MODULE_NAME=$1 + if [ -n "$SHORT_MODULE_NAME" ]; then + rm -Rf "$MODULE_PATH/$SHORT_MODULE_NAME" + else + echo "ERROR: remove_module requires a SHORT_MODULE_NAME." + fi } # 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 # since puppetlabs-ntp and kickstandproject-ntp install to the same dir if grep kickstandproject-ntp /etc/puppet/modules/ntp/Modulefile &> /dev/null; then - remove_module "ntp" + remove_module "ntp" fi 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 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 MODULE_LIST=`puppet module list` # Transition away from old things -if [ -d /etc/puppet/modules/vcsrepo/.git ] -then - rm -rf /etc/puppet/modules/vcsrepo +if [ -d /etc/puppet/modules/vcsrepo/.git ]; then + rm -rf /etc/puppet/modules/vcsrepo fi # Install all the modules for MOD in ${!MODULES[*]} ; do - # 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 - then - # Attempt module upgrade. If that fails try installing the module. - if ! puppet module upgrade $MOD --version ${MODULES[$MOD]} >/dev/null 2>&1 - then - # This will get run in cron, so silence non-error output - puppet module install $MOD --version ${MODULES[$MOD]} >/dev/null + # 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 ; then + # Attempt module upgrade. If that fails try installing the module. + if ! puppet module upgrade $MOD --version ${MODULES[$MOD]} >/dev/null 2>&1 ; then + # This will get run in cron, so silence non-error output + puppet module install $MOD --version ${MODULES[$MOD]} >/dev/null + fi fi - fi done MODULE_LIST=`puppet module list` # Make a second pass, just installing modules from source for MOD in ${!SOURCE_MODULES[*]} ; do - # get the name of the module directory - if [ `echo $MOD | awk -F. '{print $NF}'` = 'git' ]; then - echo "Remote repos of the form repo.git are not supported: ${MOD}" - exit 1 - fi - MODULE_NAME=`echo $MOD | awk -F- '{print $NF}'` - # 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}" - # treat any occurrence of the module as a match - if ! echo $MODULE_LIST | grep "${MODULE_NAME}" >/dev/null 2>&1; then - # clone modules that are not installed - git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" - else - 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" - remove_module $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 - echo "Found remote in ${MODULE_PATH}/${MODULE_NAME} that does not match desired remote ${MOD}, deleting dir and re-cloning" - remove_module $MODULE_NAME - git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" + # get the name of the module directory + if [ `echo $MOD | awk -F. '{print $NF}'` = 'git' ]; then + echo "Remote repos of the form repo.git are not supported: ${MOD}" + exit 1 + fi + MODULE_NAME=`echo $MOD | awk -F- '{print $NF}'` + # 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}" + # treat any occurrence of the module as a match + if ! echo $MODULE_LIST | grep "${MODULE_NAME}" >/dev/null 2>&1; then + # clone modules that are not installed + git clone $MOD "${MODULE_PATH}/${MODULE_NAME}" + else + 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" + remove_module $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 + echo "Found remote in ${MODULE_PATH}/${MODULE_NAME} that does not match desired remote ${MOD}, deleting dir and re-cloning" + remove_module $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 - # 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 diff --git a/modules/openstack_project/files/cacti/create_graphs.sh b/modules/openstack_project/files/cacti/create_graphs.sh index 3ca64245fc..8b8b2c9a7c 100644 --- a/modules/openstack_project/files/cacti/create_graphs.sh +++ b/modules/openstack_project/files/cacti/create_graphs.sh @@ -5,72 +5,70 @@ cd /usr/share/cacti/cli HOST_NAME=$1 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" \ - --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` 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 \ - --host-id=$HOST_ID + --host-id=$HOST_ID php -q poller_reindex_hosts.php --id=$HOST_ID php -q add_graphs.php --list-graph-templates \ - --host-template-id=$HOST_TEMPLATE_ID | \ - while read line -do - if echo $line | grep "Known" >/dev/null || [ "$line" == "" ] - then - continue - fi - TEMPLATE_ID=`echo $line | cut -f 1 -d ' '` - php -q add_graphs.php --host-id=$HOST_ID --graph-type=cg \ - --graph-template-id=$TEMPLATE_ID -done + --host-template-id=$HOST_TEMPLATE_ID | \ + while read line ; do + if echo $line | grep "Known" >/dev/null || [ "$line" == "" ] ; then + continue + fi + TEMPLATE_ID=`echo $line | cut -f 1 -d ' '` + php -q add_graphs.php --host-id=$HOST_ID --graph-type=cg \ + --graph-template-id=$TEMPLATE_ID + done function add_ds_graph { - TEMPLATE_NAME=$1 - TYPE_NAME=$2 - FIELD_NAME=$3 - FIELD_VALUE=$4 + TEMPLATE_NAME=$1 + TYPE_NAME=$2 + FIELD_NAME=$3 + FIELD_VALUE=$4 - TEMPLATE_ID=`php -q add_graphs.php --list-graph-templates | \ - grep "$TEMPLATE_NAME"|cut -f 1` - TYPE_ID=`php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID \ - --list-query-types | grep "$TYPE_NAME"|cut -f 1` + TEMPLATE_ID=`php -q add_graphs.php --list-graph-templates | \ + grep "$TEMPLATE_NAME"|cut -f 1` + TYPE_ID=`php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID \ + --list-query-types | grep "$TYPE_NAME"|cut -f 1` - php -q add_graphs.php --host-id=$HOST_ID --graph-type=ds \ - --graph-template-id=$TEMPLATE_ID --snmp-query-id=$SNMP_QUERY_ID \ - --snmp-query-type-id=$TYPE_ID --snmp-field=$FIELD_NAME \ - --snmp-value=$FIELD_VALUE + php -q add_graphs.php --host-id=$HOST_ID --graph-type=ds \ + --graph-template-id=$TEMPLATE_ID --snmp-query-id=$SNMP_QUERY_ID \ + --snmp-query-type-id=$TYPE_ID --snmp-field=$FIELD_NAME \ + --snmp-value=$FIELD_VALUE } # php -q add_graphs.php --list-graph-templates # 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 | \ - 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" \ - "hrStorageDescr" "/" + "hrStorageDescr" "/" 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)" \ - "ifOperStatus" "Up" + "ifOperStatus" "Up" 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" \ - "ifOperStatus" "Up" + "ifOperStatus" "Up" 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 | \ - 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 add_ds_graph "ucd/net - Device IO - Operations" "IO Operations" \ diff --git a/modules/openstackid/files/deploy.sh b/modules/openstackid/files/deploy.sh index 890a86889d..3b73d022b2 100644 --- a/modules/openstackid/files/deploy.sh +++ b/modules/openstackid/files/deploy.sh @@ -23,17 +23,17 @@ source $TOP_DIR/deployrc command="${1}" case $command in - init) - site_init ${2} - ;; - status) - site_status ${2} - ;; - update) - site_update ${2} - ;; - *) - print_help - exit 1 - ;; -esac \ No newline at end of file + init) + site_init ${2} + ;; + status) + site_status ${2} + ;; + update) + site_update ${2} + ;; + *) + print_help + exit 1 + ;; +esac diff --git a/modules/openstackid/files/deployrc b/modules/openstackid/files/deployrc index fc81527da1..1d20fc7599 100644 --- a/modules/openstackid/files/deployrc +++ b/modules/openstackid/files/deployrc @@ -5,4 +5,4 @@ FILE_GROUP=www-data # allow local overrides of env variables if [ -f $TOP_DIR/localrc ]; then . $TOP_DIR/localrc -fi \ No newline at end of file +fi diff --git a/modules/openstackid/files/functions b/modules/openstackid/files/functions index a185d783ef..7b6de71d41 100644 --- a/modules/openstackid/files/functions +++ b/modules/openstackid/files/functions @@ -1,176 +1,176 @@ -function print_help() { - echo "Usage: `basename $0` command [options]" - echo "" - echo "Commands:" - echo " status [site] return status information about site configurations" - echo " init initialize site structure" - echo " update update to new version" - echo "" +function print_help { + echo "Usage: `basename $0` command [options]" + echo "" + echo "Commands:" + echo " status [site] return status information about site configurations" + echo " init initialize site structure" + echo " update update to new version" + echo "" } -function site_init() { - 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 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 +function site_init { + if [ ! $1 ]; then + echo "ERROR: site parameter mandatory" + 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 - # 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 + CONF_PATH="$CONF_DIR/conf.d/$1.conf" + if [ ! -f $CONF_PATH ]; then + echo "Site configuration not found: " $1 + exit 1 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 - REMOTE_VERSION=`catalog_get_version` - RELEASE_VERSION=$(head -n 1 $SITE_ROOT/w/release) - if [ "$REMOTE_VERSION" == "$RELEASE_VERSION" ]; then - echo "INSTALLED [$RELEASE_VERSION]" + 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 "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 + 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() { - curl --silent $SOURCE_ROOT > $SITE_ROOT/releases.lst - grep -q "^]\+>//g" | sed -r "s/^$RELEASE_NAME//"` - RELEASE_DATE=`echo $RAW_LINE | awk '{ print $1 " " $2}'` - echo $RELEASE_DATE -} - -function site_update() { - if [ ! $1 ]; then - echo "ERROR: missing site parameter" - 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 - 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 +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 + else + fetch_catalog + REMOTE_VERSION=`catalog_get_version` + RELEASE_VERSION=$(head -n 1 $SITE_ROOT/w/release) + if [ "$REMOTE_VERSION" == "$RELEASE_VERSION" ]; then + echo "INSTALLED [$RELEASE_VERSION]" + else + echo "UPDATE AVAILABLE [$RELEASE_VERSION-$REMOTE_VERSION]" + fi 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 +} + +function fetch_catalog { + curl --silent $SOURCE_ROOT > $SITE_ROOT/releases.lst + grep -q "^]\+>//g" | sed -r "s/^$RELEASE_NAME//"` + RELEASE_DATE=`echo $RAW_LINE | awk '{ print $1 " " $2}'` + echo $RELEASE_DATE +} + +function site_update { + if [ ! $1 ]; then + echo "ERROR: missing site parameter" + 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 + 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 } diff --git a/modules/tmpreaper/files/tmpreaper.sh b/modules/tmpreaper/files/tmpreaper.sh index 8790e30342..b66f84ca2d 100755 --- a/modules/tmpreaper/files/tmpreaper.sh +++ b/modules/tmpreaper/files/tmpreaper.sh @@ -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' # to mimic the way /lib/init/bootclean.sh works. case "$TMPTIME" in - -*|infinite|infinity) + -*|infinite|infinity) # don't use this as default ;; - *) + *) if [ "$TMPTIME" -gt 0 ]; then TMPREAPER_TIME=${TMPTIME}d else @@ -96,14 +96,14 @@ TMPREAPER_PROTECT_EXTRA=${TMPREAPER_PROTECT_EXTRA:-''} TMPREAPER_DIRS=${TMPREAPER_DIRS:-'/tmp/.'} nice -n10 tmpreaper --delay=$TMPREAPER_DELAY --mtime-dir --symlinks $TMPREAPER_TIME \ - $TMPREAPER_ADDITIONALOPTIONS \ - --ctime \ - --protect '/tmp/.X*-{lock,unix,unix/*}' \ - --protect '/tmp/.ICE-{unix,unix/*}' \ - --protect '/tmp/.iroha_{unix,unix/*}' \ - --protect '/tmp/.ki2-{unix,unix/*}' \ - --protect '/tmp/lost+found' \ - --protect '/tmp/journal.dat' \ - --protect '/tmp/quota.{user,group}' \ - `for i in $TMPREAPER_PROTECT_EXTRA; do echo --protect "$i"; done` \ - $TMPREAPER_DIRS + $TMPREAPER_ADDITIONALOPTIONS \ + --ctime \ + --protect '/tmp/.X*-{lock,unix,unix/*}' \ + --protect '/tmp/.ICE-{unix,unix/*}' \ + --protect '/tmp/.iroha_{unix,unix/*}' \ + --protect '/tmp/.ki2-{unix,unix/*}' \ + --protect '/tmp/lost+found' \ + --protect '/tmp/journal.dat' \ + --protect '/tmp/quota.{user,group}' \ + `for i in $TMPREAPER_PROTECT_EXTRA; do echo --protect "$i"; done` \ + $TMPREAPER_DIRS diff --git a/run_puppet.sh b/run_puppet.sh index 5274a1347c..34486ef26f 100755 --- a/run_puppet.sh +++ b/run_puppet.sh @@ -1,9 +1,9 @@ #!/bin/bash if ! test -z $1 ; then - BASE_DIR=$1 + BASE_DIR=$1 else - BASE_DIR=`pwd` + BASE_DIR=`pwd` fi MODULE_DIR=${BASE_DIR}/modules @@ -12,5 +12,5 @@ MANIFEST_LOG=/var/log/manifest.log cd $BASE_DIR /usr/bin/git pull -q && \ - /bin/bash install_modules.sh && \ - /usr/bin/puppet apply -l $MANIFEST_LOG --modulepath=$MODULE_PATH manifests/site.pp + /bin/bash install_modules.sh && \ + /usr/bin/puppet apply -l $MANIFEST_LOG --modulepath=$MODULE_PATH manifests/site.pp diff --git a/tools/apply-test.sh b/tools/apply-test.sh index 06d4f35ec1..499e495a0e 100755 --- a/tools/apply-test.sh +++ b/tools/apply-test.sh @@ -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 -r -s` =~ '6' ]]; then - CODENAME='centos6' + CODENAME='centos6' fi elif [[ `lsb_release -i -s` == 'Ubuntu' ]]; then CODENAME=`lsb_release -c -s` @@ -53,8 +53,8 @@ fi FOUND=0 for f in `find applytest -name 'puppetapplytest*' -print` ; do if grep -q "Node-OS: $CODENAME" $f; then - cat applytest/head $f > $f.final - FOUND=1 + cat applytest/head $f > $f.final + FOUND=1 fi done diff --git a/tools/run-bashate.sh b/tools/run-bashate.sh new file mode 100755 index 0000000000..3fdefe1b70 --- /dev/null +++ b/tools/run-bashate.sh @@ -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 diff --git a/tox.ini b/tox.ini index 7ec8d20810..97de852e14 100644 --- a/tox.ini +++ b/tox.ini @@ -50,4 +50,4 @@ commands = {toxinidir}/tools/run-layout.sh openstack-infra config [testenv:bashate] -commands = bashate -v +commands = {toxinidir}/tools/run-bashate.sh