Skip to content

Commit

Permalink
feat: implement delete flow (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijna-Raghavendra authored Feb 17, 2024
2 parents 157ea38 + 0b438f0 commit 135730a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 4 additions & 2 deletions docs/admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ This step involves the configuration of three `.env` files:
PORT_FRONTEND=XXXX
```
- Backend env:
As suggested in the `.env.sample` present at the `src/backend` directory, create a file named `.env` and copy the contents as shown, replacing *"..."* with the respective values for your registered github oauth application's **GITHUB_OAUTH_CLIENT_ID** and **GITHUB_OAUTH_CLIENT_SECRET**. Fill in the **MONGO_API_KEY** and **MONGO_APP_ID** you obtain upon creating a cluster in *MongoDB Atlas*
As suggested in the `.env.sample` present at the `src/backend` directory, create a file named `.env` and copy the contents as shown, replacing *"..."* with the respective values for your registered github oauth application's **GITHUB_OAUTH_CLIENT_ID** and **GITHUB_OAUTH_CLIENT_SECRET**. Fill in the **MONGO_API_KEY** and **MONGO_APP_ID** you obtain upon creating a cluster in *MongoDB Atlas*. Also fill in **SENTRY_DSN**.
```
GITHUB_OAUTH_CLIENT_ID=...
GITHUB_OAUTH_CLIENT_SECRET=...
MONGO_API_KEY=...
MONGO_APP_ID=...
SENTRY_DSN=...
```
- Frontend env:
As suggested in the `.env.sample` present at the `src/frontend` directory, create a file named `.env` and copy the contents as shown, replacing *"..."* with the respective values for your registered github oauth application's **VITE_APP_GITHUB_OAUTH_CLIENT_ID** and **VITE_APP_GITHUB_OAUTH_CLIENT_SECRET**. For the **VITE_APP_GITHUB_OAUTH_REDIRECT_URL** enter the public url of the application's `/login` route. (Example: `http://df.mdgspace.org/login`). Also, add the port at which your backend is running in place of *"XXXX"*.
Expand All @@ -45,12 +46,13 @@ docker compose up --build -d

### 4. Setup Named Pipes

Create a pipe in the `docker/named_pipe` directory by executing `mkfifo docker/named_pipe/pipe`.
Navigate to the `docker/named_pipe` directory and execute the `listen.sh` script to allow the application to run commands on the host.
```bash
cd docker/named_pipe
./listen.sh
```
> Make sure to check the permissions of the `listen.sh` file. You can change them using the `chmod` command.
> Make sure to check the permissions of the `listen.sh` file. You can change them using the `chmod` command. You can also add this to `crontab` to execute script on reboot of your server.
### 5. Installing and Configuring NGINX

Expand Down
8 changes: 2 additions & 6 deletions src/backend/shell_scripts/automate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ fi
arg1=$1
arg2=$2
arg3=$3
host="mdgiitr"
http_upgrade="mdgiitr"
# Print the arguments
echo "Argument 1: $arg1"
echo "Argument 2: $arg2"
echo "Argument 3: $arg3"

if [ "$arg1" = "-u" ]; then
echo "Creating subdomain $arg3 which redirects to $arg2"
echo "Generating url.conf"
echo "url: $arg2"
sudo touch /etc/nginx/sites-available/$arg3.conf
Expand All @@ -45,6 +40,7 @@ if [ "$arg1" = "-u" ]; then
sudo ln -s /etc/nginx/sites-available/$arg3.conf /etc/nginx/sites-enabled/$arg3.conf;
sudo systemctl reload nginx;
elif [ "$arg1" = "-p" ]; then
echo "Creating subdomain $arg3 which redirects to port $2"
echo "Generating port.conf"
echo "redirect: $arg2"
sudo touch /etc/nginx/sites-available/$arg3.conf
Expand Down
6 changes: 4 additions & 2 deletions src/backend/shell_scripts/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ done
echo "Available ports: ${available_ports[56]}"
AVAILABLE=0
if [ $flag = "-g" ]; then
echo "Creating subdomain $name"
git clone $resource $name
sudo cp Dockerfile $name/
sudo cp .env $name/
cd $name
sudo docker build -t $name .
echo ${available_ports[$AVAILABLE]};
sudo docker run -d -p ${available_ports[$AVAILABLE]}:$exp_port $2
sudo docker run --name=$name -d -p ${available_ports[$AVAILABLE]}:$exp_port $2
cd ..
sudo rm -rf $name
sudo rm Dockerfile
Expand Down Expand Up @@ -56,6 +57,7 @@ if [ $flag = "-g" ]; then
sudo systemctl reload nginx

else
echo "Creating subdomain $name"
git clone $resource $name
sudo cp .env $name/
cd $name
Expand All @@ -64,7 +66,7 @@ else
COPY . /usr/share/nginx/html
" > Dockerfile
sudo docker build -t $name .
sudo docker run -d -p ${available_ports[$AVAILABLE]}:80 $name
sudo docker run --name=$name -d -p ${available_ports[$AVAILABLE]}:80 $name
cd ..
sudo rm .env
sudo rm -rf $name
Expand Down
7 changes: 4 additions & 3 deletions src/backend/shell_scripts/delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ id -u

# Assign the arguments to variables
arg1=$1
host="mdgiitr"
# Print the arguments
echo "Argument 1: $arg1"

echo "Deleting... $arg1"

sudo rm /etc/nginx/sites-available/$1.conf
sudo rm /etc/nginx/sites-enabled/$1.conf
sudo docker stop $1
sudo docker rm $1
sudo docker rmi $1

sudo systemctl reload nginx

0 comments on commit 135730a

Please sign in to comment.