Merge "Fix errors reported by shellcheck for Gerrit and Jenkins"

This commit is contained in:
Jenkins 2016-08-08 20:08:33 +00:00 committed by Gerrit Code Review
commit f779816628
7 changed files with 24 additions and 24 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
GERRIT_USER="$1" # GERRIT_USER="$1"
GROUP="$2" GROUP="$2"
FULL_NAME="$3" FULL_NAME="$3"
EMAIL="$4" EMAIL="$4"
@ -12,7 +12,7 @@ NAME="$6"
# ssh -p 29418 $GERRIT_USER@localhost -i /home/gerrit2/review_site/etc/ssh_host_rsa_key gerrit create-account \ # ssh -p 29418 $GERRIT_USER@localhost -i /home/gerrit2/review_site/etc/ssh_host_rsa_key gerrit create-account \
# --group "'$GROUP'" --full-name "'$FULL_NAME'" --email $EMAIL --ssh-key "'$SSHKEY'" $NAME # --group "'$GROUP'" --full-name "'$FULL_NAME'" --email $EMAIL --ssh-key "'$SSHKEY'" $NAME
HOSTNAME="`hostname -f`" HOSTNAME="$(hostname -f)"
create_args= create_args=
set_args= set_args=
@ -42,12 +42,12 @@ fi
set +e set +e
su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \ su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \
gerrit create-account ${create_args[@]} $NAME" gerrit create-account ${create_args[*]} $NAME"
code=$? code=$?
if [ $code -ne 0 ]; then if [ $code -ne 0 ]; then
# Do not create account but set related properties. # Do not create account but set related properties.
su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \ su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \
gerrit set-account ${set_args[@]} $NAME" gerrit set-account ${set_args[*]} $NAME"
fi fi

View File

@ -8,10 +8,10 @@ datafile='/etc/puppet/hieradata/murano.yaml'
# #
ssh-keygen -t rsa -N "" -f gerrit-rsa.key -q ssh-keygen -t rsa -N "" -f gerrit-rsa.key -q
content=`cat gerrit-rsa.key` content=$(cat gerrit-rsa.key)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_rsa_key_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_rsa_key_contents', value=>'$content', }"
content=`cat gerrit-rsa.key.pub` content=$(cat gerrit-rsa.key.pub)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_rsa_pubkey_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_rsa_pubkey_contents', value=>'$content', }"
# #
@ -19,10 +19,10 @@ puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'ger
# #
ssh-keygen -t rsa -N "" -f gerrit-dsa.key -q ssh-keygen -t rsa -N "" -f gerrit-dsa.key -q
content=`cat gerrit-dsa.key` content=$(cat gerrit-dsa.key)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_dsa_key_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_dsa_key_contents', value=>'$content', }"
content=`cat gerrit-dsa.key.pub` content=$(cat gerrit-dsa.key.pub)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_dsa_pubkey_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_dsa_pubkey_contents', value=>'$content', }"
# #
@ -30,10 +30,10 @@ puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'ger
# #
ssh-keygen -t rsa -N "" -f project-rsa.key -q ssh-keygen -t rsa -N "" -f project-rsa.key -q
content=`cat project-rsa.key` content=$(cat project-rsa.key)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_project_rsa_key_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_project_rsa_key_contents', value=>'$content', }"
content=`cat project-rsa.key.pub` content=$(cat project-rsa.key.pub)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_project_rsa_pubkey_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssh_project_rsa_pubkey_contents', value=>'$content', }"
exit exit

View File

@ -3,7 +3,7 @@ logger Generate SSL certificate for Gerrit
datafile='/etc/puppet/hieradata/murano.yaml' datafile='/etc/puppet/hieradata/murano.yaml'
fqdn=`hostname` fqdn=$(hostname)
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=$fqdn" \ openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=$fqdn" \
-keyout server.key -out server.cert -keyout server.key -out server.cert
@ -11,10 +11,10 @@ openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/
cp server.key server.key.org cp server.key server.key.org
openssl rsa -in server.key.org -out server.key openssl rsa -in server.key.org -out server.key
content=`cat server.key` content=$(cat server.key)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssl_key_file_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssl_key_file_contents', value=>'$content', }"
content=`cat server.cert` content=$(cat server.cert)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssl_cert_file_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'gerrit_ssl_cert_file_contents', value=>'$content', }"
content='' content=''
@ -23,4 +23,4 @@ puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'ger
# create # create
getent group ssl-cert || addgroup --system 'ssl-cert' getent group ssl-cert || addgroup --system 'ssl-cert'
exit exit

