Fix various shellcheck warnings and errors

Signed-off-by: solidnerd <niclas@mietz.io>
This commit is contained in:
solidnerd 2018-11-23 21:28:10 +01:00 committed by Niclas Mietz
parent ba10cbd962
commit 9d5f0dbb0b
5 changed files with 22 additions and 14 deletions

View File

@ -27,8 +27,8 @@ BUILD_DEPENDENCIES="gcc g++ make patch pkg-config cmake paxctl \
## Execute a command as GITLAB_USER
exec_as_git() {
if [[ $(whoami) == ${GITLAB_USER} ]]; then
$@
if [[ $(whoami) == "${GITLAB_USER}" ]]; then
"$@"
else
sudo -HEu ${GITLAB_USER} "$@"
fi
@ -42,9 +42,9 @@ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y ${BUIL
# Applying the mark late here does make the build usable on PaX kernels, but
# still the build itself must be executed on a non-PaX kernel. It's done here
# only for simplicity.
paxctl -Cm `which ruby${RUBY_VERSION}`
paxctl -Cm "$(command -v ruby${RUBY_VERSION})"
# https://en.wikibooks.org/wiki/Grsecurity/Application-specific_Settings#Node.js
paxctl -Cm `which nodejs`
paxctl -Cm "$(command -v nodejs)"
# remove the host keys generated during openssh-server installation
rm -rf /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
@ -134,8 +134,8 @@ rm -rf ${GITLAB_GITALY_BUILD_DIR}
rm -rf ${GITLAB_BUILD_DIR}/go${GOLANG_VERSION}.linux-amd64.tar.gz ${GOROOT}
# Fix for rebase in forks
echo "Linking $(which gitaly-ssh) to /"
ln -s $(which gitaly-ssh) /
echo "Linking $(command -v gitaly-ssh) to /"
ln -s "$(command -v gitaly-ssh)" /
# remove HSTS config from the default headers, we configure it in nginx
exec_as_git sed -i "/headers\['Strict-Transport-Security'\]/d" ${GITLAB_INSTALL_DIR}/app/controllers/application_controller.rb
@ -151,7 +151,7 @@ if [[ -d ${GEM_CACHE_DIR} ]]; then
chown -R ${GITLAB_USER}: ${GITLAB_INSTALL_DIR}/vendor/cache
fi
exec_as_git bundle install -j$(nproc) --deployment --without development test aws
exec_as_git bundle install -j"$(nproc)" --deployment --without development test aws
# make sure everything in ${GITLAB_HOME} is owned by ${GITLAB_USER} user
chown -R ${GITLAB_USER}: ${GITLAB_HOME}

View File

@ -1,6 +1,8 @@
#!/bin/bash
set -e
source ${GITLAB_RUNTIME_DIR}/functions
set -o pipefail
source "${GITLAB_RUNTIME_DIR}/functions"
[[ $DEBUG == true ]] && set -x
@ -19,7 +21,9 @@ case ${1} in
SUPERVISOR_PID=$!
migrate_database
kill -15 $SUPERVISOR_PID
ps h -p $SUPERVISOR_PID > /dev/null && wait $SUPERVISOR_PID || true
if ps h -p $SUPERVISOR_PID > /dev/null ; then
wait $SUPERVISOR_PID || true
fi
rm -rf /var/run/supervisor.sock
exec /usr/bin/supervisord -nc /etc/supervisor/supervisord.conf
;;
@ -31,7 +35,7 @@ case ${1} in
;;
app:rake)
shift 1
execute_raketask $@
execute_raketask "$@"
;;
esac
;;

View File

@ -7,6 +7,6 @@ docker build \
--pull \
--cache-from=${IMAGE_NAME} \
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \
--build-arg=VCS_REF=$(git rev-parse --short HEAD) \
--build-arg=VERSION=$(cat VERSION) \
--build-arg=VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg=VERSION="$(cat VERSION)" \
-t ${IMAGE_NAME} .

View File

@ -1,6 +1,8 @@
#!/bin/bash
set -e
set -o pipefail
if ! which kubectl > /dev/null; then
if ! command -v kubectl > /dev/null; then
echo "kubectl command not installed"
exit 1
fi

View File

@ -1,6 +1,8 @@
#!/bin/bash
set -e
set -o pipefail
if ! which kubectl > /dev/null; then
if ! command -v kubectl > /dev/null; then
echo "kubectl command not installed"
exit 1
fi