mirror of
https://github.com/sb745/NyaaV3.git
synced 2025-11-02 00:45:46 +02:00
Bittorrent software for cats, now updated
SRI means that there's a lesser risk for XSS, and CDNJS itself recommends always requesting them over HTTPS in their "About" page. This closes #133 |
||
|---|---|---|
| .github | ||
| configs | ||
| nyaa | ||
| torrent_cache | ||
| utils | ||
| .gitignore | ||
| config.example.py | ||
| create_es.sh | ||
| db_create.py | ||
| es_mapping.yml | ||
| import_to_es.py | ||
| LICENSE | ||
| lint.sh | ||
| README.md | ||
| requirements.txt | ||
| run.py | ||
| sync_es.py | ||
| trackers.txt | ||
| uwsgi.ini | ||
| WSGI.py | ||
NyaaV2
Setup:
- Create your virtualenv, for example with
pyvenv venv - Enter your virtualenv with
source venv/bin/activate - Install dependencies with
pip install -r requirements.txt - Run
python db_create.pyto create the database - Start the dev server with
python run.py
Updated Setup (python 3.6.1):
- Install dependencies https://github.com/pyenv/pyenv/wiki/Common-build-problems
- Install
pyenvhttps://github.com/pyenv/pyenv/blob/master/README.md#installation - Install
pyenv-virtualenvhttps://github.com/pyenv/pyenv-virtualenv/blob/master/README.md pyenv install 3.6.1pyenv virtualenv 3.6.1 nyaapyenv activate nyaa- Install dependencies with
pip install -r requirements.txt - Copy
config.example.pyintoconfig.py - Change TABLE_PREFIX to
nyaa_orsukebei_depending on the site
Setting up MySQL/MariaDB database for advanced functionality
- Enable
USE_MYSQLflag in config.py - Install latest mariadb by following instructions here https://downloads.mariadb.org/mariadb/repositories/
- Tested versions:
mysql Ver 15.1 Distrib 10.0.30-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
- Tested versions:
- Run the following commands logged in as your root db user:
CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123';GRANT ALL PRIVILEGES ON * . * TO 'test'@'localhost';FLUSH PRIVILEGES;CREATE DATABASE nyaav2 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
- To setup and import nyaa_maria_vx.sql:
mysql -u <user> -p nyaav2DROP DATABASE nyaav2;CREATE DATABASE nyaav2 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;SOURCE ~/path/to/database/nyaa_maria_vx.sql
Finishing up
- Run
python db_create.pyto create the database - Load the .sql file
mysql -u user -p nyaav2SOURCE cocks.sql- Remember to change the default user password to an empty string to disable logging in
- Start the dev server with
python run.py - Deactivate
source deactivate
Enabling ElasticSearch
Basics
- Install jdk
sudo apt-get install openjdk-8-jdk - Install elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
sudo systemctl enable elasticsearch.servicesudo systemctl start elasticsearch.service- Run
curl -XGET 'localhost:9200'and make sure ES is running - Optional: install Kabana as a search frontend for ES
Enable MySQL Binlogging
- Add the
[mariadb]bin-log section to my.cnf and reload mysql server - Connect to mysql
SHOW VARIABLES LIKE 'binlog_format';- Make sure it shows ROW
- Connect to root user
GRANT REPLICATION SLAVE ON *.* TO 'test'@'localhost';where test is the user you will be runningsync_es.pywith
Setting up ES
- Run
./create_es.shand this creates two indicies:nyaaandsukebei - The output should show
acknowledged: truetwice - The safest bet is to disable the webapp here to ensure there's no database writes
- Run
python import_to_es.pywithSITE_FLAVORset tonyaa - Run
python import_to_es.pywithSITE_FLAVORset tosukebei - These will take some time to run as it's indexing
Setting up sync_es.py
- Sync_es.py keeps the ElasticSearch index updated by reading the BinLog
- Configure the MySQL options with the user where you granted the REPLICATION permissions
- Connect to MySQL, run
SHOW MASTER STATUS;. - Copy the output to
/var/lib/sync_es_position.jsonwith the contents{"log_file": "FILE", "log_pos": POSITION}and replace FILENAME with File (something like master1-bin.000002) in the SQL output and POSITION (something like 892528513) with Position - Set up
sync_es.pyas a service and run it, preferably as the system/root - Make sure
sync_es.pyruns within venv with the right dependencies
Good to go!
- After that, enable the
USE_ELASTIC_SEARCHflag and restart the webapp and you're good to go
Code Quality:
- Remember to follow PEP8 style guidelines and run
./lint.shbefore committing.