ToeiRei / crowdsec-overlay

Gentoo Overlay providing (some) crowdsec ebuilds
GNU General Public License v2.0
6 stars 2 forks source link

Missing config files on emerge #6

Closed g00g1 closed 1 year ago

g00g1 commented 1 year ago

After installing crowdsec from this overlay, it could not run due to some files or directories missing. I have created them manually but even after this crowdsec refuses to start with the following error message: time="20-05-2023 00:11:04" level=fatal msg="starting outputs error : authenticate watcher (localhost): API error: ent: machine not found".

Thanks beforehand.

ToeiRei commented 1 year ago

Which files or directories were missing? Please be more specific about your upgrade.

g00g1 commented 1 year ago

@ToeiRei, when installing on a fresh system (without crowdsec previously installed) it looks like following:

sudo eselect repository add crowdsec-overlay git https://github.com/ToeiRei/crowdsec-overlay
sudo emaint sync -r crowdsec-overlay
echo "net-analyzer/crowdsec ~amd64" | sudo tee -a /etc/portage/package.accept_keywords/crowdsec
sudo emerge net-analyzer/crowdsec
sudo rc-service crowdsec start
 * Caching service dependencies ...                                                                                                                                                   [ ok ]
 * Starting crowdsec ...
time="20-05-2023 11:11:15" level=fatal msg="while checking acquisition_path: stat /etc/crowdsec/acquis.yaml: no such file or directory"
 * start-stop-daemon: failed to start `/usr/bin/crowdsec'
 * Failed to start crowdsec                                                                                                                                                           [ !! ]
 * ERROR: crowdsec failed to start
ToeiRei commented 1 year ago

Now this is something I can work with.

ToeiRei commented 1 year ago

please test and report back.

g00g1 commented 1 year ago

It goes way further... And this list is not comprehensive, I remember that after setting up local_api_credentials there is central_api_credentials (or something similar), something at /var/lib/crowdsec and yet I am not sure if this is a full list.

➜  ~ sudo rc-service crowdsec start      
 * Caching service dependencies ...                                                                                                                                                   [ ok ]
 * Starting crowdsec ...
time="20-05-2023 11:25:57" level=fatal msg="loading api client: while reading yaml file: open /etc/crowdsec/local_api_credentials.yaml: no such file or directory"
 * start-stop-daemon: failed to start `/usr/bin/crowdsec'
 * Failed to start crowdsec                                                                                                                                                           [ !! ]
 * ERROR: crowdsec failed to start
➜  ~ sudo touch /etc/crowdsec/local_api_credentials.yaml 
➜  ~ sudo rc-service crowdsec start                     
 * Starting crowdsec ...
time="20-05-2023 11:26:32" level=fatal msg="loading api client: no credentials or URL found in api client configuration '/etc/crowdsec/local_api_credentials.yaml'"
 * start-stop-daemon: failed to start `/usr/bin/crowdsec'
 * Failed to start crowdsec                                                                                                                                                           [ !! ]
 * ERROR: crowdsec failed to start
ToeiRei commented 1 year ago

let's move that over to the crowdsec discord for fixing this quickly. Updated the ebuild accordingly

g00g1 commented 1 year ago

let's move that over to the crowdsec discord for fixing this quickly. Updated the ebuild accordingly

Sorry, but I am unable to use Discord due to constantly getting bans for "ToS violation".

I have emerged new ebuild, still have issues:

➜  ~ sudo rc-service crowdsec start
 * Caching service dependencies ...                                                                                                                                                   [ ok ]
 * Starting crowdsec ...
time="20-05-2023 11:38:45" level=fatal msg="unable to create database client: failed to create SQLite database file \"/var/lib/crowdsec/data/crowdsec.db\": open /var/lib/crowdsec/data/crowdsec.db: no such file or directory"
 * start-stop-daemon: failed to start `/usr/bin/crowdsec'
 * Failed to start crowdsec                                                                                                                                                           [ !! ]
 * ERROR: crowdsec failed to start
ToeiRei commented 1 year ago

did you run wizard.sh as that should take care of some things?

g00g1 commented 1 year ago

did you run wizard.sh as that should take care of some things?

No. As I have said in the first message, I am trying to install crowdsec from an overlay on a fresh machine without previously installing crowdsec by hands.

I have already installed crowdsec on another Gentoo machine using ./wizard.sh --unattended but for this scenario I do not need any overlay at all.

ToeiRei commented 1 year ago

./wizard.sh is still something that the ebuild cannot run for you as it does some initial configs.

g00g1 commented 1 year ago

./wizard.sh is still something that the ebuild cannot run for you as it does some initial configs.

When I will have enough spare time I will try to port wizard.sh to ebuild. Otherwise I don't see any reason to use overlays.

ToeiRei commented 1 year ago

feel free to send a pull request then.

ToeiRei commented 1 year ago

From the documentation:

The wizard is going to guide you through the following steps :

  • detect services that are present on your machine
  • detect selected services logs
  • suggest collections (parsers and scenarios) to deploy
  • deploy & configure CrowdSec in order to watch selected logs for selected scenarios
g00g1 commented 1 year ago

I think those are optional, especially for Gentoo users (obviously they have enough experience to read the documentation and manually tweak configuration files for themselves):

  • detect services that are present on your machine

  • detect selected services logs

  • suggest collections (parsers and scenarios) to deploy

ToeiRei commented 1 year ago

if you feel like working without a baseline config, feel free to do so.

ToeiRei commented 1 year ago

I have emerged new ebuild, still have issues:

➜  ~ sudo rc-service crowdsec start
 * Caching service dependencies ...                                                                                                                                                   [ ok ]
 * Starting crowdsec ...
time="20-05-2023 11:38:45" level=fatal msg="unable to create database client: failed to create SQLite database file \"/var/lib/crowdsec/data/crowdsec.db\": open /var/lib/crowdsec/data/crowdsec.db: no such file or directory"
 * start-stop-daemon: failed to start `/usr/bin/crowdsec'
 * Failed to start crowdsec                                                                                                                                                           [ !! ]
 * ERROR: crowdsec failed to start

I'll see if a keepdir fixes this. I had to get me a fresh gentoo install as I was already running crowdsec here pretty much everywhere.