adding base-install.sh and boot.sh (#92)
Adding the following files in order to create the AWS AMI * boot.sh * base-install.sh * configure-ssl.sh file to run to modify app.conf file of nginx and to run init-letsencrypt.sh which generate SSL certificate. Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com>
This commit is contained in:
parent
30b8d3581b
commit
391347224d
58
deploy/aws/base-install.sh
Executable file
58
deploy/aws/base-install.sh
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
if [[ $EUID > 0 ]]; then
|
||||
echo "Please run with sudo." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_package() {
|
||||
sudo apt-get -y update --quiet
|
||||
sudo apt-get install -y ntp bc python3-pip --quiet
|
||||
pip3 install boto3
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common virtualenv python3-setuptools --quiet
|
||||
|
||||
# Installing docker
|
||||
sudo apt-get -y --quiet install gnupg-agent
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
sudo add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
sudo apt-get -y update --quiet
|
||||
sudo apt-get -y install docker-ce docker-ce-cli containerd.io --quiet
|
||||
|
||||
# Installing docker compose
|
||||
if [ ! -f /usr/bin/docker-compose ];then
|
||||
echo "Installing docker-compose"
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
install_package
|
||||
|
||||
#Download boot.sh and schedule at boot time.
|
||||
app_path="/home/ubuntu/appsmith"
|
||||
script_path="script"
|
||||
boot_script_path=$app_path/$script_path
|
||||
boot_file_name="boot.sh"
|
||||
config_ssl_file_name="configure-ssl.sh"
|
||||
mkdir -p $boot_script_path
|
||||
sudo chown -R ubuntu:ubuntu $app_path
|
||||
cd $boot_script_path
|
||||
|
||||
sudo curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/configure-ssl.sh
|
||||
sudo chown ubuntu:ubuntu $boot_script_path/$config_ssl_file_name && sudo chmod +x $boot_script_path/$config_ssl_file_name
|
||||
|
||||
sudo curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/feature/deploy-script/deploy/aws/boot.sh
|
||||
sudo chown ubuntu:ubuntu $boot_script_path/$boot_file_name && sudo chmod +x $boot_script_path/$boot_file_name
|
||||
|
||||
USER="ubuntu"
|
||||
CRON_FILE="/var/spool/cron/crontabs/$USER"
|
||||
echo "@reboot /bin/bash $boot_script_path/$boot_file_name" >> $CRON_FILE
|
||||
sudo chmod 0600 $CRON_FILE
|
||||
96
deploy/aws/boot.sh
Executable file
96
deploy/aws/boot.sh
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
# Check if Lock File exists, if not create it and set trap on exit
|
||||
if { set -C; 2>/dev/null >/home/ubuntu/.appsmith.lock; }; then
|
||||
trap "rm -f /home/ubuntu/.appsmith.lock" EXIT
|
||||
else
|
||||
exit
|
||||
fi
|
||||
|
||||
start_docker() {
|
||||
if [ `sudo systemctl is-active docker.service` == "inactive" ];then
|
||||
echo "Starting docker"
|
||||
sudo systemctl start docker.service
|
||||
fi
|
||||
}
|
||||
|
||||
# generate random string
|
||||
generate_random_string() {
|
||||
value=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1`
|
||||
echo $value
|
||||
}
|
||||
|
||||
start_docker
|
||||
|
||||
install_dir="/home/ubuntu/appsmith"
|
||||
|
||||
if [ ! -d $install_dir ];then
|
||||
mkdir -p $install_dir
|
||||
fi
|
||||
chown -R ubuntu:ubuntu $install_dir
|
||||
|
||||
mongo_host="mongo"
|
||||
mongo_database="appsmith"
|
||||
mongo_root_user=$( generate_random_string )
|
||||
mongo_root_password=$( generate_random_string )
|
||||
user_encryption_password=$( generate_random_string )
|
||||
user_encryption_salt=$( generate_random_string )
|
||||
|
||||
custom_domain=""
|
||||
NGINX_SSL_CMNT=""
|
||||
if [[ -z $custom_domain ]]; then
|
||||
NGINX_SSL_CMNT="#"
|
||||
fi
|
||||
|
||||
script_dir="/script"
|
||||
mkdir -p "$install_dir/$script_dir"
|
||||
chown -R ubuntu:ubuntu "$install_dir/$script_dir"
|
||||
|
||||
cd $install_dir/$script_dir
|
||||
mkdir -p template
|
||||
cd template
|
||||
echo $PWD
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/docker-compose.yml.sh
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/init-letsencrypt.sh.sh
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/mongo-init.js.sh
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/docker.env.sh
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/nginx_app.conf.sh
|
||||
curl -O https://raw.githubusercontent.com/appsmithorg/appsmith/release/deploy/template/encryption.env.sh
|
||||
cd ..
|
||||
echo $PWD
|
||||
|
||||
# Role - Folder
|
||||
for directory_name in nginx certbot mongo/db opa/config
|
||||
do
|
||||
if [[ ! -d "$install_dir/data/$directory_name" ]];then
|
||||
mkdir -p "$install_dir/data/$directory_name"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Generating the configuration files from the templates"
|
||||
. ./template/nginx_app.conf.sh
|
||||
. ./template/docker-compose.yml.sh
|
||||
. ./template/mongo-init.js.sh
|
||||
. ./template/docker.env.sh
|
||||
. ./template/encryption.env.sh
|
||||
|
||||
declare -A fileInfo
|
||||
|
||||
fileInfo[/data/nginx/app.conf.template]="nginx_app.conf"
|
||||
fileInfo[/docker-compose.yml]="docker-compose.yml"
|
||||
fileInfo[/data/mongo/init.js]="mongo-init.js"
|
||||
fileInfo[/docker.env]="docker.env"
|
||||
fileInfo[/encryption.env]="encryption.env"
|
||||
|
||||
for f in ${!fileInfo[@]}
|
||||
do
|
||||
mv -f ${fileInfo[$f]} $install_dir/$f
|
||||
done
|
||||
|
||||
cd $install_dir
|
||||
echo "Pull Images: $PWD"
|
||||
sudo docker-compose pull
|
||||
|
||||
echo "docker compose $PWD"
|
||||
sudo docker-compose -f docker-compose.yml up -d --remove-orphans
|
||||
19
deploy/aws/configure-ssl.sh
Executable file
19
deploy/aws/configure-ssl.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
set -o errexit
|
||||
|
||||
read -p 'Enter your domain / subdomain name (example.com / app.example.com): ' custom_domain
|
||||
|
||||
NGINX_SSL_CMNT=""
|
||||
install_dir="/home/ubuntu/appsmith"
|
||||
TEMPLATE_PATH="$install_dir/script/template"
|
||||
|
||||
. $TEMPLATE_PATH/nginx_app.conf.sh
|
||||
. $TEMPLATE_PATH/init-letsencrypt.sh.sh
|
||||
|
||||
chmod 0755 init-letsencrypt.sh
|
||||
|
||||
mv -f app.conf $install_dir/data/nginx/app.conf
|
||||
mv -f init-letsencrypt.sh $install_dir/init-letsencrypt.sh
|
||||
|
||||
cd $install_dir
|
||||
sudo ./init-letsencrypt.sh
|
||||
|
|
@ -4,7 +4,7 @@ if [ ! -f docker-compose.yml ]; then
|
|||
touch docker-compose.yml
|
||||
fi
|
||||
|
||||
cat > docker-compose.yml << EOF
|
||||
cat >| docker-compose.yml << EOF
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if [ ! -f docker-compose.yml ]; then
|
|||
touch docker-compose.yml
|
||||
fi
|
||||
|
||||
cat > docker.env << EOF
|
||||
cat >| docker.env << EOF
|
||||
# Read our documentation on how to configure these features
|
||||
# https://docs.appsmith.com/v/v1.1/enabling-3p-services
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if [ ! -f encryption.env ]; then
|
|||
touch encryption.env
|
||||
fi
|
||||
|
||||
cat > encryption.env << EOF
|
||||
cat >| encryption.env << EOF
|
||||
APPSMITH_ENCRYPTION_PASSWORD=$user_encryption_password
|
||||
APPSMITH_ENCRYPTION_SALT=$user_encryption_salt
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ fi
|
|||
|
||||
|
||||
|
||||
cat > init-letsencrypt.sh << EOF
|
||||
cat >| init-letsencrypt.sh << EOF
|
||||
#!/bin/bash
|
||||
|
||||
if ! [ -x "\$(command -v docker-compose)" ]; then
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ fi
|
|||
|
||||
|
||||
|
||||
cat > mongo-init.js << EOF
|
||||
cat >| mongo-init.js << EOF
|
||||
let error = false
|
||||
print("**** Going to start Mongo seed ****")
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ $NGINX_SSL_CMNT proxy_pass http://appsmith-internal-server:8080;
|
|||
$NGINX_SSL_CMNT }
|
||||
$NGINX_SSL_CMNT
|
||||
$NGINX_SSL_CMNT }
|
||||
' > nginx_app.conf
|
||||
' >| nginx_app.conf
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s/\$NGINX_SSL_CMNT/$NGINX_SSL_CMNT/g" nginx_app.conf
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user