5
submitted 11 months ago by Fruitball to c/linux4noobs@programming.dev

I'm currently trying to set up a self-hosted SearX search engine on Ubuntu 22.04. In order for the search engine to work, I have to manually run the following commands on startup:

#! /usr/bin/bash

sudo -H -u searx -i

cd /usr/local/searx/searx-src

export SEARX_SETTINGS_PATH="/etc/searx/settings.yml"

python searx/webapp.py

This is kind of annoying to have to do, so I put the script into /etc/rc.local and went through all the steps to enable all that. Now my rc.local file looks like:

#!/bin/sh -e

#! /usr/bin/bash

sudo -H -u searx -i

cd /usr/local/searx/searx-src

export SEARX_SETTINGS_PATH="/etc/searx/settings.yml"

python searx/webapp.py

exit 0

However, the code fails, and upon checking "sudo systemctl status rc-local.service" I get the following (abbreviated) error message:

 Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
         └─debian.conf
 Active: failed (Result: exit-code) since Thu 2023-10-05; 55s ago
Process: 8468 ExecStart=/etc/rc.local start (code=exited, status=127)
    CPU: 12ms

systemd[1]: Starting /etc/rc.local Compatibility... sudo[8469]: root : PWD=/usr/local/searx ; USER=searx ; COMMAND=/bin/bash sudo[8469]: pam_unix(sudo-i:session): session opened for user searx(uid=999) by (uid=0) sudo[8469]: pam_unix(sudo-i:session): session closed for user searx rc.local[8468]: /etc/rc.local: 6: python: not found systemd[1]: rc-local.service: Control process exited, code=exited, status=127/n/a systemd[1]: rc-local.service: Failed with result 'exit-code'. systemd[1]: Failed to start /etc/rc.local Compatibility.

I understand that an Exit Code 127 means that the code is failing because it can't access the following directory:

cd /usr/local/searx/searx-src

But I honestly have no idea how to fix my code to make this possible. Please lmk if you have any suggestions

you are viewing a single comment's thread
view the rest of the comments
[-] EddyBot@feddit.de 2 points 11 months ago* (last edited 11 months ago)

why not create a systemd service directly for this instead of going through ancient rc.local way? you can specify with which user to run it (without sudo or su schenanigans) and in which directory to start with
environmental variables are also possible

something like (didn't tested it)

[Unit]
Description=SearX
After=network.target

[Service]
Type=simple
WorkingDirectory=/usr/local/searx/searx-src
User=searx
Group=searx
Environment="SEARX_SETTINGS_PATH=/etc/searx/settings.yml"
ExecStart=/usr/bin/python /usr/local/searx/searx-src/searx/webapp.py 
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target 

keep in mind though that SearX is unmaintained since last month, you might consider SearXNG

this post was submitted on 05 Oct 2023
5 points (100.0% liked)

linux4noobs

1283 readers
1 users here now

linux4noobs


Noob Friendly, Expert Enabling

Whether you're a seasoned pro or the noobiest of noobs, you've found the right place for Linux support and information. With a dedication to supporting free and open source software, this community aims to ensure Linux fits your needs and works for you. From troubleshooting to tutorials, practical tips, news and more, all aspects of Linux are warmly welcomed. Join a community of like-minded enthusiasts and professionals driving Linux's ongoing evolution.


Seeking Support?

Community Rules

founded 1 year ago
MODERATORS