#!/usr/bin/bash # Install open-webui # Load the configuration source ./installer.conf CURRENT_DIR=$(pwd) # Create the users echo "Create users and groups" getent group $GROUP > /dev/null 2&>1 || groupadd $GROUP getent passwd $USER > /dev/null 2&>1 if [ $? -ne 0 ]; then useradd --system -s /usr/bin/nologin -g $GROUP $USER fi # Start with creating the configuration file echo "Writing configuration files..." mkdir -p /etc/open-webui cp open-webui.conf /etc/open-webui sed -i "s|#TARGET_DIR#|${TARGET_DIR}|g" /etc/open-webui/open-webui.conf # Now create the target directory echo "Creating target directory..." mkdir -p $TARGET_DIR # And populate it echo "Installing open-webui" cd $TARGET_DIR $PYTHON -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install open-webui deactivate chown -R $USER:$GROUP $TARGET_DIR cd $CURRENT_DIR echo "Finished installing open-webui." # Now install the script file echo "Installing the script" mkdir -p /usr/local/bin cp ./run-open-webui $TARGET_DIR chmod +x $TARGET_DIR/run-open-webui # Install the systemd file echo "Installing the service file" cp ./open-webui.service /etc/systemd/system sed -i "s|#TARGET_DIR#|${TARGET_DIR}|g" /etc/systemd/system/open-webui.service sed -i "s|#USER#|${USER}|g" /etc/systemd/system/open-webui.service sed -i "s|#GROUP#|${GROUP}|g" /etc/systemd/system/open-webui.service systemctl daemon-reload