martomi / chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.
MIT License
458 stars 120 forks source link

Install script doesn't work on non-debian distributions #279

Open Jacek-ghub opened 3 years ago

Jacek-ghub commented 3 years ago

Kind of a noob question.

I have just installed python 3.9.6 on CentOS 7, and am getting "Python 3.9.6" as a response to "python --version." I tried to run chiadog install.sh but got an error:

Chiadog requires Python 3.7+. Please update before proceeding with the installation

Do I need to drop the python version to 3.7?

martomi commented 3 years ago

Install script checks python3 --version and not python --version. You probably have older version under python3

Jacek-ghub commented 3 years ago

Thank you, I noticed that, and already fixed it, and got it working.

After installing p3.6.9, there was no python3 symlink created - only "python" still pointing to 2.7. So, I changed that symlink to point to the p3.9.6 binary, but I didn't initially create p3. Checking the install script, I added p3 symlink, and it started working. As I said, I am new to python, so I don't really know what is the proper installation, whether what I got is normal, or rather something went wrong.

As mentioned, I am on CentOS 7, as such the install.sh barfs on apt-get. RedHat derived OSes don't use that.

Also, that "sudo apt-get update" potentially should not be there. If that is the same as yum update on RedHat, it will force the user to update everything on the system, what may not be what the user is ready to do. I think that echoing those two lines and exiting the script would be a better idea. Another reason is that on RedHat you need to install libpython3-devel, as ...-dev is just for Debian based OSes.

And of course, dpkg also does not exist on RedHat based system.

I think that the install script should stick with its own code, not really be doing system level changes. I know it is tempting to do that, but you are just forcing your guesses against what the user decided to have. It is tempting, as it may be helping some people, but may cause issues for those that are for whatever reason not ready to do that. Just letting people know (echo) what needs to be done should be good enough (that note about wrong version helped me to fix the problem).

Also just noticed that "build-essential" looks like is not there under RedHat. Same for dpkg.

So, basically all those maintenance related lines are wrong if the OS is not Debian based.

martomi commented 3 years ago

These are very valid points, thanks for the feedback!

We should add explicit check for non-Debian based distributions and exit if we decide to keep the install script. And also ask user for confirmation before installing any missing dependencies.

sudo apt-get update should be harmless, it only updates the list of packages. Actual upgrade of the packages is performed with sudo apt-get upgrade which we do not invoke.

Jacek-ghub commented 3 years ago

On RedHat side, "yum update" will update the whole box. The metadata update is always done internally before proceeding to the installation/update/upgrade part. Of course, if you don't do "-y" switch, command will stop asking for it, but you will need to have a really good explanation what and why you want to update before anyone will confirm that (that is the main reason for me to separate that script into OS related, and ChiaDog related, although that split may be a bit fuzzy).

Also, yum is not the only option, or rather not default. On CentOS 7 it is rpm, on v8 I think is dnf.

Although, RedHat is killing CentOS for time being, so maybe that is not something worth pursuing.

Lastly, looking at python guides, gentoo looks like have yet another python installation, where potentially they always install devel part.

Since you already have install.sh, maybe update.sh would be also nice. Yeah, those are only four lines, but that is what exactly small and useful scripts are. Seeing that, the next person will help to make it for Windows, etc.

gurkburk76 commented 2 years ago

I have a similar issue on truenas running a jail. There is this nifty chia plugin there that runs in a jail and where i run a harvester. I thought i kinda made it work by running the stuff in install.sh that is able to run but i get errors when starting the dog so i guess not :) I belive truenas runs on freebsd.

Error: [root@san-chia-harvester ~/chiadog]# ./start.sh Traceback (most recent call last): File "main.py", line 13, in from src.chia_log.log_consumer import create_log_consumer_from_config File "/root/chiadog/src/chia_log/log_consumer.py", line 23, in import paramiko File "/root/chiadog/venv/lib/python3.8/site-packages/paramiko/init.py", line 22, in from paramiko.transport import SecurityOptions, Transport File "/root/chiadog/venv/lib/python3.8/site-packages/paramiko/transport.py", line 129, in class Transport(threading.Thread, ClosingContextManager): File "/root/chiadog/venv/lib/python3.8/site-packages/paramiko/transport.py", line 190, in Transport if KexCurve25519.is_available(): File "/root/chiadog/venv/lib/python3.8/site-packages/paramiko/kex_curve25519.py", line 30, in is_available X25519PrivateKey.generate() File "/root/chiadog/venv/lib/python3.8/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py", line 39, in generate from cryptography.hazmat.backends.openssl.backend import backend File "/root/chiadog/venv/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/init.py", line 6, in from cryptography.hazmat.backends.openssl.backend import backend File "/root/chiadog/venv/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 113, in from cryptography.hazmat.bindings.openssl import binding File "/root/chiadog/venv/lib/python3.8/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 14, in from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: /root/chiadog/venv/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: Undefined symbol "SSLv3_client_method"

Python 3.8.11

What i did to "manually" install it was:

Create virtual environment

python3 -m venv venv

Activate virtual environment

. ./venv/bin/activate

Update pip3 to latest version

python3 -m pip install --upgrade pip

Install dependencies

pip3 install wheel && pip3 install -r requirements.txt

Deactivate virtual environment

deactivate

and ./start.sh Error above.

Also, the reason i wanted to run the dog is that i've noticed that the harverster for some reason stops working, i know i can get notifications but could it alse be added as a feature that i actually restarts the harvester? Would save some time and effort.