Initial commit

This commit is contained in:
2024-07-13 00:53:45 +03:00
commit 00eabc8150
25 changed files with 870 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# Check if project_name argument is provided
if [ -z "$PROJECT_NAME" ]; then
echo "Error: PROJECT_NAME is not set."
exit 1
fi
project_name="$PROJECT_NAME"
# Create /var/www directory
mkdir -p /var/www
# Change group of /var/www directory to oleg20111511
chgrp oleg20111511 /var/www
# Change permissions of /var/www directory to 775
chmod 775 /var/www
# Create /var/www/logs/"project_name" directory
# mkdir -p "/var/www/logs/$project_name"
echo "Project setup complete."

View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Update package lists
sudo apt update
# Install Supervisor
sudo apt install supervisor -y
# Install Nginx
sudo apt install nginx -y
# Install redis
sudo apt install redis -y
# Install certbot
sudo apt install python3-certbot-nginx -y
# Install uWSGI and its dependencies
sudo apt install uwsgi build-essential python3-dev -y
# Install the Python 3 plugin for uWSGI
sudo apt install uwsgi-plugin-python3 -y

View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Check if username and password arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <username> <password>"
exit 1
fi
username=$1
password=$2
# Install PostgreSQL
sudo apt-get update
sudo apt-get install -y postgresql
# Create a new database named "jfl"
sudo -u postgres psql -c "CREATE DATABASE $username;"
# Create a user with provided username and password
sudo -u postgres psql -c "CREATE USER $username WITH PASSWORD '$password';"
# Grant all privileges on the "jfl" database to the user
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $username TO $username;"
# Grant permission to create and delete databases
sudo -u postgres psql -c "ALTER USER $username CREATEDB;"
echo "Database setup complete."

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Check if username and password arguments are provided
if [ -z "$PROJECT_NAME" ]; then
echo "Error: PROJECT_NAME is not set."
exit 1
fi
project_name=$PROJECT_NAME
ln -s /var/www/$project_name/deployment/$project_name-nginx.conf /etc/nginx/sites-enabled/$project_name-nginx.conf
ln -s /var/www/$project_name/deployment/$project_name-sv.conf /etc/supervisor/conf.d/$project_name-sv.conf
logs_dir="/var/www/logs"
project_logs_dir="$logs_dir/$project_name"
# Create /var/www/logs directory if it doesn't exist
if [ ! -d "$logs_dir" ]; then
sudo mkdir -p "$logs_dir"
sudo chown -R "$USER:$USER" "$logs_dir"
sudo chmod -R 755 "$logs_dir"
echo "Created directory $logs_dir"
fi
# Create /var/www/logs/$project_name directory if it doesn't exist
if [ ! -d "$project_logs_dir" ]; then
sudo mkdir -p "$project_logs_dir"
sudo chown -R "$USER:$USER" "$project_logs_dir"
sudo chmod -R 755 "$project_logs_dir"
echo "Created directory $project_logs_dir"
fi

View File

@@ -0,0 +1,43 @@
#!/bin/bash
# echo "export PROJECT_NAME=value" >> ~/.bashrc
# Check if project_name arugment is provided
# if [ $# -ne 1 ]; then
# echo "Usage: $0 <project_name>"
# exit 1
# fi
# project_name=$1
if [ -z "$PROJECT_NAME" ]; then
echo "Error: PROJECT_NAME is not set."
exit 1
fi
# Change to your desired directory
cd /var/www/$PROJECT_NAME
# Perform a git pull
git pull
git submodule init
git submodule update
# Activate virtual environment
source /var/www/venvs/$PROJECT_NAME/bin/activate
# Collect static files
python manage.py collectstatic --noinput
# Create database migrations
python manage.py makemigrations
# Apply database migrations
python manage.py migrate
# Restart supervisor processes
sudo supervisorctl restart $PROJECT_NAME
sudo supervisorctl restart "$PROJECT_NAME"_celery