Merge "Shell files syntax cleanup"

This commit is contained in:
Jenkins 2016-08-09 08:59:48 +00:00 committed by Gerrit Code Review
commit f289b8988c
57 changed files with 201 additions and 188 deletions

View File

@ -25,10 +25,10 @@ EOF
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "${1}" | grep -q -e '[^0-9.]' ; then
echo AAAA "${1}"
else
echo A $1
echo A "${1}"
fi
}
@ -47,4 +47,4 @@ EOF
}
# Log all output to file.
deploy 2>&1 | tee -a /var/log/bind-install.log
deploy 2>&1 | tee -a /var/log/bind-install.log

View File

@ -15,5 +15,5 @@
# Sleep for some time added as a helper
TIME="$1"
sleep $TIME
sleep "${TIME}"
sudo service cassandra restart

View File

@ -23,10 +23,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install bono --yes --force-yes
DEBIAN_FRONTEND=noninteractive apt-get install clearwater-config-manager --yes --force-yes
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -54,10 +54,10 @@ service ellis stop
/usr/share/clearwater/ellis/env/bin/python /usr/share/clearwater/ellis/src/metaswitch/ellis/tools/create_numbers.py --start 6505550000 --count 1000 --realm %ZONE%
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -25,10 +25,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install homer --yes --force-yes
DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -23,10 +23,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install homestead homestead-prov clearwat
DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -38,10 +38,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install ralf --yes --force-yes
DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -40,10 +40,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install sprout --yes --force-yes
DEBIAN_FRONTEND=noninteractive apt-get install clearwater-management --yes --force-yes
# Function to give DNS record type and IP address for specified IP address
ip2rr() {
if echo $1 | grep -q -e '[^0-9.]' ; then
echo AAAA $1
if echo "$1" | grep -q -e '[^0-9.]' ; then
echo AAAA "$1"
else
echo A $1
echo A "$1"
fi
}
# Update DNS

View File

