-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1ab61d4
Showing
7 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Color output | ||
GREEN='\033[0;32m' | ||
RESET='\033[0m' | ||
|
||
################################################################################ | ||
# Deploy # | ||
################################################################################ | ||
BuildAndDeploy() | ||
{ | ||
env=$2 | ||
|
||
# Make executable | ||
chmod +x scripts/build-application.sh | ||
chmod +x scripts/build-environment.sh | ||
chmod +x scripts/deploy-application.sh | ||
|
||
# Build application | ||
echo -e "${GREEN}Building application${RESET}" | ||
scripts/build-application.sh -b "$env" | ||
|
||
# Build environment | ||
echo -e "${GREEN}Building environment${RESET}" | ||
scripts/build-environment.sh -b "$env" | ||
|
||
# Deploy | ||
# echo -e "${GREEN}Deploying${RESET}" | ||
# scripts/deploy-application.sh -d "$env" | ||
|
||
} | ||
|
||
################################################################################ | ||
# Help # | ||
################################################################################ | ||
Help() | ||
{ | ||
# Display Help | ||
echo "Runs build and deploy scripts" | ||
echo "Target depends on environment variable" | ||
echo | ||
echo "Syntax: build-and-deploy.sh [-h|b] ENVIRONMENT" | ||
echo "options:" | ||
echo "h Print this Help." | ||
echo "b Builds and deploys Omeka" | ||
echo | ||
} | ||
|
||
while getopts 'hb' flag; do | ||
case "${flag}" in | ||
h) Help ;; | ||
b) BuildAndDeploy "$@";; | ||
*) error "Unexpected option ${flag}" ;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/bash | ||
# | ||
# Runs composer install against a composer.json file and | ||
# copies over modules. | ||
# | ||
# | ||
# Run with -h for help and composer.json file is specified | ||
# with -c compose.json | ||
# | ||
# Supported distributions: | ||
# - WSL2 Ubuntu 20.04.4 LTS | ||
# | ||
#---------------------------------------------------------------- | ||
|
||
# Color output | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
YELLOW="\033[0;33m" | ||
WHITE='\033[0;37m' | ||
RESET='\033[0m' | ||
|
||
base_dir='/var/www/' | ||
relative_dir='html' | ||
env=$2 | ||
|
||
################################################################################ | ||
# Checks # | ||
################################################################################ | ||
|
||
Checks() | ||
{ | ||
|
||
# Expected OS version | ||
|
||
OS=`uname -s` | ||
if [ $OS != 'Linux' ]; then | ||
echo "$PROG: error: unsupported operating system: not Linux: $OS" >&2 | ||
exit 1 | ||
fi | ||
|
||
if ! which lsb_release >/dev/null 2>&1; then | ||
echo "$PROG: error: unsupported distribution: missing lsb_release" >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
################################################################################ | ||
# CHECK REQUIREMENTS # | ||
################################################################################ | ||
CheckRequirements() | ||
{ | ||
echo -e "${YELLOW}Checking for composer and unzip${RESET}" | ||
|
||
# check we have composer and unzip | ||
if command -v composer &> /dev/null | ||
then | ||
echo -e "${GREEN}Found composer :).${RESET}" | ||
else | ||
echo -e "${RED}Could not find composer :(${RESET}" | ||
|
||
# Build composer | ||
echo -e "${GREEN}Building composer${RESET}" | ||
scripts/build-composer.sh -b | ||
fi | ||
|
||
if command -v unzip &> /dev/null | ||
then | ||
echo -e "${GREEN}Found unzip :).${RESET}" | ||
else | ||
echo -e "${RED}Could not find unzip :(${RESET}" | ||
fi | ||
|
||
} | ||
|
||
Build() | ||
{ | ||
|
||
Checks | ||
CheckRequirements | ||
|
||
# Create composer.json from template | ||
echo -e "${GREEN}Creating composer.json${RESET}" | ||
cp scripts/composer.json.template composer.json | ||
|
||
php scripts/composer-merge.php | ||
|
||
# Use composer to build the application | ||
echo -e "${GREEN}Running composer${RESET}" | ||
|
||
if [ """$env""" == "test" ] || [ """$env""" == "dev" ]; | ||
then | ||
composer install --dev --prefer-source | ||
else | ||
# assumes prod or staging | ||
composer install --no-dev | ||
fi | ||
|
||
|
||
} | ||
|
||
|
||
################################################################################ | ||
# Help # | ||
################################################################################ | ||
Help() | ||
{ | ||
# Display Help | ||
echo "Uses composer to create omeka S filesystem from composer.json file" | ||
echo "Run this from a folder which container composer.json" | ||
echo | ||
echo "Syntax: build-omeka-from-composer.sh [-h|b]" | ||
echo "options:" | ||
echo "h Print this Help." | ||
echo "b Build filesystem from composer.json file." | ||
echo | ||
} | ||
|
||
while getopts 'hb' flag; do | ||
case "${flag}" in | ||
h) Help ;; | ||
b) Build ;; | ||
*) error "Unexpected option ${flag}" ;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" | ||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | ||
|
||
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] | ||
then | ||
>&2 echo 'ERROR: Invalid installer checksum' | ||
rm composer-setup.php | ||
exit 1 | ||
fi | ||
|
||
php composer-setup.php --quiet | ||
RESULT=$? | ||
rm composer-setup.php | ||
mv composer.phar /usr/local/bin/composer | ||
exit $RESULT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################################################################################ | ||
# DATABASE CONFIGURATION # | ||
################################################################################ | ||
SetupDatabase() | ||
{ | ||
if [ """$env""" == "test" ]; then | ||
|
||
echo -e "${GREEN}Copying Database dumps for import by image${RESET}" | ||
|
||
DB_folder="container_database/db_files" | ||
|
||
mkdir -p $DB_folder | ||
|
||
# join the text files into a single dump for image loading | ||
#cat db/clear_tables.sql db/build_tables.sql db/insert_base_data.sql db/enable_ldap_plugin.sql db/insert_idguser.sql> "$DB_folder/dump.sql" | ||
cp db/omeka.sql "$DB_folder/dump.sql" | ||
elif [ """$env""" == "dev" ]; then | ||
|
||
echo -e "${GREEN}Dev environment persists the database if exists ${RESET}" | ||
|
||
if [ -d "container_database/db_files" ]; then | ||
echo -e "${GREEN}Database files already exist, skipping${RESET}" | ||
else | ||
echo -e "${GREEN}Copying Database dumps for import by image${RESET}" | ||
|
||
DB_folder="container_database/db_files" | ||
|
||
mkdir -p $DB_folder | ||
|
||
# join the text files into a single dump for image loading | ||
#cat db/clear_tables.sql db/build_tables.sql db/insert_base_data.sql db/enable_ldap_plugin.sql db/insert_idguser.sql> "$DB_folder/dump.sql" | ||
cp db/omeka.sql "$DB_folder/dump.sql" | ||
fi | ||
|
||
fi | ||
|
||
|
||
|
||
} |
Oops, something went wrong.