Fix shellcheck errors in build script

This commit is contained in:
Starbeamrainbowlabs 2019-07-18 23:38:56 +01:00
parent 69d8954ba0
commit 27efd5a1b5
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 9 additions and 6 deletions

15
build
View File

@ -1,8 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Make sure the current directory is the location of this script to simplify matters # Make sure the current directory is the location of this script to simplify matters
cd "$(dirname $(readlink -f $0))"; cd "$(dirname "$(readlink -f "$0")")" || exit 1;
if [ ! -d "${PWD}/.git" ]; then if [ ! -d "${PWD}/.git" ]; then
# shellcheck disable=SC1117
echo -e "\033[1m\033[31mError: The .git folder does not appear to exist. Please ensure you clone this repository with git, like this:\n\n\tgit clone https://github.com/ConnectedHumber/Air-Quality-Web.git\n\033[0m"; echo -e "\033[1m\033[31mError: The .git folder does not appear to exist. Please ensure you clone this repository with git, like this:\n\n\tgit clone https://github.com/ConnectedHumber/Air-Quality-Web.git\n\033[0m";
exit 1; exit 1;
fi fi
@ -46,11 +47,13 @@ deploy_root_dir_beta="Air-Quality-Web-Beta";
# Check out the lantern git submodule if needed # Check out the lantern git submodule if needed
if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
# shellcheck disable=SC1090
source "${lantern_path}/lantern.sh"; source "${lantern_path}/lantern.sh";
if [[ "$#" -lt 1 ]]; then if [[ "$#" -lt 1 ]]; then
echo -e "${FBLE}${project_name}${RS} build script"; echo -e "${FBLE}${project_name}${RS} build script";
echo -e " by Starbeamrainbowlabs"; echo -e " by Starbeamrainbowlabs";
# shellcheck disable=SC2154
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}"; echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
echo -e ""; echo -e "";
echo -e "${CSECTION}Usage${RS}"; echo -e "${CSECTION}Usage${RS}";
@ -97,7 +100,7 @@ task_download-composer() {
check_php_module() { check_php_module() {
module_name="$1"; module_name="$1";
subtask_begin "Checking for ${module_name} PHP module"; subtask_begin "Checking for ${module_name} PHP module";
if [[ "$(php -m | grep -i pdo_mysql | wc -l)" -eq "0" ]]; then if [[ "$(php -m | grep -ic pdo_mysql)" -eq "0" ]]; then
subtask_end 1 "Error: The php_mysql PHP module is not installed."; subtask_end 1 "Error: The php_mysql PHP module is not installed.";
fi fi
subtask_end 0; subtask_end 0;
@ -191,7 +194,7 @@ task_database() {
task_dev-server() { task_dev-server() {
task_begin "Starting development server"; task_begin "Starting development server";
php -S [::1]:40482 & php -S "[::1]:40482" &
exit_code=$?; exit_code=$?;
echo $! >/tmp/micro-lantern-dev-server.pid; echo $! >/tmp/micro-lantern-dev-server.pid;
task_end $?; # Should be 0 unless php died for some reason task_end $?; # Should be 0 unless php died for some reason
@ -284,7 +287,7 @@ task_ci() {
if [ "${GIT_REF_NAME}" == "refs/heads/master" ]; then if [ "${GIT_REF_NAME}" == "refs/heads/master" ]; then
tasks_run deploy; tasks_run deploy;
else if [ "${GIT_REF_NAME}" == "refs/heads/dev" ]; then elif [ "${GIT_REF_NAME}" == "refs/heads/dev" ]; then
echo "Deploying as beta release, as we're on the dev branch"; echo "Deploying as beta release, as we're on the dev branch";
deploy_root_dir="${deploy_root_dir_beta}"; deploy_root_dir="${deploy_root_dir_beta}";
tasks_run deploy; tasks_run deploy;
@ -301,7 +304,7 @@ task_archive() {
task_begin "Packing archive"; task_begin "Packing archive";
# We include the data directory here because we assume that this task is ONLY run in a CI environment, so it should only contain the default setup generated by an earlier task. # We include the data directory here because we assume that this task is ONLY run in a CI environment, so it should only contain the default setup generated by an earlier task.
execute tar cafv "${ARCHIVE}/Air-Quality-Web.tar.gz" app/ __nightdocs/ lib/ logic/ vendor/ data/ *.php *.md LICENSE version settings.default.toml; execute tar cafv "${ARCHIVE}/Air-Quality-Web.tar.gz" app/ __nightdocs/ lib/ logic/ vendor/ data/ ./*.php ./*.md LICENSE version settings.default.toml;
task_end $?; task_end $?;
task_begin "Cleaning up"; task_begin "Cleaning up";
@ -402,4 +405,4 @@ SFTPCOMMANDS
######################################################################### #########################################################################
tasks_run $@; tasks_run "$@";