@ -14,10 +14,10 @@
exec &> /tmp/clone_repos.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -21,6 +21,7 @@ fi
function log {
if [ "$DEBUGLVL" -gt 0 ]; then
chars=$(echo "@$" | wc -c)
echo "Parsed chars: ${chars}"
case $DEBUGLVL in
1 )
echo -e "LOG:>$@"
@ -44,16 +45,16 @@ function find_pip()
{
for cmd in $PIPAPPS
do
_cmd=$(which $cmd 2>/dev/null)
_cmd=$(which "$cmd" 2>/dev/null)
if [ $? -eq 0 ];then
break
fi
done
if [ -z $_cmd ];then
if [[ -z $_cmd ]];then
echo "Can't find \"pip\" in system, please install it first, exiting!"
exit 1
else
PIPCMD=$_cmd
export PIPCMD=$_cmd
fi
}
OPTIND=1 # Reset if getopts used previously
@ -77,43 +78,44 @@ function collect_args(){
OPTIND=$((OPTIND + 1))
#sleep 1
done
echo $ARGS
echo "${ARGS}"
unset _n
unset ARGS
}
function get_os(){
KERNEL=$(uname -r)
MACH=$(uname -m)
OS=$(uname)
# (azvyagintsev) export variables just for clearing shellcheck warning's
export KERNEL=$(uname -r)
export MACH=$(uname -m)
export OS=$(uname)
if [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
Packager='yum'
DIST=$(cat /etc/redhat-release |sed s/\ release.*//)
PSUEDONAME=$(cat /etc/redhat-release | sed s/.*\(// | sed s/\)//)
REV=$(cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//)
export DistroBasedOn='RedHat'
export Packager='yum'
export DIST=$(< /etc/redhat-release sed s/\ release.*// )
export PSUEDONAME=$(< /etc/redhat-release sed -e s/.*\(// -e s/\)// )
export REV=$(< /etc/redhat-release sed -e s/.*release\ // -e s/\ .*//)
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
Packager='zypper'
PSUEDONAME=$(cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//)
REV=$(cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //)
export DistroBasedOn='SuSe'
export Packager='zypper'
export PSUEDONAME=$(< /etc/SuSE-release tr "\n" ' '| sed s/VERSION.*//)
export REV=$(< /etc/SuSE-release tr "\n" ' ' | sed s/.*=\ //)
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
Packager='urpmi urpme'
PSUEDONAME=$(cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//)
REV=$(cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//)
export DistroBasedOn='Mandrake'
export Packager='urpmi urpme'
export PSUEDONAME=$(< /etc/mandrake-release sed s/.*\(// | sed s/\)//)
export REV=$(< /etc/mandrake-release sed s/.*release\ // | sed s/\ .*//)
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
Packager='apt-get'
DIST=$(cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }')
PSUEDONAME=$(cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }')
REV=$(cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }')
export DistroBasedOn='Debian'
export Packager='apt-get'
export DIST=$(< /etc/lsb-release grep '^DISTRIB_ID' | awk -F= '{ print $2 }')
export PSUEDONAME=$(< /etc/lsb-release grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }')
export REV=$(< /etc/lsb-release grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }')
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[$(cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//)]"
DIST="${DIST}[$(< /etc/UnitedLinux-release tr "\n" ' ' | sed s/VERSION.*//)]"
fi
OS=$(lowercase $OS)
DistroBasedOn=$(lowercase $DistroBasedOn)
OS=$(lowercase "$OS")
DistroBasedOn=$(lowercase "$DistroBasedOn")
readonly OS
readonly DIST
readonly DistroBasedOn
@ -130,32 +132,34 @@ function get_os(){
fi
}
function add_fw_rule(){
_rule_string=$@
_tmp_fw_port=$(echo $_rule_string | grep -o -e "dport [0-9]*\s")
_tmp_fw_proto=$(echo $_rule_string | grep -o -e "-p \w*\s")
_fw_port=$(echo $_tmp_fw_port | awk '{print $2}')
_fw_proto=$(echo $_tmp_fw_proto |awk '{print $2}')
_rule_string=$*
_tmp_fw_port=$(echo "$_rule_string" | grep -o -e "dport [0-9]*\s")
_tmp_fw_proto=$(echo "$_rule_string" | grep -o -e "-p \w*\s")
_fw_port=$(echo "$_tmp_fw_port" | awk '{print $2}')
_fw_proto=$(echo "$_tmp_fw_proto" |awk '{print $2}')
_fw_reload=""
# (azvyagintsev) Do echo just for remove shellcheck warning
echo "${_fw_reload}" >> /dev/null
#find iptables and add rule
case $DIST in
case "$DIST" in
"Fedora")
_fw_cmd=$(which firewall-cmd)
_fw_port=$(echo $_rule_string | grep -o -e "dport [0-9]*\s" | awk '{print $2}')
_fw_proto=$(echo $_rule_string | grep -o -e "-p \w*\s" | awk '{print $2}')
_fw_port=$(echo "$_rule_string" | grep -o -e "dport [0-9]*\s" | awk '{print $2}')
_fw_proto=$(echo "$_rule_string" | grep -o -e "-p \w*\s" | awk '{print $2}')
_fw_rule="--permanent --add-port=$_fw_port/$_fw_proto"
_fw_enable_rules="$_fw_cmd --reload"
;;
*)
_fw_cmd=$(which iptables)
_fw_rule=$_rule_string
_fw_enable_rules="service $(basename $_fw_cmd) save"
_fw_enable_rules="service $(basename "$_fw_cmd") save"
;;
esac
iptcmdsave=$(which iptables-save)
if [[ "$_fw_cmd" != '' ]] && [[ "$iptcmdsave" != '' ]]; then
eval "$iptcmdsave | grep -e \"$_tmp_fw_port\" | grep -e \"$_tmp_fw_proto\"" > /dev/null 2>&1
if [ $? -ne 0 ]; then
eval $_fw_cmd $_fw_rule
eval "$_fw_cmd $_fw_rule"
if [ $? -ne 0 ]; then
log "Can't set firewall rules, exiting..."
exit 1
@ -187,46 +191,49 @@ function enable_init(){
_init_suffix="on"
;;
esac
$_initctrl $_service $_init_suffix
eval "$_initctrl $_service $_init_suffix"
if [ $? -ne 0 ]; then
log "$_initctrl $_service $_init_suffix - fails!"
exit 1
fi
}
function restart_service(){
_service=$1
service $_service restart > /dev/null 2>&1
_service="$1"
service "$_service" restart > /dev/null 2>&1
if [ $? -ne 0 ]; then
log "Can't start $_service service!"
exit 1
fi
}
function package_renamer(){
_pkg=$1
case $DistroBasedOn in
_pkg="$1"
case "$DistroBasedOn" in
"debian")
_pkg=$(echo $_pkg | sed 's/-devel$/-dev/')
_pkg=$(echo "$_pkg" | sed 's/-devel$/-dev/')
;;
*)
_pkg=$(echo $_pkg | sed 's/-dev$/-devel/')
_pkg=$(echo "$_pkg" | sed 's/-dev$/-devel/')
;;
esac
echo $_pkg
echo "$_pkg"
}
function retry()
{
local n=0
local try=$1
local cmd="${@: 2}"
local cmd="${*:2}"
[[ $# -le 1 ]] && {
echo "Usage $0 <retry_number> <Command>"; }
until [[ $n -ge $try ]]
do
$cmd && break || {
if eval "$cmd"; then
echo "Command: ${cmd} done.."
break
else
echo "Command Fail.."
((n++))
echo "retry $n ::"
sleep 1;
}
fi
done
}

View File

@ -14,10 +14,10 @@
exec &> /tmp/install_cf_release.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -14,10 +14,10 @@
exec &> /tmp/install_cf_cli.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -14,10 +14,10 @@
exec &> /tmp/install_environemnt.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -14,10 +14,10 @@
exec &> /tmp/install_ruby.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -17,10 +17,10 @@ PMGR=""
PMGR_LIST_OPTS=""
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
exit 1
fi
@ -63,7 +63,7 @@ function set_install_options(){
exit 1
;;
esac
PACKAGER=$(which $1)
PACKAGER=$(which "$1")
if [ $? -ne 0 ]; then
log "Can't find \"$1\", exiting!"
exit 1
@ -76,7 +76,7 @@ function package_install(){
log "\"$PKG\" already installed"
else
log "Installing \"$PKG\" ..."
$PACKAGER $INSTALLER_OPTS $PKG > /dev/null 2>&1
eval "$PACKAGER $INSTALLER_OPTS $PKG" > /dev/null 2>&1
if [ $? -ne 0 ]; then
log "\"$PKG\" installation fails, exiting!"
exit 1
@ -92,7 +92,7 @@ function package_uninstall(){
log "\"$PKG\" not installed"
else
log "Uninstalling \"$PKG\" ..."
$PACKAGER $UNINSTALLER_OPTS $PKG > /dev/null 2>&1
eval "$PACKAGER $UNINSTALLER_OPTS $PKG" > /dev/null 2>&1
if [ $? -ne 0 ]; then
log "\"$PKG\" uninstallation fails, exiting!"
exit 1
@ -102,21 +102,21 @@ function package_uninstall(){
fi
}
function run_install(){
for PKG in $@
for PKG in "$@"
do
package_install $PKG
package_install "$PKG"
done
}
function run_uninstall(){
for PKG in $@
for PKG in "$@"
do
package_uninstall $PKG
package_uninstall "$PKG"
done
}
# Main workflow
include "common.sh"
if [ $# -eq 0 ]; then
script=$(basename $0)
script=$(basename "$0")
echo -e "Usage:\n\t* install packages -- ./$script -p package_manager -i package0 [packageN]\n\t* remove packages -- ./$script -p package_manager -r package0 [packageN]"
exit 1
fi
@ -132,16 +132,16 @@ while getopts ":p:i:r:" opt ; do
if [[ "$OPTARG" != sys ]]; then
Packager=$OPTARG
fi
set_install_options $Packager
set_install_options "$Packager"
;;
i)
n=$OPTARG
run_install $(collect_args $n $@)
run_install "$(collect_args "$n" "$@")"
break;
;;
r)
n=$OPTARG
run_uninstall $(collect_args $n $@)
run_uninstall "$(collect_args "$n" "$@")"
break;
;;
\?)
@ -150,4 +150,4 @@ while getopts ":p:i:r:" opt ; do
;;
esac
done
shift $((OPTIND-1))
shift $((OPTIND-1))

View File

@ -14,10 +14,10 @@
exec &> /tmp/start_cf.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "$inc_file_path"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -15,20 +15,21 @@ set +eu
function retry()
{
local n=0
local try=$1
local cmd="${@: 2}"
[[ $# -le 1 ]] && {
echo "Usage $0 <retry_number> <Command>"; }
until [[ $n -ge $try ]]
do
$cmd && break || {
echo "Command Fail.."
((n++))
echo "retry $n ::"
sleep 1;
}
done
local n=0
local try=$1
local cmd="${*:2}"
[[ $# -le 1 ]] && {
echo "Usage $0 <retry_number> <Command>"; }
until [[ $n -ge $try ]]
do
if eval "$cmd"; then
echo "Command: ${cmd} done.."
break
else
echo "Command Fail.."
((n++))
echo "retry $n ::"
sleep 1;
fi
done
}

View File

@ -16,10 +16,10 @@ set -eu
exec &> /tmp/deploy_cf_release.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "${inc_file_path}"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -16,10 +16,10 @@ set -eu
exec &> /tmp/deploy_diego_release.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "${0}")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "${inc_file_path}"
else
echo -e "$inc_file_path not found!"
exit 1

View File

@ -16,10 +16,10 @@ set -eu
exec &> /tmp/install_bosh.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "${0}")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "${inc_file_path}"
else
echo -e "$inc_file_path not found!"
exit 1
@ -50,7 +50,7 @@ auth:
username: admin
password: admin
BOSH_CONFIG
) > $HOME/.bosh_config
) > "${HOME}/.bosh_config"
bosh target 127.0.0.1

View File

@ -16,10 +16,10 @@ set -eu
exec &> /tmp/upload_releases.log
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
curr_dir=$(cd "$(dirname "$0")" && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
. "${inc_file_path}"
else
echo -e "$inc_file_path not found!"
exit 1
@ -28,10 +28,10 @@ function include(){
include "common.sh"
cd /tmp
IMAGE=$(bosh public stemcells | grep bosh-stemcell-.*-warden-boshlite-ubuntu-trusty-go_agent.tgz | head -n1 | awk '{print $2}')
bosh download public stemcell ${IMAGE}
bosh upload stemcell ${IMAGE}
rm -f ${IMAGE}
IMAGE=$(bosh public stemcells | grep "bosh-stemcell-.*-warden-boshlite-ubuntu-trusty-go_agent.tgz" | head -n1 | awk '{print $2}')
bosh download public stemcell "${IMAGE}"
bosh upload stemcell "${IMAGE}"
rm -f "${IMAGE}"
retry 3 bosh -n upload release /root/workspace/cf-release.tgz
retry 3 bosh -n upload release /root/workspace/diego-release.tgz

View File

@ -11,4 +11,4 @@
# License for the specific language governing permissions and limitations
# under the License.
docker $*
docker "$@"

View File

@ -13,4 +13,4 @@
source /etc/default/docker
DOCKER_OPTS+=" --registry-mirror=$1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker
echo "DOCKER_OPTS=${DOCKER_OPTS}" > /etc/default/docker

View File

@ -13,4 +13,4 @@
source /etc/default/docker
DOCKER_OPTS+=" --insecure-registry $1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker
echo "DOCKER_OPTS=${DOCKER_OPTS}" > /etc/default/docker

View File

@ -1,3 +1,3 @@
#!/bin/bash
echo "Deleting Pods" >> /tmp/murano-kube.log
/opt/bin/kubectl delete pod -l $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete pod -l "$1" >> /tmp/murano-kube.log

View File

@ -1,3 +1,3 @@
#!/bin/bash
echo "Deleting a replication controller" >> /tmp/murano-kube.log
/opt/bin/kubectl delete replicationcontrollers $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete replicationcontrollers "$1" >> /tmp/murano-kube.log

View File

@ -1,3 +1,3 @@
#!/bin/bash
echo "Deleting a Service" >> /tmp/murano-kube.log
/opt/bin/kubectl delete service $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete service "$1" >> /tmp/murano-kube.log

View File

@ -1,3 +1,3 @@
#!/bin/bash
/opt/bin/kubectl get service $1 --template '{{.spec.clusterIP}}' -o template
/opt/bin/kubectl get service "$1" --template '{{.spec.clusterIP}}' -o template

View File

@ -5,7 +5,7 @@
cp -f haproxy.toml /etc/confd/conf.d/
cp -f haproxy.tmpl /etc/confd/templates/
/usr/local/bin/confd -onetime -backend etcd -node $1:4001
/usr/local/bin/confd -onetime -backend etcd -node "$1:4001"
cp -f default_scripts/haproxy /etc/default/
@ -23,4 +23,4 @@ else
service haproxy start
fi
sleep 1
sleep 1

View File

@ -9,7 +9,7 @@ echo "Adding member $1 to etcd cluster" >> /tmp/etcd.log
while [ $count -gt 0 ]; do
/opt/bin/etcdctl cluster-health >> /tmp/etcd.log
if [ $? -eq 0 ]; then
out=$((/opt/bin/etcdctl member add "$1" "http://$2:7001") 2>&1)
out=$( (/opt/bin/etcdctl member add "$1" "http://$2:7001") 2>&1)
if [ $? -ne 0 ]; then
echo "Member $1 not added. Reason: $out" >> /tmp/etcd.log
break

View File

@ -3,4 +3,4 @@
# $1 - service name
# $2 - publicIPs JSON
/opt/bin/kubectl update service $1 --patch="$2"
/opt/bin/kubectl update service "$1" --patch="$2"

View File

@ -1,4 +1,4 @@
#!/bin/bash
NODE_ID=$(/opt/bin/etcdctl member list | grep $1 | cut -d':' -f1)
/opt/bin/etcdctl member remove $NODE_ID
NODE_ID=$(/opt/bin/etcdctl member list | grep "$1" | cut -d':' -f1)
/opt/bin/etcdctl member remove "${NODE_ID}"

View File

@ -1,3 +1,3 @@
#!/bin/bash
echo "Deleting Kubernetes Node" >> /tmp/murano-kube.log
/opt/bin/kubectl delete node $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete node "$1" >> /tmp/murano-kube.log

View File

@ -4,5 +4,5 @@
CONTAINERS=$(docker ps -q --filter "name=_$1-")
if (( ${#CONTAINERS} > 0 )); then
docker restart $CONTAINERS
fi
docker restart "${CONTAINERS}"
fi

View File

@ -3,4 +3,4 @@
# $1 - RC name
# $2 - new size
/opt/bin/kubectl scale rc $1 --replicas=$2
/opt/bin/kubectl scale rc "${1}" --replicas="${2}"

View File

@ -2,4 +2,4 @@
source /etc/default/docker
DOCKER_OPTS+=" --registry-mirror=$1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker
echo "DOCKER_OPTS=${DOCKER_OPTS}" > /etc/default/docker

View File

@ -2,4 +2,4 @@
source /etc/default/docker
DOCKER_OPTS+=" --insecure-registry $1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker
echo "DOCKER_OPTS=${DOCKER_OPTS}" > /etc/default/docker

View File

@ -3,10 +3,10 @@ count=30
echo "Adding flannel configuration to etcd"
command=$((/opt/bin/etcdctl set /coreos.com/network/config '{"Network":"10.200.0.0/16"}') 2>&1)
command=$( (/opt/bin/etcdctl set /coreos.com/network/config '{"Network":"10.200.0.0/16"}') 2>&1)
while [ $count -gt 0 ]; do
if [ $command ]; then
if [ "${command}" ]; then
echo "Flannel is configured on master node" >> /tmp/etcd.log
exit 0
fi

View File

@ -28,7 +28,7 @@ done
ip link set dev docker0 down
brctl delbr docker0
echo DOCKER_OPTS=\"-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}\" > /etc/default/docker
echo "DOCKER_OPTS=-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}" > /etc/default/docker
echo post-up iptables -t nat -A POSTROUTING -s 10.200.0.0/16 ! -d 10.200.0.0/16 -j MASQUERADE >> /etc/network/interfaces.d/eth0.cfg
iptables -t nat -A POSTROUTING -s 10.200.0.0/16 ! -d 10.200.0.0/16 -j MASQUERADE

View File

@ -3,7 +3,7 @@
# File with pod is /tmp/pod.json
# $1 new or update
DEFINITION_DIR=/var/run/murano-kubernetes
mkdir -p $DEFINITION_DIR
mkdir -p "${DEFINITION_DIR}"
podId=$2
fileName=$3
@ -12,8 +12,8 @@ echo "$podId Pod $fileName" >> $DEFINITION_DIR/elements.list
if [ "$1" == "True" ]; then
#new Pod
echo "Creating a new Pod" >> /tmp/murano-kube.log
/opt/bin/kubectl create -f $fileName >> /tmp/murano-kube.log
/opt/bin/kubectl create -f "${fileName}" >> /tmp/murano-kube.log
else
echo "Updating a Pod" >> /tmp/murano-kube.log
/opt/bin/kubectl update -f $fileName >> /tmp/murano-kube.log
/opt/bin/kubectl update -f "${fileName}" >> /tmp/murano-kube.log
fi

View File

@ -11,8 +11,8 @@ echo "$serviceId Service $fileName" >> $DEFINITION_DIR/elements.list
if [ "$1" == "True" ]; then
echo "Creating a new Service" >> /tmp/murano-kube.log
/opt/bin/kubectl create -f $fileName >> /tmp/murano-kube.log
/opt/bin/kubectl create -f "${fileName}" >> /tmp/murano-kube.log
else
echo "Updating a Service" >> /tmp/murano-kube.log
/opt/bin/kubectl update -f $fileName >> /tmp/murano-kube.log
/opt/bin/kubectl update -f "${fileName}" >> /tmp/murano-kube.log
fi

View File

@ -12,4 +12,4 @@
# under the License.
echo "Deleting a replication controller" >> /tmp/murano-kube.log
/opt/bin/kubectl delete replicationcontrollers $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete replicationcontrollers "$1" >> /tmp/murano-kube.log

View File

@ -12,4 +12,4 @@
# under the License.
echo "Deleting a Service" >> /tmp/murano-kube.log
/opt/bin/kubectl delete services $1 >> /tmp/murano-kube.log
/opt/bin/kubectl delete services "$1" >> /tmp/murano-kube.log

View File

@ -63,7 +63,7 @@ sudo cat <<EOF2 > /etc/guacamole/user-mapping.xml
</user-mapping>
EOF2
# Create a new user
sudo useradd -d /etc/guacamole -p $(openssl passwd -1 %PASSWORD%) %USERNAME%
sudo useradd -d /etc/guacamole -p "$(openssl passwd -1 %PASSWORD%)" %USERNAME%
# Make guacamole configuration directory readable and writable by the group and others
sudo chmod -R go+rw /etc/guacamole
sudo mkdir /usr/share/tomcat${tcat_version}/.guacamole

View File

@ -18,10 +18,10 @@
# lsnrctl is the proper way to get the host and port numbers.
# Get the descriptions but only the tcp and tcps descriptions
ip_addrs=`lsnrctl status | grep 'DESCRIPTION.*PROTOCOL=tcp' | sed 's|.*HOST=\([^)]*\))(PORT=\([^)]*\).*|\1:\2|g'`
ip_addrs=$(lsnrctl status | grep 'DESCRIPTION.*PROTOCOL=tcp' | sed 's|.*HOST=\([^)]*\))(PORT=\([^)]*\).*|\1:\2|g')
for addr in $ip_addrs
do
tnsping $addr >> /dev/null
tnsping "$addr" >> /dev/null
if [ $? -eq 0 ]
then
echo "$addr"

View File

@ -20,11 +20,11 @@ export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/perl/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
# Find site_perl
site_perl=( $(/usr/bin/ls -r $ORACLE_HOME/perl/lib/site_perl) )
site_perl=( $(/usr/bin/ls -r "${ORACLE_HOME}/perl/lib/site_perl") )
if [[ $(/usr/bin/uname -p) == 'sparc' ]]; then
export PERL5LIB=$ORACLE_HOME/perl/lib/site_perl/${site_perl[0]}/sun4-solaris-64int:$ORACLE_HOME/perl/lib
export PERL5LIB=${ORACLE_HOME}/perl/lib/site_perl/${site_perl[0]}/sun4-solaris-64int:${ORACLE_HOME}/perl/lib
else
export PERL5LIB=$ORACLE_HOME/perl/lib/site_perl/${site_perl[0]}/i86pc-solaris-thread-multi-64:$ORACLE_HOME/perl/lib
export PERL5LIB=${ORACLE_HOME}/perl/lib/site_perl/${site_perl[0]}/i86pc-solaris-thread-multi-64:${ORACLE_HOME}/perl/lib
fi
export PDBSEED=$ORADATA/pdbseed

View File

@ -21,7 +21,7 @@ sql_file="$ORACLE_USER_HOME/pdb_create_$$.sql"
# Create pluggable database
# Open the pluggable database for read-write
cat > $sql_file << EOF
cat > "${sql_file}" << EOF
CONNECT / as sysdba;
SET LINESIZE 100;
SET PAGESIZE 50;
@ -29,8 +29,8 @@ CREATE PLUGGABLE DATABASE $1 ADMIN USER $ADMIN_USER IDENTIFIED BY $ADMIN_PWD rol
ALTER PLUGGABLE DATABASE $1 OPEN;
EXIT;
EOF
chown oracle:oracle $sql_file
chown oracle:oracle "${sql_file}"
# Execute the sql statements
su - oracle -c ". ~/ora_env.sh && sqlplus /nolog @$sql_file $1"
# remove the sql_file
rm -f $sql_file
rm -fv "${sql_file}"

View File

@ -19,11 +19,11 @@
sql_file="$ORACLE_USER_HOME/pdb_create_user_$$.sql"
# get the address to attach to
lsnr=$($ORACLE_USER_HOME/get_listener.sh)
lsnr=$("${ORACLE_USER_HOME}/get_listener.sh")
err=$?
if [[ $err -ne 0 ]]
then
echo $lsnr;
echo "${lsnr}";
exit $err
fi
@ -32,7 +32,7 @@ fi
# TODO: privileges to be set based on what the ADMIN user is requesting
# from the client.
cat > $sql_file << EOF
cat > "${sql_file}" << EOF
CONNECT $SYSTEM_USER/$SYSTEM_USER_PWD@//$lsnr/$1;
SET LINESIZE 100;
SET PAGESIZE 50;
@ -41,13 +41,13 @@ GRANT ALL PRIVILEGES to $2;
EXIT
EOF
chown oracle:oracle $sql_file
chown oracle:oracle "${sql_file}"
# Run this perl script so that the user information is
# updated properly on all the system meta files.
perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l $ORACLE_USER_HOME -b pupbld -u $SYSTEM_USER/$SYSTEM_USER_PWD $ORACLE_HOME/sqlplus/admin/pupbld.sql;
perl "${ORACLE_HOME}/rdbms/admin/catcon.pl" -n 1 -l "${ORACLE_USER_HOME}" -b pupbld -u "${SYSTEM_USER}/${SYSTEM_USER_PWD}" "${ORACLE_HOME}/sqlplus/admin/pupbld.sql";
# Execute the sql
su - oracle -c " . ~/ora_env.sh && sqlplus /nolog @$sql_file"
su - oracle -c " . ~/ora_env.sh && sqlplus /nolog @${sql_file}"
# construct the connection string.
# echo the CONN string
@ -55,4 +55,4 @@ su - oracle -c " . ~/ora_env.sh && sqlplus /nolog @$sql_file"
# echo "$2/$3@//$lnsr/$1"
echo "Connection host and port $lsnr"
rm -f $sql_file
rm -fv "${sql_file}"

View File

@ -1,9 +1,9 @@
#!/bin/sh
#!/bin/bash
# Wait until service starts
while true; do
sleep 30
if ps ax | grep -v grep | grep ruby > /dev/null
if pgrep [r]uby > /dev/null
then
break
fi
@ -13,7 +13,7 @@ done
mkdir /tmp/murano
# Register user in ops manager
echo 'Create the first user:\n' >> /tmp/murano/ops-config.log
echo -e 'Create the first user:\n' >> /tmp/murano/ops-config.log
curl "https://localhost/api/setup" -d \
'setup[user_name]=%USER%&setup[password]=%PASS%&setup[password_confirmation]=%PASS%&setup[eula_accepted]=true' \
@ -36,7 +36,7 @@ curl "https://localhost/api/installation_settings" -X GET \
-u %USER%:%PASS% --insecure > /tmp/murano/bare-installation.yml
# Merge settings
echo "Merging installation settings\n" >> /tmp/murano/ops-config.log
echo -e "Merging installation settings\n" >> /tmp/murano/ops-config.log
python /tmp/murano/merge_settings.py >> /tmp/murano/ops-config.log
if [ ! -f /tmp/murano/installation.yml ]; then
@ -44,7 +44,7 @@ if [ ! -f /tmp/murano/installation.yml ]; then
wc_notify --data-binary '{"status": "FAILURE"}'
fi
echo "Importing settings to Ops Manager:\n" >> /tmp/murano/ops-config.log
echo -e "Importing settings to Ops Manager:\n" >> /tmp/murano/ops-config.log
curl "https://localhost/api/installation_settings" -F \
'installation[file]=@/tmp/murano/installation.yml' -X POST \
-u %USER%:%PASS% --insecure >> /tmp/murano/ops-config.log

View File

@ -17,9 +17,12 @@ set -e
groupadd stacker
useradd -g stacker -s /bin/bash -d /home/stacker -m stacker
( umask 226 && echo "stacker ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/50_dev )
echo "PS1='${debian_chroot:+($debian_chroot)}\u:\w\$ '" >> /home/stacker/.bashrc
echo "source /home/stacker/refstack-client/.venv/bin/activate" >> /home/stacker/.bashrc
echo "alias 'refstack-client'=/home/stacker/refstack-client/refstack-client" >> /home/stacker/.bashrc
{
echo "PS1='${debian_chroot:+($debian_chroot)}\u:\w\$ '"
echo "source /home/stacker/refstack-client/.venv/bin/activate"
echo "alias 'refstack-client'=/home/stacker/refstack-client/refstack-client"
} >> /home/stacker/.bashrc
[ -d '/home/debian' ] && cp -r /home/debian/.ssh /home/stacker
[ -d '/home/ubuntu' ] && cp -r /home/ubuntu/.ssh /home/stacker
chown -R stacker:stacker /home/stacker/.ssh

View File

@ -36,5 +36,5 @@
sed -i.bkp "s/'demoData' => 'no'/'demoData' => 'yes'/g" /var/www/html/Sugar/config_si.php
curl http://localhost/Sugar/install.php?goto=SilentInstall&cli=true
curl -v "http://localhost/Sugar/install.php?goto=SilentInstall&cli=true"

View File

@ -36,5 +36,5 @@
sed -i.bkp "s/'demoData' => 'yes'/'demoData' => 'no'/g" /var/www/html/Sugar/config_si.php
curl http://localhost/Sugar/install.php?goto=SilentInstall&cli=true
curl -v "http://localhost/Sugar/install.php?goto=SilentInstall&cli=true"

View File

@ -49,5 +49,5 @@ sed -i.bkp "s/%%DB_HOST%%/$1/g; s/%%DB_NAME%%/$2/g; s/%%ADMIN_NAME%%/$3/g; s/%%A
cp config_si.php /var/www/html/Sugar/
curl http://localhost/Sugar/install.php?goto=SilentInstall&cli=true
curl -v "http://localhost/Sugar/install.php?goto=SilentInstall&cli=true"

View File

@ -11,4 +11,4 @@
# License for the specific language governing permissions and limitations
# under the License.
python addProbe.py $1 $2 $3 $4
python addProbe.py "$1" "$2" "$3" "$4"

View File

@ -37,7 +37,7 @@ sudo sed -e "s/# DBPassword.*$/DBPassword=%PASSWORD%/" -i /etc/zabbix/zabbix_ser
sudo sed -e "s/^DBUser.*$/DBUser=%USERNAME%/" -i /etc/zabbix/zabbix_server.conf
cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz
sudo gunzip ./*.gz
mysql --user=root --password=root -e "CREATE DATABASE %DATABASE%"
mysql --user=root --password=root -e "CREATE USER '%USERNAME%'@'localhost' IDENTIFIED BY '%PASSWORD%'"

View File

@ -1,6 +1,10 @@
#!/bin/bash
WORKSPACE="${WORKSPACE:-${1}}"
# SC2001: See if you can use ${variable//search/replace} instead.
# Occasionally a more complex sed substitution is required, so lets igone
# this warning
skip_list='SC2001'
function help_m() {
cat <<-EOF
@ -27,7 +31,7 @@ function run_check() {
EOF
while read -d '' -r script; do
unset RESULT
shellcheck "${script}"
shellcheck "${script}" -e "${skip_list}"
RESULT=$?
if [ ${RESULT} != 0 ]; then
((e_count++))

View File

@ -14,7 +14,6 @@ commands = bindep test
# 'shellcheck' is not an Python package, so it can be run w\o
# virtual env. But tox is a usable wrapper to run any kind of tests -
# let's use it for common test-run as well - for unification purposes.
whitelist_externals = shellcheck
commands = {toxinidir}/tools/jenkins/shellcheck.sh {toxinidir}
[testenv:yaml-syntaxcheck]
@ -33,7 +32,6 @@ commands = {toxinidir}/tools/jenkins/yamllint.sh {toxinidir}
# Otherwise, if some command failed - exit code from tox itself will be 1
ignore_errors=True
deps = yamllint
whitelist_externals = shellcheck
commands =
{toxinidir}/tools/jenkins/shellcheck.sh {toxinidir}
{toxinidir}/tools/jenkins/yamllint.sh {toxinidir}