indent using 4 spaces (3/3)

As advised in I072cf8bf6748d0c910fecffdf2282bcc4656d038, code should
use 4 spaces for indentation.
This commit enforces the use of 4 spaces indentation.
In order to simplify the review process, this patch only cover the
following elements:
 - os-apply-config
 - os-collect-config
 - os-refresh-config
 - os-svc-install
 - pacemaker
 - pypi-mirror
 - qpidd
 - rabbitmq-server
 - snmpd
 - stackuser
 - tripleo-cd

Change-Id: I3f365f6a1cd6fd9e56402ad3bd6572192b85d798
This commit is contained in:
Gonéri Le Bouder 2014-05-11 01:47:16 +02:00
parent 50da841161
commit 0a71316726
16 changed files with 271 additions and 271 deletions

View File

@ -9,16 +9,16 @@ source /opt/stack/venvs/os-apply-config/bin/activate
set -u
if [ -n "$manifest" ]; then
use-pip-manifest $manifest
use-pip-manifest $manifest
else
# bug #1201253 : virtualenv-1.10.1 embeds setuptools-0.9.8, which
# doesn't manage correctly HTTPS sockets when downloading pbr from
# https://pypi.python.org/simple/ if using http_proxy and https_proxy
# envvars
/opt/stack/venvs/os-apply-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-apply-config/bin/pip install -U 'pbr>=0.6,<1.0'
/opt/stack/venvs/os-apply-config/bin/pip install -U os-apply-config
# bug #1201253 : virtualenv-1.10.1 embeds setuptools-0.9.8, which
# doesn't manage correctly HTTPS sockets when downloading pbr from
# https://pypi.python.org/simple/ if using http_proxy and https_proxy
# envvars
/opt/stack/venvs/os-apply-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-apply-config/bin/pip install -U 'pbr>=0.6,<1.0'
/opt/stack/venvs/os-apply-config/bin/pip install -U os-apply-config
fi
# Write the manifest of what was installed

View File

@ -11,14 +11,14 @@ source /opt/stack/venvs/os-collect-config/bin/activate
set -u
if [ -n "$manifest" ]; then
use-pip-manifest $manifest
use-pip-manifest $manifest
else
# Need setuptools>=1.0 to manage connections when
# downloading from pypi using http_proxy and https_proxy
/opt/stack/venvs/os-collect-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-collect-config/bin/pip install -U 'pbr>=0.6,<1.0'
/opt/stack/venvs/os-collect-config/bin/pip install -U os-collect-config
# Need setuptools>=1.0 to manage connections when
# downloading from pypi using http_proxy and https_proxy
/opt/stack/venvs/os-collect-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-collect-config/bin/pip install -U 'pbr>=0.6,<1.0'
/opt/stack/venvs/os-collect-config/bin/pip install -U os-collect-config
fi
# Write the manifest of what was installed
@ -56,8 +56,8 @@ Restart=on-failure
WantedBy=multi-user.target
eof
# Enable the service
systemctl enable os-collect-config.service
# Enable the service
systemctl enable os-collect-config.service
else
echo Only systems with systemd or upstart are supported.

View File

@ -14,15 +14,15 @@ source /opt/stack/venvs/os-refresh-config/bin/activate
set -u
if [ -n "$manifest" ]; then
use-pip-manifest $manifest
use-pip-manifest $manifest
else
# Need setuptools>=1.0 to manage connections when
# downloading from pypi using http_proxy and https_proxy
/opt/stack/venvs/os-refresh-config/bin/pip install -U pip
/opt/stack/venvs/os-refresh-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-refresh-config/bin/pip install -U 'pbr>=0.5.21,<1.0'
/opt/stack/venvs/os-refresh-config/bin/pip install -U os-refresh-config
# Need setuptools>=1.0 to manage connections when
# downloading from pypi using http_proxy and https_proxy
/opt/stack/venvs/os-refresh-config/bin/pip install -U pip
/opt/stack/venvs/os-refresh-config/bin/pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
/opt/stack/venvs/os-refresh-config/bin/pip install -U 'pbr>=0.5.21,<1.0'
/opt/stack/venvs/os-refresh-config/bin/pip install -U os-refresh-config
fi
# Write the manifest of what was installed
@ -31,7 +31,7 @@ write-pip-manifest os-refresh-config
ln -s /opt/stack/venvs/os-refresh-config/bin/os-refresh-config /usr/local/bin/os-refresh-config
for d in pre-configure.d configure.d migration.d post-configure.d; do
install -m 0755 -o root -g root -d /opt/stack/os-config-refresh/$d
install -m 0755 -o root -g root -d /opt/stack/os-config-refresh/$d
done
set +u