View File

@ -7,8 +7,8 @@ ssh-keygen -t rsa -N "" -f jenkins.key -q
datafile='/etc/puppet/hieradata/murano.yaml' datafile='/etc/puppet/hieradata/murano.yaml'
content=`cat jenkins.key` content=$(cat jenkins.key)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'jenkins_ssh_private_key_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'jenkins_ssh_private_key_contents', value=>'$content', }"
content=`cat jenkins.key.pub` content=$(cat jenkins.key.pub)
puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'jenkins_ssh_pubkey_contents', value=>'$content', }" puppet apply --execute "yaml_setting { 'example': target=>'$datafile', key=>'jenkins_ssh_pubkey_contents', value=>'$content', }"

View File

@ -14,18 +14,18 @@ mkdir -p ${plugin_dir}
installPlugin() { installPlugin() {
plugin_name=$1 plugin_name=$1
if [ -f ${plugin_dir}/${plugin_name}.hpi -o -f ${plugin_dir}/${plugin_name}.jpi ]; then if [ -f "${plugin_dir}/${plugin_name}.hpi" -o -f "${plugin_dir}/${plugin_name}.jpi" ]; then
if [ "$2" == "1" ]; then if [ "$2" == "1" ]; then
return 1 return 1
fi fi
fi fi
echo "Installing: $plugin_name" echo "Installing: $plugin_name"
curl -L --silent --output ${plugin_dir}/${plugin_name}.hpi https://updates.jenkins-ci.org/latest/${plugin_name}.hpi curl -L --silent --output "${plugin_dir}/${plugin_name}.hpi" "https://updates.jenkins-ci.org/latest/${plugin_name}.hpi"
return 0 return 0
} }
# Install plugin. # Install plugin.
for plugin in $* for plugin in "$@"
do do
installPlugin "$plugin" installPlugin "$plugin"
done done
@ -46,7 +46,7 @@ while [ "$changed" == "1" ]; do
# Without optionals. # Without optionals.
# deps=$( unzip -p ${f} META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | grep -v "resolution:=optional" | awk -F ':' '{ print $1 }' | tr '\n' ' ' ) # deps=$( unzip -p ${f} META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | grep -v "resolution:=optional" | awk -F ':' '{ print $1 }' | tr '\n' ' ' )
# With optionals. # With optionals.
deps=$( unzip -p ${f} META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | awk -F ':' '{ print $1 }' | tr '\n' ' ' ) deps=$( unzip -p "${f}" META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | awk -F ':' '{ print $1 }' | tr '\n' ' ' )
for plugin in $deps; do for plugin in $deps; do
# if installPlugin returns 1 then 'changed' stays as is. (it means that the whole jenkins plugins state is not changed and in fact, nothing installed) # if installPlugin returns 1 then 'changed' stays as is. (it means that the whole jenkins plugins state is not changed and in fact, nothing installed)
# if installPlugin returns 0 then changed=1 # if installPlugin returns 0 then changed=1

View File

@ -2,7 +2,7 @@
# Cloning 'project-config' from deployed Gerrit # Cloning 'project-config' from deployed Gerrit
GERRIT_URL=`hiera -c /etc/puppet/hiera.yaml gerrit_host` GERRIT_URL=$(hiera -c /etc/puppet/hiera.yaml gerrit_host)
su jenkins -c "git clone ssh://jenkins@$GERRIT_URL:29418/open-paas/project-config /tmp/project-config/" su jenkins -c "git clone ssh://jenkins@$GERRIT_URL:29418/open-paas/project-config /tmp/project-config/"
# Removing old project-config # Removing old project-config

View File

@ -5,9 +5,9 @@ cd /etc/project-config
# Check whether we have local Gerrit installed or not. # Check whether we have local Gerrit installed or not.
# If yes, then 'git pull' should be executed under 'jenkins' user # If yes, then 'git pull' should be executed under 'jenkins' user
GERRIT_URL=`hiera -c /etc/puppet/hiera.yaml gerrit_host` GERRIT_URL=$(hiera -c /etc/puppet/hiera.yaml gerrit_host)
if [ $GERRIT_URL != "nil" ]; then if [ "$GERRIT_URL" != "nil" ]; then
echo "Pulling changes from installed Gerrit" echo "Pulling changes from installed Gerrit"
su jenkins -c "git pull" su jenkins -c "git pull"
else else