^
This commit is contained in:
parent
cb6b68184b
commit
a687e932f7
1 changed files with 71 additions and 50 deletions
121
deploy-saleor.sh
121
deploy-saleor.sh
|
@ -14,6 +14,7 @@ if [[ "$UN" != "root" ]]; then
|
||||||
else
|
else
|
||||||
HD="/root"
|
HD="/root"
|
||||||
fi
|
fi
|
||||||
|
cd $HD
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,6 +160,7 @@ sleep 3
|
||||||
# Kubernetes
|
# Kubernetes
|
||||||
# SUSE CaaS
|
# SUSE CaaS
|
||||||
echo "Installing core dependencies..."
|
echo "Installing core dependencies..."
|
||||||
|
sleep 1
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Debian)
|
Debian)
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
@ -200,9 +202,10 @@ esac
|
||||||
echo ""
|
echo ""
|
||||||
echo "Finished installing core dependencies"
|
echo "Finished installing core dependencies"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 3
|
sleep 2
|
||||||
echo "Setting up security feature details..."
|
echo "Setting up security feature details..."
|
||||||
echo ""
|
echo ""
|
||||||
|
sleep 2
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,9 +250,10 @@ PGSQLUSERPASS=$(cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 128 | head -n 1)
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
echo "Finished setting up security feature details"
|
echo "Finished setting up security feature details"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 1
|
sleep 2
|
||||||
echo "Creating database..."
|
echo "Creating database..."
|
||||||
echo ""
|
echo ""
|
||||||
|
sleep 2
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +275,7 @@ sudo -i -u postgres psql -c "CREATE DATABASE $PGSQLDBNAME;"
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
echo "Finished creating database"
|
echo "Finished creating database"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 3
|
sleep 2
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,6 +392,38 @@ sudo ufw allow $API_PORT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
# Create virtual environment directory
|
||||||
|
if [ ! -d "$HD/env" ]; then
|
||||||
|
sudo -u $UN mkdir $HD/env
|
||||||
|
wait
|
||||||
|
fi
|
||||||
|
# Does an old virtual environment for Saleor exist?
|
||||||
|
if [ ! -d "$HD/env/saleor" ]; then
|
||||||
|
# Create a new virtual environment for Saleor
|
||||||
|
sudo -u $UN python3 -m venv $HD/env/saleor
|
||||||
|
wait
|
||||||
|
fi
|
||||||
|
# Activate the virtual environment
|
||||||
|
sudo -u $UN source $HD/env/saleor/bin/activate
|
||||||
|
# Make sure pip is upgraded
|
||||||
|
sudo -u $UN python3 -m pip install --upgrade pip
|
||||||
|
wait
|
||||||
|
# Install Django
|
||||||
|
sudo -u $UN pip3 install Django
|
||||||
|
wait
|
||||||
|
# Create a Temporary directory to generate some files we need
|
||||||
|
#sudo -u $UN mkdir $HD/django
|
||||||
|
#cd django
|
||||||
|
# Create the project folder
|
||||||
|
#sudo -u $UN django-admin.py startproject saleor
|
||||||
|
# Install uwsgi
|
||||||
|
sudo -u $UN pip3 install uwsgi
|
||||||
|
wait
|
||||||
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# Clone the Saleor Git repository
|
# Clone the Saleor Git repository
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
@ -405,15 +441,15 @@ echo ""
|
||||||
# Check if the -v (version) option was used
|
# Check if the -v (version) option was used
|
||||||
if [ "$vOPT" = "true" ]; then
|
if [ "$vOPT" = "true" ]; then
|
||||||
# Get the Mirumee repo
|
# Get the Mirumee repo
|
||||||
git clone https://github.com/mirumee/saleor.git
|
sudo -u $UN git clone https://github.com/mirumee/saleor.git
|
||||||
else
|
else
|
||||||
# Was a repo specified?
|
# Was a repo specified?
|
||||||
if [ "$REPO" = "mirumee" ]; then
|
if [ "$REPO" = "mirumee" ]; then
|
||||||
# Get the Mirumee repo
|
# Get the Mirumee repo
|
||||||
git clone https://github.com/mirumee/saleor.git
|
sudo -u $UN git clone https://github.com/mirumee/saleor.git
|
||||||
else
|
else
|
||||||
# Get the Mirumee repo
|
# Get the Mirumee repo
|
||||||
git clone https://github.com/mirumee/saleor.git
|
sudo -u $UN git clone https://github.com/mirumee/saleor.git
|
||||||
|
|
||||||
###### For possible later use ######
|
###### For possible later use ######
|
||||||
# Get the forked repo from thewhiterabbit
|
# Get the forked repo from thewhiterabbit
|
||||||
|
@ -422,13 +458,20 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
wait
|
wait
|
||||||
|
#sudo -u $UN cp $HD/django/saleor/asgi.py $HD/saleor/saleor/
|
||||||
|
#sudo -u $UN cp $HD/django/saleor/wsgi.py $HD/saleor/saleor/
|
||||||
|
sudo -u $UN cp $HD/saleor/saleor/wsgi/__init__.py $HD/saleor/saleor/wsgi.py
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#########################################################################################
|
||||||
|
# Tell the user what's happening
|
||||||
|
#########################################################################################
|
||||||
echo "Github cloning complete"
|
echo "Github cloning complete"
|
||||||
echo ""
|
echo ""
|
||||||
|
sleep 2
|
||||||
|
#########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -557,74 +600,52 @@ sudo cp $HD/Deploy_Saleor/resources/saleor/uwsgi_params $HD/saleor/uwsgi_params
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# Install Saleor for production
|
# Install Saleor for production
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# Make sure we're in the project root directory for Saleor
|
|
||||||
cd $HD/saleor
|
|
||||||
# Was the -v (version) option used?
|
|
||||||
if [ "vOPT" = "true" ]; then
|
|
||||||
# Checkout the specified version
|
|
||||||
git checkout $VERSION
|
|
||||||
wait
|
|
||||||
fi
|
|
||||||
# Create vassals directory in virtual environment
|
|
||||||
if [ ! -d "$HD/env" ]; then
|
|
||||||
mkdir $HD/env
|
|
||||||
wait
|
|
||||||
fi
|
|
||||||
# Does an old virtual environment for Saleor exist?
|
|
||||||
if [ ! -d "$HD/env/saleor" ]; then
|
|
||||||
# Create a new virtual environment for Saleor
|
|
||||||
python3 -m venv $HD/env/saleor
|
|
||||||
wait
|
|
||||||
fi
|
|
||||||
# Does an old virtual environment vassals for Saleor exist?
|
# Does an old virtual environment vassals for Saleor exist?
|
||||||
if [ -d "$HD/env/saleor/vassals" ]; then
|
if [ -d "$HD/env/saleor/vassals" ]; then
|
||||||
sudo rm -R $HD/env/saleor/vassals
|
sudo rm -R $HD/env/saleor/vassals
|
||||||
wait
|
wait
|
||||||
fi
|
fi
|
||||||
# Create vassals directory in virtual environment
|
# Create vassals directory in virtual environment
|
||||||
mkdir $HD/env/saleor/vassals
|
sudo -u $UN mkdir $HD/env/saleor/vassals
|
||||||
wait
|
wait
|
||||||
# Simlink to the prod.ini
|
# Simlink to the prod.ini
|
||||||
sudo ln -s $HD/saleor/saleor/wsgi/prod.ini $HD/env/saleor/vassals
|
sudo ln -s $HD/saleor/saleor/wsgi/prod.ini $HD/env/saleor/vassals
|
||||||
wait
|
wait
|
||||||
# Activate the virtual environment
|
# Make sure we're in the project root directory for Saleor
|
||||||
source $HD/env/saleor/bin/activate
|
cd $HD/saleor
|
||||||
# Make sure pip is upgraded
|
# Was the -v (version) option used?
|
||||||
python3 -m pip install --upgrade pip
|
if [ "vOPT" = "true" || $VERSION != "" ]; then
|
||||||
wait
|
# Checkout the specified version
|
||||||
# Install Django
|
sudo -u $UN git checkout $VERSION
|
||||||
pip3 install Django
|
wait
|
||||||
wait
|
fi
|
||||||
# Install uwsgi
|
|
||||||
pip3 install uwsgi
|
|
||||||
wait
|
|
||||||
# Install the project requirements
|
# Install the project requirements
|
||||||
pip3 install -r requirements.txt
|
sudo -u $UN pip3 install -r requirements.txt
|
||||||
wait
|
wait
|
||||||
# Install the decoupler for .env file
|
# Install the decoupler for .env file
|
||||||
pip3 install python-decouple
|
sudo -u $UN pip3 install python-decouple
|
||||||
wait
|
wait
|
||||||
# Set any secret Environment Variables
|
# Set any secret Environment Variables
|
||||||
export ADMIN_PASS="$ADMIN_PASS"
|
sudo -u $UN export ADMIN_PASS="$ADMIN_PASS"
|
||||||
# Install the project
|
# Install the project
|
||||||
npm install
|
sudo -u $UN npm install
|
||||||
wait
|
wait
|
||||||
# Run an audit to fix any vulnerabilities
|
# Run an audit to fix any vulnerabilities
|
||||||
npm audit fix
|
#sudo -u $UN npm audit fix
|
||||||
wait
|
#wait
|
||||||
# Establish the database
|
# Establish the database
|
||||||
python3 manage.py migrate
|
sudo -u $UN python3 manage.py migrate
|
||||||
wait
|
wait
|
||||||
python3 manage.py populatedb --createsuperuser
|
sudo -u $UN python3 manage.py populatedb --createsuperuser
|
||||||
wait
|
wait
|
||||||
# Collect the static elemants
|
# Collect the static elemants
|
||||||
python3 manage.py collectstatic
|
sudo -u $UN python3 manage.py collectstatic
|
||||||
wait
|
wait
|
||||||
# Build the schema
|
# Build the schema
|
||||||
npm run build-schema
|
sudo -u $UN npm run build-schema
|
||||||
wait
|
wait
|
||||||
# Build the emails
|
# Build the emails
|
||||||
npm run build-emails
|
sudo -u $UN npm run build-emails
|
||||||
wait
|
wait
|
||||||
# Set ownership of the app directory to $UN:www-data
|
# Set ownership of the app directory to $UN:www-data
|
||||||
sudo chown -R $UN:www-data $HD/saleor
|
sudo chown -R $UN:www-data $HD/saleor
|
||||||
|
@ -635,7 +656,7 @@ wait
|
||||||
# Stop the uwsgi processes
|
# Stop the uwsgi processes
|
||||||
#uwsgi --stop $HD/saleortemp.pid
|
#uwsgi --stop $HD/saleortemp.pid
|
||||||
# Exit the virtual environment here? _#_
|
# Exit the virtual environment here? _#_
|
||||||
deactivate
|
sudo -u $UN deactivate
|
||||||
# Move static files to /var/www/$HOST
|
# Move static files to /var/www/$HOST
|
||||||
sudo mv $HD/saleor/saleor$STATIC_URL /var/www/${HOST}${STATIC_URL}
|
sudo mv $HD/saleor/saleor$STATIC_URL /var/www/${HOST}${STATIC_URL}
|
||||||
sudo chown -R www-data:www-data /var/www/$HOST
|
sudo chown -R www-data:www-data /var/www/$HOST
|
||||||
|
|
Loading…
Reference in a new issue