1 # Installation Instructions
2 Note that these instructions are a work in progress and will change during the prototyping phase.
4 ## 1. Download the Project
6 Grab and extract a tarball or clone this repository into a convenient location,
7 e.g. `/opt/yt` (the rest of these instructions will assume this path).
12 ## 2. Install Virtual Environment
14 For the most part, it doesn't matter where you set up the virtual environment.
15 Here, it is created in `/opt/yt/venv`. You eill have to point the systemd unit
16 files/init scripts and app/common/utils.py to it.
20 pip3 install -r config/requirements.txt
25 Since we use jwz's `youtubedown`, we need Perl and two external modules.
27 dnf install perl perl-IO-Socket-SSL.noarch perl-HTML-Parser.x86_64
28 # apt-get install perl libio-socket-ssl-perl libhtml-parser-perl
32 Configuration is read from the `YT_CONFIG` environment variable, falling back
33 to `/etc/yt/config.ini`. You can keep the `config/` directory untouched to
34 avoid merge conflicts, and copy the relevant files to `/etc/yt`.
36 Carefully read and fill out `config/config.ini`. If you want to run the app
37 directly from gunicorn (as I do), the [Gunicorn configuration] file
38 (`gunicorn-frontend-config.py`) will need TLS certificate paths. You can ignore
39 `gunicorn-webhooks-config.py`, unless you want to run it standalone. Otherwise,
40 configure them to use a high port and reverse-proxy them through your real web
42 `gunicorn-frontend-config.py` uses eventlet workers, which require
43 `gunicorn[eventlet]` to be installed. If you want a synchronous worker, use
44 `gthread` instead. If you are using the in-memory requests-cache, do not use
45 more than 1 process, or the cache will be useless!
47 If you want to use the included systemd unit files, point `WorkingDirectory=`
48 to the location of the repository, `Environment=PATH=` to the location of the
49 virtualenv's `bin/` directory and `Environment=YT_CONFIG=` to your `config.ini`
50 (if you aren't using `/etc/yt/config.ini`), as well as the gunicorn config
51 path. Then copy them to `/etc/systemd/system/`.
53 **Do not start the frontend before the database and cronjobs are in place!**
56 cp config/subscriptions-frontend.service /etc/systemd/system
59 vi /etc/yt/gunicorn-frontend-config.py
60 vi /etc/systemd/system/subscriptions-frontend.service
62 systemctl daemon-reload
63 systemctl enable subscriptions-frontend.service
65 [Gunicorn configuration]: https://docs.gunicorn.org/en/stable/settings.html
67 ## 4. Create and Prepopulate SQLite Database
69 To create the database and tables, simply issue:
71 sqlite3 subscriptions.sqlite < config/setup.sql
73 Next, create a user for yourself:
76 PASSWD=$(./config/generate-passwd.py) # will ask
77 TOKEN=$(head -c16 </dev/urandom|base64|tr /+ _-|tr -d =)
78 echo "INSERT INTO users(name, password, token) VALUES ('$USERN','$PASSWD','$TOKEN')" |
79 sqlite3 subscriptions.sqlite
81 The homepage will show the guest user's subscription feed. As you cannot log in
82 as guest, you will have to populate this feed by INSERTing directly into the
83 datbase. The README's *Advanced Topics* section has information on this. Or you
84 can use the provided list:
86 sqlite3 subscriptions.sqlite < config/guest.sql
88 You can do the same for your own subscriptions, or use the *Subscription
89 Manager* in the footer of the main page to subscribe to channels manually.
91 ## 5. Set up Cron Jobs
93 Cronjobs live in app/common/utils.py, which is both a python script and an
94 executable shell script. When executed with `sh`, it will load the virtual
95 environment and launch itself with it.
97 Before starting the frontend, run them once. `cipher` is required to play music
98 videos; `pull` downloads a back catalog of subscriptions; `websub` will
99 register for automatic push-updated on new videos. (Note: export `YT_CONFIG` if
100 you don't use `/etc/yt/config`)
102 ./app/common/utils.py pull
103 ./app/common/utils.py websub
104 ./app/common/utils.py cipher
106 If all goes well, install them with `crontab -e`. Running `pull` and `cipher`
107 once per day is plenty; `websub` should run at least twice daily (both `pull`
108 and `websub` are idempotent; they won't do any additional work if ran multiple
112 # YT_CONFIG=/opt/yt/config/config.ini # optional
113 19 21 * * * $YT_DIR/app/common/utils.py pull
114 03 */4 * * * $YT_DIR/app/common/utils.py websub
115 52 02 * * * $YT_DIR/app/common/utils.py cipher
119 All set -- you can start the frontend now and relax.
121 systemctl start subscriptions-frontend.service