File: init_variables

package info (click to toggle)
ruby-health-check 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: sh: 1,227; ruby: 766; makefile: 3
file content (79 lines) | stat: -rw-r--r-- 1,889 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

# Any failure causes exit
set -eE -o functrace

report_failure() {
  local lineno=$2
  local fn=$3
  local exitstatus=$4
  local msg=$5
  local lineno_fns=${1% 0}
  if [[ $lineno_fns != "0" ]] ; then
    lineno="${lineno} ${lineno_fns}"
  fi
  if [[ $exitstatus == 0 ]] ; then
    echo "${BASH_SOURCE[1]}: Finished!"
  else
    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
  fi
}

trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR

echo Setting RAILS_ENV=test RACK_ENV=test
export RAILS_ENV=test RACK_ENV=test

base_dir=$PWD
tmp_dir=$base_dir/tmp
railsapp=$tmp_dir/railsapp
custom_file="$railsapp/tmp/custom_check.ok"
catchall_file="$railsapp/tmp/catchall_route.enabled"
success=successful

rehash=''
rbenv_which='which'

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  echo "Detected user installed rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
  echo "Detected root installed rvm"
elif [[ -d "$HOME/.rbenv" ]] ; then
  echo "Detected rbenv: `rbenv version`"
  rehash='rbenv rehash'
  rbenv_which='rbenv which'
else
  printf "Note: Neither rvm nor rbenv was not found.\n"
fi

echo "Checking required commands exist:"
for cmd in bash gem egrep ls tail kill find cpio
do
    echo -n "  "
    which $cmd || ( echo "Aborting setup_railsapp: Missing $cmd command!" && exit 2 )
done
for cmd in ruby gem
do
    echo -n "  "
    $rbenv_which $cmd || ( echo "Aborting setup_railsapp: Missing $cmd command!" && exit 2 )
done

rails="rails"
rake="rake"

if [ -x $base_dir/test/bin/rails ]
then
    rails="$base_dir/test/bin/rails"
    rake="$base_dir/test/bin/rake"
    export PATH="$base_dir/test/bin:$PATH"
fi

if [ -x $railsapp/bin/rails ]
then
    rails="$railsapp/bin/rails"
    rake="$railsapp/bin/rake"
    export PATH="$railsapp/bin:$PATH"
fi

echo "Using rails=$rails, rake=$rake"