Merge pull request #38 from th3r00t/development

Bring docker branch up to date with master, as pushed from version 0.5.0
This commit is contained in:
th3r00t
2020-05-12 16:14:56 -04:00
committed by GitHub
9 changed files with 125 additions and 39 deletions

6
.tern-config vendored Normal file
View File

@@ -0,0 +1,6 @@
{
“plugins”:
{
“node”: {}
}
}

80
README.md vendored
View File

@@ -1,20 +1,22 @@
# pyShelf 0.4.1
# pyShelf 0.5.0
<p align="center"><b>Terminal based ebook server. Open source & Lightweight.</b></p>
<p align="center">Having used Calibre for hosting my eBook collection in the past, I found myself frustrated having to install X on my server, or manage my library externally, Thus I have decided to spin up my own.</p>
<p align="center"><a href="https://pyshelf.com">https://pyshelf.com</a></p>
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D51ALZH)
![pyShelf 0.5.0 Collection 1](https://github.com/th3r00t/pyShelf/raw/development/preview_050.png)
![pyShelf 0.5.0 Collection 2](https://github.com/th3r00t/pyShelf/raw/development/preview_1_050.png)
Having used Calibre for hosting my eBook collection in the past, I found myself frustrated having to install X on my server, or manage my library externally, Thus I have decided to spin up my own.
### Join the discussion: Discord [https://discord.gg/H9TbNJS](https://discord.gg/H9TbNJS) | IRC freenode.net @ #pyshelf
<p align="center"><b>Discord [https://discord.gg/H9TbNJS](https://discord.gg/H9TbNJS) | IRC freenode.net @ #pyshelf</b></p>
## Current Features
* Custom Installer
* Custom Installer -- pre-req installs work on Arch Based Distros Only
* Recursive Scanning
* Fast database access
* Django based frontend
* Basic seaching via a SearchVector of author, title, & file_name fields.
* Ebook Downloading
* Collections
## Currently Supported Formats
* epub
@@ -25,22 +27,39 @@ Having used Calibre for hosting my eBook collection in the past, I found myself
## Further Installation & Support Information
* [SUPPORT.md](https://github.com/th3r00t/pyShelf/blob/development/.github/SUPPORT.md)
## 0.4.1 Patch Notes.
### Filename detection
Now using os.path.splitext to ensure proper formating of downloaded files
## 0.5.0 Patch Notes.
## 0.4.0 Patch Notes.
### The Installer Initiative
### Pre-req Dependencies
* gcc -- This will be installed by the new pre-installer script if its binary is not detected at /usr/bin/gcc
Users on distros other then Arch should install gcc via their systems package manager prior to
running the installer.
* Python3
* pip
### New Features
* Collections
We are now categorizing your ebooks into collections based on the folder
structure used to store them. Any folder after the root book folder is now
considered as a collection.
#### books/forgotten realms/ -> Forgotten Realms Collection.
#### books/Dune/Prelude To Dune -> Dune, & Preluse To Dune Collections.
All work this time around was centered on creating an installer simple and inclusive enough to hopefully enable all
users to simply set it and forget it. I have debugged as much as I can with my setup. I am performing some simple file finding to determine which system installer is present, and setting it as the installer used by pyShelf.
In addition to the work on the collection system, a good deal of time was spent
on the installer, and the concept of having an installer in the first place.
This setup has been tested and is working flawlessly on arch based distros, and i have done what I can for debian, and centos based distros, If you do encounter installer issues please let me know if it isnt finding the system installer, or possibly isnt passing command line arguments to your installer.
I mainly wanted to make this project for Network Administrators, and other home
enthusiasts whom I assume will know how to setup a Django app, and a
Postgres server. Beyond that theres nothing the user has to do to make the
system work...
Also it should be noted that I am determining the presence of your postgresql, and nginx servers based on whether or not the
process is listed in the process list.
The installer will only run correctly on arch based distros. This could be
easily rectified to include other package managers, Members of the community
are welcome to dig into the installer source and patch in support
for other package managers.
At this time I would suggest stopping both your postgresql and nginx servers should you already have them and allowing the installer to do its work generating custom configurations and putting the nginx config files in place (/etc/nginx/sites-available, and symlinked to /etc/nginx/sites-enabled/) None of your existing configurations will be overwritten.
There is some support for detection of the aptitude package manager
installation already present in the source now, however it is not complete and
should not be relied upon to be present in future releases unless completed by
a member of the community,
## Development
@@ -59,15 +78,24 @@ All configuration is now handled by the installer.
Running via the Django test server might be possible, albeit not recomended.
## In Progress
### In Progress
* Organizational tools.
* Docker image for those who need it.
* Improved cover image storage, and acquisition.
#### Organizational tools.
- [x] Automated Collections
- [ ] Manual Collections
- [ ] Books Removal
- [ ] Access Restrictions
- [ ] Metadata Manipulation
- [ ] Others?
#### Improved cover image storage, and acquisition.
#### OPDS Support
#### Support for other formats
- [ ] .mobi
- [ ] .pdf
- [ ] .cbz
- [ ] .zip (Zipped book folders, is this a new idea? (Consider storing your library folders zipped and retrieving a book on demand))
## Future Goals
* Support for other book formats (Currently only supporting EPUBS)
* Terminal Backend for catalogue maintenance
* Calculate page count from total characters
### Future Goals
#### Terminal Backend for catalogue maintenance
#### Calculate page count from total characters
* (Thanks to @Fireblend for the idea) https://github.com/th3r00t/pyShelf/issues/3
* Reader for easy integration with your catalogue

2
install.sh vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
eval python3 preinstall
eval "pip install -r requirements.txt"
eval python3 installer

33
installer vendored
View File

@@ -227,16 +227,15 @@ for key in install_answers:
config["USER"] = "pyshelf"
# Write configuration
Configuration().write_file(config)
# Start checking for our list of required services
service_list = ["postgres", "nginx", "httpd", "test"]
service_list = ["postgres", "nginx", "httpd"]
req = RequiredServices().check_ps(service_list)
# Does user have either nginx || apache?
if RequiredServices().web_server_found(req) is False:
web_prompt = [
{
"message": " You must have either apache or nginx\n would you like us to try and install nginx now? > ",
"message": " You must have either apache or nginx\n would you like \
us to try and install nginx now? Enter for default 'no' > ",
"options": "nginx",
"name": "NGINX",
"answer": None,
@@ -275,7 +274,8 @@ if RequiredServices().web_server_found(req) is False:
if RequiredServices().db_server_found(req) is False:
db_prompt = [
{
"message": " You must have PostgreSQL\n would you like us to try and install it now? > ",
"message": " You must have PostgreSQL\n would you like us to try \
and install it now? Enter for default 'no' > ",
"options": "postgres",
"name": "postgresql",
"answer": None,
@@ -308,7 +308,8 @@ if RequiredServices().db_server_found(req) is False:
sql_user = "pyshelf"
db_name = "pyshelf"
psql_cmd = (
"CREATE DATABASE %s; CREATE USER %s WITH PASSWORD '%s'; GRANT ALL PRIVILEGES ON DATABASE %s TO %s;"
"CREATE DATABASE %s; CREATE USER %s WITH PASSWORD '%s'; \
GRANT ALL PRIVILEGES ON DATABASE %s TO %s;"
% (db_name, sql_user, sql_pass, db_name, sql_user)
)
_sql_file = "/tmp/create_db.sql"
@@ -316,7 +317,8 @@ if RequiredServices().db_server_found(req) is False:
sql_file_open.write(psql_cmd)
sql_file_open.close()
os.system(
"sudo -u postgres initdb --locale=en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data"
"sudo -u postgres initdb --locale=en_US.UTF-8 -E UTF8 \
-D /var/lib/postgres/data"
)
os.system("sudo systemctl start postgresql")
os.system("sudo -u postgres psql -f %s" % _sql_file)
@@ -330,6 +332,23 @@ if RequiredServices().db_server_found(req) is False:
"pyShelf database and user created",
psql_cmd,
]
else:
psql_cmd = (
"CREATE DATABASE %s; CREATE USER %s WITH PASSWORD '%s'; \
GRANT ALL PRIVILEGES ON DATABASE %s TO %s;"
% (db_name, sql_user, sql_pass, db_name, sql_user)
)
_sql_file = "/tmp/create_db.sql"
with open(_sql_file, "w") as sql_file_open:
sql_file_open.write(psql_cmd)
sql_file_open.close()
os.system("sudo systemctl start postgresql")
os.system("sudo -u postgres psql -f %s" % _sql_file)
# os.system("sudo -u postgres psql -c \'%s\'"%psql_cmd)
messages = messages + [
"pyShelf database and user created",
psql_cmd,
]
# Post install configurations
sysinstall.make_nginx_config(install_answers)

33
preinstall vendored Executable file
View File

@@ -0,0 +1,33 @@
#!python
import os
from subprocess import run
class RequiredPackages:
def __init__(self, bins):
self.required = bins
self.to_be_installed = []
self.locate()
def locate(self):
for bin in self.required:
if os.path.isfile(bin[1]):
continue
else:
self.to_be_installed.append(bin[0])
return self.to_be_installed
# Package List
package_list = [["gcc", "/usr/bin/gcc"]]
packages, required_packages = "", RequiredPackages(package_list)
for package in required_packages.to_be_installed:
packages = packages + package + " "
try:
ret = run(["sudo", "pacman", "-S", packages[0:-1]])
print(ret)
except Exception as e:
ret = run(["pacman", "-S", packages[0:-1]])
print(ret)

BIN
preview_050.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
preview_1_050.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

5
requirements.txt vendored
View File

@@ -16,7 +16,4 @@ django-debug-toolbar
psycopg2-binary
prompt_toolkit
psutil
pyfiglet
psycopg2-binary
gunicorn
pudb
pyfiglet

View File

@@ -11,7 +11,10 @@ class TerminalDisplay:
self.term = True
self.w, self.y = os.get_terminal_size()[0], os.get_terminal_size()[1]
self.home = os.environ["HOME"]
self.user = os.environ["USER"]
try:
self.user = os.environ["USER"]
except KeyError:
self.user = None
self.version = "0.4.0"
self.slogan = "The Installer Initiative"
self.green = "\033[1;32m"