# 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.](https://github.com/justinmayer/virtualfish) ``` $ 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 ``` ## 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`](https://manpages.debian.org/stretch/libpam-systemd/pam_systemd.8.en.html) and [`logind.conf`](https://manpages.debian.org/stretch/systemd/logind.conf.5.en.html). ``` [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 ```