-
Notifications
You must be signed in to change notification settings - Fork 28
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
Showing
21 changed files
with
466 additions
and
209 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
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
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
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,26 @@ | ||
#!/bin/bash | ||
|
||
# Help | ||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||
echo "Used to (re)build services running through docker. Optionally specify service names." | ||
echo "" | ||
echo "Usage: bash $0 [service name (optional) (up to 10 service names)]" | ||
exit 0 | ||
fi | ||
|
||
# Start | ||
# Get additional arguments (service names) | ||
I1="$1" | ||
I2="$2" | ||
I3="$3" | ||
I4="$4" | ||
I5="$5" | ||
I6="$6" | ||
I7="$7" | ||
I8="$8" | ||
I9="$9" | ||
I10="$10" | ||
|
||
sudo docker compose build $I1 $I2 $I3 $I4 $I5 $I6 $I7 $I8 $I9 $I10 | ||
|
||
echo "Build script is done. You can now start the services using the './scripts/start.sh $MODE' script." |
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,80 @@ | ||
#!/bin/bash | ||
|
||
# Help | ||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||
echo "Used to set up the repository. Specify the environment type." | ||
echo "Optionally initialises git submodules and their setups." | ||
echo "Removes any .env file, and creates a copy of .env.example with the appropriate name, then symlinks it to .env." | ||
echo "Optionally prepopulates DX with data" | ||
echo "" | ||
echo "Usage: . $0" | ||
exit 0 | ||
fi | ||
|
||
# Function to prompt user for Y/n choice | ||
ask_for_confirmation() { | ||
read -rp "$1 (Y/n): " choice | ||
case "$choice" in | ||
""|y|Y ) | ||
return 0 # Default to Y if user presses Enter without typing anything | ||
;; | ||
n|N ) | ||
return 1 | ||
;; | ||
* ) | ||
ask_for_confirmation "$1" # Ask again if input is not recognized | ||
;; | ||
esac | ||
} | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to install Docker?"; then | ||
. ./scripts/setup/install_docker.sh | ||
else | ||
echo "Skipping Docker installation." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to install NodeJS v16, npm and yarn?"; then | ||
. ./scripts/setup/install_node.sh | ||
else | ||
echo "Skipping NodeJS, npm and yarn installation." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to initialise the submodules?"; then | ||
. ./scripts/setup/install_submodules.sh | ||
else | ||
echo "Skipping the submodules." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to set up the query builder?"; then | ||
. ./scripts/setup/setup_iati_cloud_frontend.sh | ||
else | ||
echo "Skipping the Query Builder." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to install NGINX with SSL enabled?"; then | ||
. ./scripts/setup/install_nginx.sh | ||
else | ||
echo "Skipping NGINX." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
if ask_for_confirmation "Do you want to set up Solr (must be done before stack can be activated)?"; then | ||
. ./scripts/setup/setup_solr.sh | ||
else | ||
echo "Skipping NGINX." | ||
fi | ||
|
||
echo "" | ||
echo "" | ||
echo "Setup script is done, please set up your env, and run 'bash ./scripts/build.sh <MODE>' to build the project." |
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,30 @@ | ||
#!/bin/bash | ||
|
||
print_status() { | ||
echo " | ||
====================================================== | ||
Status Update | ||
------------------------------------------------------ | ||
$1 | ||
====================================================== | ||
" | ||
} | ||
|
||
print_status "Installing Docker..." | ||
# Copied from https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository | ||
# Add Docker's official GPG key: | ||
sudo apt-get update | ||
sudo apt-get install ca-certificates curl gnupg -y | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
sudo chmod a+r /etc/apt/keyrings/docker.gpg | ||
|
||
# Add the repository to Apt sources: | ||
echo \ | ||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | ||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y | ||
print_status "Done installing Docker." |
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,90 @@ | ||
#!/bin/bash | ||
|
||
# Function to prompt user for Y/n choice | ||
ask_for_confirmation() { | ||
read -rp "$1 (Y/n): " choice | ||
case "$choice" in | ||
""|y|Y ) | ||
return 0 # Default to Y if user presses Enter without typing anything | ||
;; | ||
n|N ) | ||
return 1 | ||
;; | ||
* ) | ||
ask_for_confirmation "$1" # Ask again if input is not recognized | ||
;; | ||
esac | ||
} | ||
|
||
print_status() { | ||
echo " | ||
====================================================== | ||
Status Update | ||
------------------------------------------------------ | ||
$1 | ||
====================================================== | ||
" | ||
} | ||
|
||
if ask_for_confirmation "Do NGINX and Certbot need to be installed before setup?"; then | ||
echo "Installing NGINX and Certbot..." | ||
print_status "Installing NGINX..." | ||
sudo apt update | ||
sudo apt install nginx -y | ||
|
||
print_status "Installing certbot..." | ||
sudo apt install software-properties-common -y | ||
sudo add-apt-repository universe -y | ||
sudo apt-get update -y | ||
sudo apt-get install certbot python3-certbot-nginx -y | ||
else | ||
echo "Skipping NGINX and Certbot installation." | ||
fi | ||
|
||
# Configure nginx | ||
|
||
print_status "Setting up NGINX configuration..." | ||
# Function to configure NGINX for a given environment | ||
|
||
# datastore.iati.cloud | ||
# Ask the user for the server name | ||
read -rp "What is the iati.cloud server name as defined in the DNS records (for example, datastore.iati.cloud)?: " server_name | ||
sudo cp ./scripts/setup/nginx_host_machine/iati.cloud "/etc/nginx/sites-available/iati-cloud" | ||
sudo sed -i "s/REPL_SERVER_NAME/$server_name/g" "/etc/nginx/sites-available/iati-cloud" | ||
read -p "Re-Enter your solr username: " username | ||
read -sp "Re-Enter your solr password: " password | ||
encoded_base64=$(echo -n "$username:$password" | base64) | ||
sudo sed -i "s/REPL_AUTH/$encoded_base64/g" "/etc/nginx/sites-available/iati-cloud" | ||
sudo ln -s "/etc/nginx/sites-available/iati-cloud" /etc/nginx/sites-enabled/ | ||
|
||
# flower | ||
sudo cp ./scripts/setup/nginx_host_machine/flower "/etc/nginx/sites-available/flower" | ||
sudo sed -i "s/REPL_SERVER_NAME/$server_name/g" "/etc/nginx/sites-available/flower" | ||
sudo ln -s "/etc/nginx/sites-available/flower" /etc/nginx/sites-enabled/ | ||
|
||
if ask_for_confirmation "Do you want to set up the redirect for iati.cloud -> datastore.iati.cloud?: "; then | ||
sudo cp ./scripts/setup/nginx_host_machine/iati.cloud-redirect "/etc/nginx/sites-available/iati-cloud-redirect" | ||
sudo ln -s "/etc/nginx/sites-available/iati-cloud-redirect" /etc/nginx/sites-enabled/ | ||
fi | ||
|
||
# Restart nginx | ||
print_status "Restarting NGINX..." | ||
sudo service nginx restart | ||
|
||
print_status "Setting up SSL certificates..." | ||
if ask_for_confirmation "Do you want to set up SSL certificates for your domains?"; then | ||
# Set up the ssl certificate, this will require some user input. | ||
echo "Setting up SSL certificates..." | ||
sudo certbot --nginx | ||
|
||
echo "Setting up cron job to renew SSL certificates..." | ||
# update crontab with `0 5 1 * * sudo certbot renew --preferred-challenges http-01` | ||
cron_command="0 5 1 * * sudo certbot renew --preferred-challenges http-01" | ||
temp_cron_file=$(mktemp) | ||
echo "$cron_command" > "$temp_cron_file" | ||
crontab "$temp_cron_file" | ||
rm "$temp_cron_file" | ||
fi | ||
|
||
print_status "Done installing NGINX." |
Oops, something went wrong.