rebuild.sh 2.26 KB
Newer Older
1
#!/bin/bash
2
3
4
5
6
phpversion="$(php --version | head -n 1 | cut -d ' ' -f 2 | cut -c 1,3)"
if (( phpversion < 70 ));  then
  echo 'PHP is too old to continue. If in Vagrant, run "defaultphp71" to change versions.'
  exit 1
fi
7

8
9
10
11
12
13
14
15
16
# ISTWCMS-2841: Get the current directory that we are in.
dir=$(pwd)

# ISTWCMS-2841: Split the string based on /.
dirs=(`echo $dir |sed 's/\// /g'`)

# ISTWCMS-2841: The drupal directory will always be the third element.
drupal_directory=${dirs[2]}

17
18
# Set variables from command line, if any.
response=${1}
Chris Shantz's avatar
Chris Shantz committed
19

20
21
case "$response" in
  -y|-n|1|2|3 )
22

23
24
25
26
27
    # Set the variables for drupal core and pattern lab.
    # If none are supplied from the commandline, use defaults.
    # When argument supplied for building, arguments 2 & 3 are used.
    drupal_core_path=${2:-/var/www/drupal8}
    pattern_lab_root_path=${3:-/var/www/html}
28

29
30
31
32
    if [ ${response} = "-y" ]; then
      answer=1
    elif [ ${response} = "-n" ]; then
      answer=2
33
    else
34
35
36
37
38
      if [ ${response} = "1" ] || [ ${response} = "2" ] || [ ${response} = "3" ]; then
        answer=${response}
      else
        echo "There was an incorrect flag supplied"
      fi
39
    fi
40
41
42
  ;;
  * )

43
44
45
46
47
48
49
    echo "Error: No BUILD specified. Usage:"
    echo "rebuild.sh BUILD [DRUPAL_CORE_PATH] [PATTERN_LAB_ROOT_PATH]"
    echo "BUILD must be one of:"
    echo "1 = Rebuild profile and pattern-lab."
    echo "2 = Rebuild profile only."
    echo "3 = Rebuild pattern-lab only."
    exit 1
50
51
52
53
54
  ;;
esac

case $answer in
  1 )
55
    echo ""
56
    echo "You have chosen to rebuild the profile and gesso.";
57
    echo ""
58
59
60
61
62
    sh ./scripts/github_check.sh
    if [[ $? -ne 0 ]] ; then
      exit 1
    else
      sh ./scripts/rebuild_profile.sh $drupal_core_path $pattern_lab_root_path
63
      sh ./scripts/rebuild_gesso.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
64
65
66
    fi
    ;;
  2 )
67
    echo ""
68
    echo "You have chosen to rebuild the profile only."
69
    echo ""
70
    sh ./scripts/rebuild_profile.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
71
72
    ;;
  3 )
73
    echo ""
74
    echo "You have chosen to rebuild pattern-lab only."
75
    echo ""
76
77
78
79
    sh ./scripts/github_check.sh
    if [[ $? -ne 0 ]] ; then
      exit 1
    else
80
      sh ./scripts/rebuild_gesso.sh $drupal_core_path $pattern_lab_root_path $drupal_directory
81
82
    fi
    ;;
Liam Morland's avatar
Liam Morland committed
83
esac