View File

@ -1,18 +1,18 @@
#!/bin/bash
set -eu
function create_db {
local sql="
create database if not exists $1;
grant all on $1.* to '$2'@'localhost' identified by '$3';
grant all on $1.* to '$2'@'%' identified by '$3';
flush privileges;"
echo "$sql" | mysql
function create_db() {
local sql="
create database if not exists $1;
grant all on $1.* to '$2'@'localhost' identified by '$3';
grant all on $1.* to '$2'@'%' identified by '$3';
flush privileges;"
echo "$sql" | mysql
}
if [ $# -lt 3 ]; then
echo "Usage: os-db-create DB_NAME DB_USER DB_PASS"
exit 1
echo "Usage: os-db-create DB_NAME DB_USER DB_PASS"
exit 1
fi
create_db $*

View File

@ -4,25 +4,25 @@ set -eu
DEFAULT_POSTSTART="exec sleep 1"
usage() {
echo "Usage: os-svc-daemon [ -ph ] [ -s POSTSTART ] [ -e ENV ] -n SERVICENAME -u RUNAS [ -c RUNCMD -- [arg [arg...]]]"
echo ""
echo "SERVICENAME, RUNAS, RUNCMD, and POSTSTART can be set via the"
echo "environment as well. Command line arguments will override"
echo "environment variables."
echo ""
echo " -h Show help and exit"
echo " -p Print the job file instead of writing to disk"
echo " -d [NAME] Specify the name of the runtime directory, which will be"
echo " /var/run/[NAME]"
echo " -s POSTSTART post_start will be added to the upstart job. Ignored with systemd."
echo " default: $DEFAULT_POSTSTART"
echo " -e ENV Environment name=value entries to set in the service/job"
echo " -n SERVICENAME Name of job/service file."
echo " -i INSTALLDIR Optional: virtualenv installation directory. Defaults to: /opt/stack/venvs/<SERVICENAME>"
echo " -u RUNAS User to run main executable as."
echo " -c RUNCMD Command to execute. Must stay in foreground."
echo " arg... Arguments will be passed to COMMAND"
echo ""
echo "Usage: os-svc-daemon [ -ph ] [ -s POSTSTART ] [ -e ENV ] -n SERVICENAME -u RUNAS [ -c RUNCMD -- [arg [arg...]]]"
echo ""
echo "SERVICENAME, RUNAS, RUNCMD, and POSTSTART can be set via the"
echo "environment as well. Command line arguments will override"
echo "environment variables."
echo ""
echo " -h Show help and exit"
echo " -p Print the job file instead of writing to disk"
echo " -d [NAME] Specify the name of the runtime directory, which will be"
echo " /var/run/[NAME]"
echo " -s POSTSTART post_start will be added to the upstart job. Ignored with systemd."
echo " default: $DEFAULT_POSTSTART"
echo " -e ENV Environment name=value entries to set in the service/job"
echo " -n SERVICENAME Name of job/service file."
echo " -i INSTALLDIR Optional: virtualenv installation directory. Defaults to: /opt/stack/venvs/<SERVICENAME>"
echo " -u RUNAS User to run main executable as."
echo " -c RUNCMD Command to execute. Must stay in foreground."
echo " arg... Arguments will be passed to COMMAND"
echo ""
}
# Can be set in environment now
@ -90,23 +90,23 @@ if [ -z "$INSTALLDIR" ]; then
fi
function install_upstart {
local name=$1
local install_dir=$2
local user=$3
local dirname=${4:-$user}
local cmd=$5
shift; shift; shift; shift; shift
local args=$*
local name=$1
local install_dir=$2
local user=$3
local dirname=${4:-$user}
local cmd=$5
shift; shift; shift; shift; shift
local args=$*
local env_entries=''
if [ -n "$ENV" ]; then
local env_pad=" $ENV"
env_entries=${env_pad// /
local env_entries=''
if [ -n "$ENV" ]; then
local env_pad=" $ENV"
env_entries=${env_pad// /
env }
fi
local target_file="/etc/init/$name.conf"
fi
local target_file="/etc/init/$name.conf"
$OUTPUT $target_file <<EOF
$OUTPUT $target_file <<EOF
start on runlevel [2345]
stop on runlevel [016]
$env_entries
@ -120,8 +120,8 @@ pre-start script
end script
EOF
if [ -n "$cmd" ]; then
$APPEND $target_file <<EOF
if [ -n "$cmd" ]; then
$APPEND $target_file <<EOF
respawn
# the default post-start of 1 second sleep delays respawning enough to
@ -132,25 +132,25 @@ exec start-stop-daemon --start -c $user --exec $install_dir/bin/$cmd -- $args
post-start $POSTSTART
EOF
fi
fi
}
function install_systemd {
local name=$1
local install_dir=$2
local user=$3
local cmd=$4
shift; shift; shift; shift;
local args=$*
local name=$1
local install_dir=$2
local user=$3
local cmd=$4
shift; shift; shift; shift;
local args=$*
local env_entries=''
if [ -n "$ENV" ]; then
local env_pad=" $ENV"
env_entries=${env_pad// /
local env_entries=''
if [ -n "$ENV" ]; then
local env_pad=" $ENV"
env_entries=${env_pad// /
Environment=}
fi
fi
$OUTPUT /usr/lib/systemd/system/$name.service <<EOF
$OUTPUT /usr/lib/systemd/system/$name.service <<EOF
[Unit]
Description=$name Service
After=os-refresh-config.service
@ -169,11 +169,11 @@ EOF
}
function install_create_dir_systemd {
local name=$(map-services $1)
local user=$2
local dirname=${3:-$user}
local name=$(map-services $1)
local user=$2
local dirname=${3:-$user}
$OUTPUT /usr/lib/systemd/system/$name-create-dir.service <<EOF
$OUTPUT /usr/lib/systemd/system/$name-create-dir.service <<EOF
[Unit]
Description=Create /var/run/$dirname
@ -190,13 +190,13 @@ EOF
# TODO: SysV init fallback support
DIB_INIT_SYSTEM=$(dib-init-system)
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
install_upstart $SERVICENAME $INSTALLDIR $RUNAS "$CREATE_DIR_NAME" "$RUNCMD" $*
install_upstart $SERVICENAME $INSTALLDIR $RUNAS "$CREATE_DIR_NAME" "$RUNCMD" $*
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
if [ "$POSTSTART" != "$DEFAULT_POSTSTART" ] ; then
echo "WARNING: post start is ignored with systemd." >&2
fi
if [ -n "$RUNCMD" ]; then
install_systemd $SERVICENAME $INSTALLDIR $RUNAS $RUNCMD $*
fi
install_create_dir_systemd $SERVICENAME $RUNAS $CREATE_DIR_NAME
if [ "$POSTSTART" != "$DEFAULT_POSTSTART" ] ; then
echo "WARNING: post start is ignored with systemd." >&2
fi
if [ -n "$RUNCMD" ]; then
install_systemd $SERVICENAME $INSTALLDIR $RUNAS $RUNCMD $*
fi
install_create_dir_systemd $SERVICENAME $RUNAS $CREATE_DIR_NAME
fi

View File

@ -18,12 +18,12 @@
set -eu
usage() {
echo "Usage: os-svc-enable -n SERVICENAME"
echo ""
echo " -h Show help and exit"
echo " -n SERVICENAME Name of job/service file."
echo ""
exit $1
echo "Usage: os-svc-enable -n SERVICENAME"
echo ""
echo " -h Show help and exit"
echo " -n SERVICENAME Name of job/service file."
echo ""
exit $1
}
SERVICENAME=${SERVICENAME:-""}
@ -43,25 +43,25 @@ if [ -z "$SERVICENAME" ] ; then
usage 1
fi
function enable_upstart_service {
local name=$1
os-svc-enable-upstart $name enable
function enable_upstart_service() {
local name=$1
os-svc-enable-upstart $name enable
}
function enable_systemd_service {
local name=$1
local service_name=$(map-services $name)
systemctl enable $service_name.service
# Also enable the create-dir service if it exists
if [ -f /usr/lib/systemd/system/$service_name-create-dir.service ]; then
systemctl enable $service_name-create-dir.service
fi
function enable_systemd_service() {
local name=$1
local service_name=$(map-services $name)
systemctl enable $service_name.service
# Also enable the create-dir service if it exists
if [ -f /usr/lib/systemd/system/$service_name-create-dir.service ]; then
systemctl enable $service_name-create-dir.service
fi
}
# TODO: SysV init fallback support
DIB_INIT_SYSTEM=$(dib-init-system)
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
enable_upstart_service $SERVICENAME
enable_upstart_service $SERVICENAME
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
enable_systemd_service $SERVICENAME
enable_systemd_service $SERVICENAME
fi

View File

@ -20,7 +20,7 @@ set -eu
job_name=${1:-}
action=${2:-}
function usage {
function usage() {
echo "usage: $(basename $0) job_name [enable|disable|enabled|clear]"
}

View File

@ -2,110 +2,110 @@
set -eux
function python_install() {
local svc_root=$1
local install_dir=$2
local system_site_packages=${3:-"False"}
local name=$(basename $install_dir)
local svc_manifest=$(get-pip-manifest $name)
local svc_root=$1
local install_dir=$2
local system_site_packages=${3:-"False"}
local name=$(basename $install_dir)
local svc_manifest=$(get-pip-manifest $name)
SITE_PCKGS="--no-site-packages"
if [ $system_site_packages == "True" ]; then
SITE_PCKGS="--no-site-packages"
if [ $system_site_packages == "True" ]; then
SITE_PCKGS="--system-site-packages"
fi
mkdir -p $(dirname $install_dir)
virtualenv $SITE_PCKGS $install_dir
fi
mkdir -p $(dirname $install_dir)
virtualenv $SITE_PCKGS $install_dir
set +u
source $install_dir/bin/activate
set -u
set +u
source $install_dir/bin/activate
set -u
# If given an exact deps list, use it, and upgrade to the local git service
if [ -n "$svc_manifest" ]; then
use-pip-manifest $svc_manifest
else
if [ -e $svc_root/requirements.txt ]; then
reqs=$svc_root/requirements.txt
elif [ -e $svc_root/tools/pip-requires ]; then
reqs=$svc_root/tools/pip-requires
# If given an exact deps list, use it, and upgrade to the local git service
if [ -n "$svc_manifest" ]; then
use-pip-manifest $svc_manifest
else
reqs=""
if [ -e $svc_root/requirements.txt ]; then
reqs=$svc_root/requirements.txt
elif [ -e $svc_root/tools/pip-requires ]; then
reqs=$svc_root/tools/pip-requires
else
reqs=""
fi
# bug #1201253 : virtualenv-1.10.1 embeds setuptools-0.9.8, which
# doesn't manage correctly HTTPS sockets when downloading pbr from
# https://pypi.python.org/simple/ if using http_proxy and
# https_proxy envvars
pip install -U 'setuptools>=1.0'
# bug #1293812 : Avoid easy_install triggering on pbr.
pip install -U 'pbr>=0.5.21,<1.0'
if [ -n "$reqs" ] ; then
pip install -r $reqs
# FIXME: pip requires doesn't include MySQL-python
pip install MySQL-python
fi
fi
# Always replay this, as we cannot use the entry this would generate in the manifest
pip install $svc_root
# bug #1201253 : virtualenv-1.10.1 embeds setuptools-0.9.8, which
# doesn't manage correctly HTTPS sockets when downloading pbr from
# https://pypi.python.org/simple/ if using http_proxy and
# https_proxy envvars
pip install -U 'setuptools>=1.0'
# Write the manifest of what was installed
write-pip-manifest $name
# bug #1293812 : Avoid easy_install triggering on pbr.
pip install -U 'pbr>=0.5.21,<1.0'
if [ -n "$reqs" ] ; then
pip install -r $reqs
# FIXME: pip requires doesn't include MySQL-python
pip install MySQL-python
fi
fi
# Always replay this, as we cannot use the entry this would generate in the manifest
pip install $svc_root
# Write the manifest of what was installed
write-pip-manifest $name
set +u
deactivate
set -u
set +u
deactivate
set -u
}
function install_os_service() {
local user=$1
local repo=$(echo $2 | sed 's/github.com/review.openstack.org/')
local branch=$3
local directory=$4
local system_site_packages=$5
local user=$1
local repo=$(echo $2 | sed 's/github.com/review.openstack.org/')
local branch=$3
local directory=$4
local system_site_packages=$5
id $user || useradd $user --system -d /var/run/$user -s /bin/false
id $user || useradd $user --system -d /var/run/$user -s /bin/false
install -d -m 0750 -o $user -g $user /etc/$user
install -d -m 0750 -o $user -g $user /etc/$user
local svc_root=/opt/stack/$user
local git_dir="--git-dir $svc_root/.git"
local svc_root=/opt/stack/$user
local git_dir="--git-dir $svc_root/.git"
# if the repository is an absolute local path then
# we assume its present, on the correct branch and use it
# this would be the case when the source was retrieved by
# the source-repositories element
if [ "${repo:0:1}" = "/" ] ; then
python_install $repo $directory $system_site_packages
elif [ ! -e $svc_root ]; then
git clone --depth=1 -b $branch $repo $svc_root
python_install $svc_root $directory $system_site_packages
else
if ! git $git_dir remote -v | grep $repo; then
echo "ERROR: $svc_root exists and did not come from $repo"
exit 1
# if the repository is an absolute local path then
# we assume its present, on the correct branch and use it
# this would be the case when the source was retrieved by
# the source-repositories element
if [ "${repo:0:1}" = "/" ] ; then
python_install $repo $directory $system_site_packages
elif [ ! -e $svc_root ]; then
git clone --depth=1 -b $branch $repo $svc_root
python_install $svc_root $directory $system_site_packages
else
if ! git $git_dir remote -v | grep $repo; then
echo "ERROR: $svc_root exists and did not come from $repo"
exit 1
fi
actual_rev=$(git $git_dir show | head -1 | awk '{print $2}')
git $git_dir checkout $branch
expected_rev=$(git $git_dir show | head -1 | awk '{print $2}')
if [ "$expected_rev" != "$actual_rev" ]; then
echo "ERROR: $repo exists and is not on rev $branch"
exit 1
fi
fi
actual_rev=$(git $git_dir show | head -1 | awk '{print $2}')
git $git_dir checkout $branch
expected_rev=$(git $git_dir show | head -1 | awk '{print $2}')
if [ "$expected_rev" != "$actual_rev" ]; then
echo "ERROR: $repo exists and is not on rev $branch"
exit 1
fi
fi
}
function usage() {
echo "options:"
echo " -h show usage and exit"
echo " -r service's git repo url"
echo " -b repo branch or ref (default 'master')"
echo " -i Optional: installation directory for the virtualenv."
echo " If not specified defaults to /opt/stack/venv/<service_name>."
echo " -u name of the service run-as user"
echo " -s enable --system-site-packages in the virtualenv."
echo "options:"
echo " -h show usage and exit"
echo " -r service's git repo url"
echo " -b repo branch or ref (default 'master')"
echo " -i Optional: installation directory for the virtualenv."
echo " If not specified defaults to /opt/stack/venv/<service_name>."
echo " -u name of the service run-as user"
echo " -s enable --system-site-packages in the virtualenv."
}
user=
@ -113,7 +113,7 @@ repo=
install_dir=
system_site_packages="False"
while getopts hsr:u:b:i: opt; do
case "$opt" in
case "$opt" in
u) user=$OPTARG;;
i) install_dir=$OPTARG;;
h) usage; exit 0;;
@ -122,14 +122,14 @@ while getopts hsr:u:b:i: opt; do
s) system_site_packages="True";;
\?) usage; exit 1;;
:) usage; exit 1;;
esac
esac
done
branch=${branch:-master}
if [[ -z "$user" || -z "$repo" ]]; then
echo "missing required parameter"
exit 1
echo "missing required parameter"
exit 1
fi
if [[ -z "$install_dir" ]]; then

View File

@ -18,12 +18,12 @@
set -eu
usage() {
echo "Usage: os-svc-restart -n SERVICENAME"
echo ""
echo " -h Show help and exit"
echo " -n SERVICENAME Name of job/service file."
echo ""
exit $1
echo "Usage: os-svc-restart -n SERVICENAME"
echo ""
echo " -h Show help and exit"
echo " -n SERVICENAME Name of job/service file."
echo ""
exit $1
}
SERVICENAME=${SERVICENAME:-""}
@ -44,19 +44,19 @@ if [ -z "$SERVICENAME" ] ; then
fi
function restart_upstart_service {
local name=$1
service $name restart
local name=$1
service $name restart
}
function restart_systemd_service {
local name=$1
systemctl restart $(map-services $name).service
local name=$1
systemctl restart $(map-services $name).service
}
# TODO: SysV init fallback support
DIB_INIT_SYSTEM=$(dib-init-system)
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
restart_upstart_service $SERVICENAME
restart_upstart_service $SERVICENAME
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
restart_systemd_service $SERVICENAME
restart_systemd_service $SERVICENAME
fi

View File

@ -7,5 +7,5 @@ RECHECK_INTERVAL=$(os-apply-config --key pacemaker.recheck_interval --type raw -
STONITH_ENABLED=$(os-apply-config --key pacemaker.stonith_enabled --type raw --key-default false)
crm configure property no-quorum-policy=$QUORUM_POLICY \
cluster-recheck-interval=$RECHECK_INTERVAL"min" \
stonith-enabled=$STONITH_ENABLED
cluster-recheck-interval=$RECHECK_INTERVAL"min" \
stonith-enabled=$STONITH_ENABLED

View File

@ -16,7 +16,7 @@
set -eux
install-packages libyaml-dev pkg-config python-dev build-essential libmysqlclient-dev \
libffi-dev libpq-dev libxslt-dev libsqlite3-dev libldap2-dev libsasl2-dev
libffi-dev libpq-dev libxslt-dev libsqlite3-dev libldap2-dev libsasl2-dev
mkdir -p /opt/stack/venvs
virtualenv /opt/stack/venvs/pypi-mirror

View File

@ -2,8 +2,8 @@
install-packages qpidd qpid-tools qpid-client
function install_qpidd_upstart {
cat > /etc/init/qpidd.conf << eof
function install_qpidd_upstart() {
cat > /etc/init/qpidd.conf << eof
start on runlevel [2345]
stop on runlevel [016]

View File

@ -32,17 +32,17 @@ os-svc-restart -n rabbitmq-server
# [2] cluster is any cluster with at least 2 running nodes
function is_in_cluster() {
local node=$1
# Returns true if the list following "running_nodes" in rabbitmqctl
# cluster_status contains at least two nodes.
rabbitmqctl -n rabbit@$node cluster_status|grep -q "running_nodes,\[[^]]\+,"
local node=$1
# Returns true if the list following "running_nodes" in rabbitmqctl
# cluster_status contains at least two nodes.
rabbitmqctl -n rabbit@$node cluster_status|grep -q "running_nodes,\[[^]]\+,"
}
function join_with() {
local node=$1
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@$node || return 1
rabbitmqctl start_app
local node=$1
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@$node || return 1
rabbitmqctl start_app
}
LOCAL=$(hostname -s)
@ -57,46 +57,46 @@ NODES=${NODES,,}
MASTER=${MASTER,,}
if [ -n "$NODES" ];then
if [ "$MASTER" = "$LOCAL" ];then
# if this is master node which is already clustered, do nothing
if [ "$MASTER" = "$LOCAL" ];then
# if this is master node which is already clustered, do nothing
if is_in_cluster $LOCAL;then
exit 0
exit 0
fi
else
# if this node is already in cluster with current master node, do nothing
if rabbitmqctl cluster_status|grep -q "$MASTER";then
exit 0
fi
fi
JOINED_WITH=''
# find another node which is already clustered and try join with it
for NODE in $NODES;do
if [ ! "$NODE" = "$LOCAL" ] && is_in_cluster $NODE;then
if join_with $NODE; then
JOINED_WITH=$NODE
break
fi
fi
done
if [ -z "$JOINED_WITH"];then
# if there is no existing cluster yet and this is master node, start this
# node standalone (other nodes will join to this one)
if [ "$MASTER" == "$LOCAL" ];then
rabbitmqctl start_app
else
if ! join_with $MASTER; then
echo "failed to join this node into cluster"
exit 1
fi
# if this node is already in cluster with current master node, do nothing
if rabbitmqctl cluster_status|grep -q "$MASTER";then
exit 0
fi
fi
fi
# wait until rabbitmq node is up
timeout 3 rabbitmqctl wait /var/run/rabbitmq/pid
JOINED_WITH=''
# find another node which is already clustered and try join with it
for NODE in $NODES;do
if [ ! "$NODE" = "$LOCAL" ] && is_in_cluster $NODE;then
if join_with $NODE; then
JOINED_WITH=$NODE
break
fi
fi
done
# make sure that all queues (except those with auto-generated names) are
# mirrored across all nodes in running:
rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'
if [ -z "$JOINED_WITH"];then
# if there is no existing cluster yet and this is master node, start this
# node standalone (other nodes will join to this one)
if [ "$MASTER" == "$LOCAL" ];then
rabbitmqctl start_app
else
if ! join_with $MASTER; then
echo "failed to join this node into cluster"
exit 1
fi
fi
fi
# wait until rabbitmq node is up
timeout 3 rabbitmqctl wait /var/run/rabbitmq/pid
# make sure that all queues (except those with auto-generated names) are
# mirrored across all nodes in running:
rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'
fi

View File

@ -5,7 +5,7 @@ install-packages snmpd snmp-mibs-downloader lm-sensors nagios-plugins-basic
# install our snmp check script
DEST_DIR="/usr/lib64/nagios/plugins"
if [ ! 'amd64' = "$ARCH" ] || [ ! -d $DEST_DIR ]; then
DEST_DIR="/usr/lib/nagios/plugins"
DEST_DIR="/usr/lib/nagios/plugins"
fi
install -m 0755 -o root -g root $(dirname $0)/../files/check_proc_open_files.py $DEST_DIR/check_proc_open_files.py
install -m 0440 -o root -g root $(dirname $0)/../files/snmp /etc/sudoers.d/snmp

View File

@ -22,7 +22,7 @@ chmod 0440 /etc/sudoers.d/stack
visudo -c
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /home/stack/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /home/stack/.ssh/authorized_keys
chown -R stack:stack /home/stack/.ssh
mkdir -p /home/stack/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /home/stack/.ssh/authorized_keys
chown -R stack:stack /home/stack/.ssh
fi

View File

@ -24,8 +24,8 @@ Restart=on-failure
WantedBy=multi-user.target
eof
# Enable the service
systemctl enable tripleo-cd.service
# Enable the service
systemctl enable tripleo-cd.service
else
echo Only systems with systemd or upstart are supported.
@ -36,5 +36,5 @@ mkdir -p ~root/.cache/image-create
ln -s /var/cache/pypi-mirror/pypi ~root/.cache/image-create
for f in `ls $(dirname $0)/../bin`; do
install -m 0755 -o root -g root $(dirname $0)/../bin/$f /usr/local/bin/$f
install -m 0755 -o root -g root $(dirname $0)/../bin/$f /usr/local/bin/$f
done