diff --git a/run.sh b/run.sh index 901d7e46172..039047a87b8 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,6 @@ #!/bin/sh -cd `dirname $0` +cd "$(dirname "$0")" # If there is a file that defines a shell environment specific to this # instance of Galaxy, source the file. @@ -34,7 +34,7 @@ do shift ;; --daemon|--restart|restart) - if [ "$1"=="--restart" ] + if [ "$1" = "--restart" ] then paster_args="$paster_args restart" else @@ -66,7 +66,7 @@ GALAXY_VIRTUAL_ENV="${GALAXY_VIRTUAL_ENV:-.venv}" if [ -d "$GALAXY_VIRTUAL_ENV" -a -z "$skip_venv" ]; then [ -n "$PYTHONPATH" ] && { echo 'Unsetting $PYTHONPATH'; unset PYTHONPATH; } - printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n" + echo "Activating virtualenv at $GALAXY_VIRTUAL_ENV" . "$GALAXY_VIRTUAL_ENV/bin/activate" fi @@ -99,35 +99,35 @@ if [ -z "$GALAXY_CONFIG_FILE" ]; then fi if [ -n "$GALAXY_RUN_ALL" ]; then - servers=`sed -n 's/^\[server:\(.*\)\]/\1/ p' $GALAXY_CONFIG_FILE | xargs echo` + servers=$(sed -n 's/^\[server:\(.*\)\]/\1/ p' "$GALAXY_CONFIG_FILE" | xargs echo) if [ -z "$stop_daemon_arg_set" -a -z "$daemon_or_restart_arg_set" ]; then - echo 'ERROR: $GALAXY_RUN_ALL cannot be used without the `--daemon`, `--stop-daemon` or `restart` arguments to run.sh' + echo "ERROR: \$GALAXY_RUN_ALL cannot be used without the '--daemon', '--stop-daemon' or 'restart' arguments to run.sh" exit 1 fi for server in $servers; do if [ -n "$wait_arg_set" -a -n "$daemon_or_restart_arg_set" ]; then - python ./scripts/paster.py serve $GALAXY_CONFIG_FILE --server-name=$server --pid-file=$server.pid --log-file=$server.log $paster_args + python ./scripts/paster.py serve "$GALAXY_CONFIG_FILE" --server-name="$server" --pid-file="$server.pid" --log-file="$server.log" $paster_args while true; do sleep 1 printf "." # Grab the current pid from the pid file - if ! current_pid_in_file=$(cat $server.pid); then + if ! current_pid_in_file=$(cat "$server.pid"); then echo "A Galaxy process died, interrupting" >&2 exit 1 fi # Search for all pids in the logs and tail for the last one - latest_pid=`egrep '^Starting server in PID [0-9]+\.$' $server.log -o | sed 's/Starting server in PID //g;s/\.$//g' | tail -n 1` + latest_pid=$(egrep '^Starting server in PID [0-9]+\.$' "$server.log" -o | sed 's/Starting server in PID //g;s/\.$//g' | tail -n 1) # If they're equivalent, then the current pid file agrees with our logs # and we've succesfully started - [ -n "$latest_pid" ] && [ $latest_pid -eq $current_pid_in_file ] && break + [ -n "$latest_pid" ] && [ "$latest_pid" -eq "$current_pid_in_file" ] && break done echo else echo "Handling $server with log file $server.log..." - python ./scripts/paster.py serve $GALAXY_CONFIG_FILE --server-name=$server --pid-file=$server.pid --log-file=$server.log $paster_args + python ./scripts/paster.py serve "$GALAXY_CONFIG_FILE" --server-name="$server" --pid-file="$server.pid" --log-file="$server.log" $paster_args fi done else # Handle only 1 server, whose name can be specified with --server-name parameter (defaults to "main") - python ./scripts/paster.py serve $GALAXY_CONFIG_FILE $paster_args + python ./scripts/paster.py serve "$GALAXY_CONFIG_FILE" $paster_args fi diff --git a/scripts/common_startup.sh b/scripts/common_startup.sh index fbf4180d22e..c7c1d1758d0 100755 --- a/scripts/common_startup.sh +++ b/scripts/common_startup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e SET_VENV=1 @@ -54,22 +54,22 @@ if [ $COPY_SAMPLE_FILES -eq 1 ]; then for sample in $SAMPLES; do file=${sample%.sample} if [ ! -f "$file" -a -f "$sample" ]; then - echo "Initializing $file from `basename $sample`" - cp $sample $file + echo "Initializing $file from $(basename "$sample")" + cp "$sample" "$file" fi done fi # remove problematic cached files for rmfile in $RMFILES; do - [ -f $rmfile ] && rm -f $rmfile + [ -f "$rmfile" ] && rm -f "$rmfile" done : ${GALAXY_CONFIG_FILE:=config/galaxy.ini} -if [ ! -f $GALAXY_CONFIG_FILE ]; then +if [ ! -f "$GALAXY_CONFIG_FILE" ]; then GALAXY_CONFIG_FILE=universe_wsgi.ini fi -if [ ! -f $GALAXY_CONFIG_FILE ]; then +if [ ! -f "$GALAXY_CONFIG_FILE" ]; then GALAXY_CONFIG_FILE=config/galaxy.ini.sample fi @@ -87,24 +87,24 @@ if [ $SET_VENV -eq 1 -a $CREATE_VENV -eq 1 ]; then vvers=13.1.2 vurl="https://pypi.python.org/packages/source/v/virtualenv/virtualenv-${vvers}.tar.gz" vsha="aabc8ef18cddbd8a2a9c7f92bc43e2fea54b1147330d65db920ef3ce9812e3dc" - vtmp=`mktemp -d -t galaxy-virtualenv-XXXXXX` - vsrc="$vtmp/`basename $vurl`" + vtmp=$(mktemp -d -t galaxy-virtualenv-XXXXXX) + vsrc="$vtmp/$(basename $vurl)" # SSL certificates are not checked to prevent problems with messed # up client cert environments. We verify the download using a known # good sha256 sum instead. echo "Fetching $vurl" if command -v curl >/dev/null; then - curl --insecure -L -o $vsrc $vurl + curl --insecure -L -o "$vsrc" "$vurl" elif command -v wget >/dev/null; then - wget --no-check-certificate -O $vsrc $vurl + wget --no-check-certificate -O "$vsrc" "$vurl" else python -c "import urllib; urllib.urlretrieve('$vurl', '$vsrc')" fi echo "Verifying $vsrc checksum is $vsha" python -c "import hashlib; assert hashlib.sha256(open('$vsrc', 'rb').read()).hexdigest() == '$vsha', '$vsrc: invalid checksum'" - tar zxf $vsrc -C $vtmp - python $vtmp/virtualenv-$vvers/virtualenv.py "$GALAXY_VIRTUAL_ENV" - rm -rf $vtmp + tar zxf "$vsrc" -C "$vtmp" + python "$vtmp/virtualenv-$vvers/virtualenv.py" "$GALAXY_VIRTUAL_ENV" + rm -rf "$vtmp" fi fi fi @@ -114,7 +114,7 @@ if [ $SET_VENV -eq 1 ]; then # should run this instance in. if [ -d "$GALAXY_VIRTUAL_ENV" ]; then - printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n" + echo "Activating virtualenv at $GALAXY_VIRTUAL_ENV" . "$GALAXY_VIRTUAL_ENV/bin/activate" # Because it's a virtualenv, we assume $PYTHONPATH is unnecessary for # anything in the venv to work correctly, and having it set can cause @@ -131,7 +131,7 @@ if [ $SET_VENV -eq 1 ]; then exit 1 fi elif [ $SET_VENV -eq 0 -a $CONDA_ALREADY_INSTALLED -eq 1 ]; then - echo -e "\e[33mWarning: You have Conda installed. Skipping virtualenv activation. This could cause missing dependencies.\e[0m" + echo "Warning: You have Conda installed. Skipping virtualenv activation. This could cause missing dependencies." fi : ${GALAXY_WHEELS_INDEX_URL:="https://wheels.galaxyproject.org/simple"} @@ -140,12 +140,12 @@ if [ $REPLACE_PIP -eq 1 ]; then fi if [ $FETCH_WHEELS -eq 1 ]; then - pip install -r requirements.txt --index-url ${GALAXY_WHEELS_INDEX_URL} - GALAXY_CONDITIONAL_DEPENDENCIES=`PYTHONPATH=lib python -c "import galaxy.dependencies; print '\n'.join(galaxy.dependencies.optional('$GALAXY_CONFIG_FILE'))"` - [ -z "$GALAXY_CONDITIONAL_DEPENDENCIES" ] || echo "$GALAXY_CONDITIONAL_DEPENDENCIES" | pip install -r /dev/stdin --index-url ${GALAXY_WHEELS_INDEX_URL} + pip install -r requirements.txt --index-url "${GALAXY_WHEELS_INDEX_URL}" + GALAXY_CONDITIONAL_DEPENDENCIES=$(PYTHONPATH=lib python -c "import galaxy.dependencies; print '\n'.join(galaxy.dependencies.optional('$GALAXY_CONFIG_FILE'))") + [ -z "$GALAXY_CONDITIONAL_DEPENDENCIES" ] || echo "$GALAXY_CONDITIONAL_DEPENDENCIES" | pip install -r /dev/stdin --index-url "${GALAXY_WHEELS_INDEX_URL}" fi if [ $FETCH_WHEELS -eq 1 -a $DEV_WHEELS -eq 1 ]; then dev_requirements='./lib/galaxy/dependencies/dev-requirements.txt' - [ -f $dev_requirements ] && pip install -r $dev_requirements --index-url ${GALAXY_WHEELS_INDEX_URL} + [ -f $dev_requirements ] && pip install -r $dev_requirements --index-url "${GALAXY_WHEELS_INDEX_URL}" fi