Skip to content

Commit

Permalink
Merge pull request malkemit#32 from offline-pirate/master
Browse files Browse the repository at this point in the history
[feat, maintain](add some missed section to readme & wire a setup script):
  • Loading branch information
malkemit authored Dec 28, 2022
2 parents 78cd8ad + 3767973 commit 0db2a9b
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 10 deletions.
32 changes: 22 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

This project is used to remove the limitation of asymmetric ratio for uploading and downloading Iranian servers

## Installation
## One command installation

```bash
sudo curl https://raw.githubusercontent.com/malkemit/namizun/master/setup.sh | bash
```

## Manual installation

**Important Note : use it on ubuntu +20 (python +3.8)**

Expand All @@ -12,13 +18,19 @@ This project is used to remove the limitation of asymmetric ratio for uploading
sudo apt install python3-pip python3-venv redis git -y
```

- 2\) you need to create a directory to clone the project:
- 2\) start the redis service

```bash
sudo systemctl start redis.service
```

- 3\) you need to create a directory to clone the project:

```bash
mkdir -p /var/www/namizun && cd /var/www/namizun
```

- 3\) Clone the project with Git:
- 4\) Clone the project with Git:

```bash
git init
Expand All @@ -32,43 +44,43 @@ git remote add origin https://github.com/malkemit/namizun.git
git pull origin master
```

- 4\) make virtual environment:
- 5\) make virtual environment:

```bash
python3 -m venv /var/www/namizun/venv
```

- 5\) Install the project requirements with pip by **setup.py** (namizun_core & namizun_menu):
- 6\) Install the project requirements with pip by **setup.py** (namizun_core & namizun_menu):

```bash
cd /var/www/namizun && source /var/www/namizun/venv/bin/activate && pip install wheel && pip install namizun_core/ namizun_menu/ && deactivate
```

- 6\) Create service for uploader.py (for running namizun script):
- 7\) Create service for uploader.py (for running namizun script):

```bash
ln -s /var/www/namizun/else/namizun.service /etc/systemd/system/
```

- 7\) Reload the service files to include the new service:
- 8\) Reload the service files to include the new service:

```bash
sudo systemctl daemon-reload
```

- 8\) To enable your service on every reboot:
- 9\) To enable your service on every reboot:

```bash
sudo systemctl enable namizun.service
```

- 9\) Start namizun service:
- 10\) Start namizun service:

```bash
sudo systemctl start namizun.service
```

- 10\) Create **namizun** command to execute **menu.py**
- 11\) Create **namizun** command to execute **menu.py**

```bash
ln -s /var/www/namizun/else/namizun /usr/local/bin/ && chmod +x /usr/local/bin/namizun
Expand Down
79 changes: 79 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

echo 'installing prerequests'
apt update && apt install python3-pip python3-venv redis git -y
if [ $? == 0 ]
then
echo 'installing done'
else
echo 'something went wrong with installing'
exit
fi


echo 'start redis service'
systemctl start redis.service
if [ $? == 0 ]
then
echo 'redis servie started'
else
echo 'service starting failed'
exit
fi


echo 'pulling the repostory'
git clone https://github.com/offline-pirate/namizun.git /var/www/namizun
if [ $? != 0 ]
then
echo 'could not clone the repository'
exit
fi


echo 'create virtual env'
python3 -m venv /var/www/namizun/venv
if [ $? != 0 ]
then
echo 'venv didnt created'
fi


echo 'installing project dependencies'
cd /var/www/namizun && source /var/www/namizun/venv/bin/activate && pip install wheel && pip install namizun_core/ namizun_menu/ && deactivate
if [ $? != 0 ]
then
echo 'depencensies doesnt installed correctlly'
exit
fi

echo 'create service'
ln -s /var/www/namizun/else/namizun.service /etc/systemd/system/
if [ $? != 0 ]
then
echo 'creating service was failed'
exit
fi

## starging the services
systemctl daemon-reload


echo 'starting namizun service'
sudo systemctl enable namizun.service
sudo systemctl start namizun.service
if [ $? != 0 ]
then
echo 'service namizun didnt started'
exit
fi


echo 'make namizun as a command'
ln -s /var/www/namizun/else/namizun /usr/local/bin/ && chmod +x /usr/local/bin/namizun
if [ $? != 0 ]
then
echo 'failed to add namizun to PATH environment variables'
exit
fi

0 comments on commit 0db2a9b

Please sign in to comment.