1
mirror of https://git.sr.ht/~cadence/tube-docs synced 2025-10-27 11:49:12 +00:00
tube-docs/docs/Installing NewLeaf.md
2021-02-27 15:18:59 +13:00

2.3 KiB

Installing NewLeaf

System dependencies

  • python3 (v3.7+ ?)
  • python3-venv

Prepare

We suggest you create a new user to run NewLeaf as, for security reasons.

# adduser cloudtube
# su cloudtube

Installing

Clone the repo:

$ git clone https://git.sr.ht/~cadence/NewLeaf
$ cd NewLeaf

Create a Python virtual environment, for separating dependencies:

Note: /bin/activate only works with the bash shell. See here for fish shell.

$ python3 -m venv newleaf-venv
$ source newleaf-venv/bin/activate

Install dependencies:

$ pip3 install -r requirements.txt

Set up the configuration. Configuration is read from the filename configuration.py. Copy the sample file to that name, then edit it.

$ cp configuration.sample.py configuration.py
$ $EDITOR configuration.py

All done! Start NewLeaf:

$ python3 index.py

In the future, from a new terminal session, NewLeaf can be started with:

$ cd [installation directory]
$ source newleaf-venv/bin/activate
$ python3 index.py

Updating

$ cd [installation directory]
$ source newleaf-venv/bin/activate
$ git pull
$ pip3 install -r requirements.txt

Then start:

$ python3 index.py

systemd service

If you want to control the services with systemd, you can use these files. This is optional.

This service should be run as the cloudtube user rather than as the system.

You may need to adjust the paths in these files.

If you find that these processes terminate when you log out, see the documentation for libpam-systemd and logind.conf.

[Unit]
Description=NewLeaf

[Service]
Type=simple
ExecStart=/usr/local/bin/python3 /home/cloudtube/NewLeaf/index.py
WorkingDirectory=/home/cloudtube/NewLeaf

# Restart timing
Restart=always
RestartSec=60

# Disable logs
StandardOutput=null
StandardError=null
SyslogIdentifier=newleaf

[Install]
WantedBy=multi-user.target

As above, save it to ~/.config/systemd/user/newleaf.service, then issue these commands:

$ systemctl daemon-reload
$ systemctl start newleaf

...and if all is successful...

$ systemctl enable newleaf