1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/bin/bash
_message() {
cat << EOF
>>>
>>>
>>>
>>> The preferred way to start OpenWebUI is through the systemd service like so:
>>> $ sudo systemctl start open-webui
>>>
>>>
>>> Doing so is preferred because OpenWebUI requires the setup of specific environment variables
>>> in a specific manner, which can be seen in the file /usr/share/open-webui/open-webui.conf, which
>>> itself is required, because we need to set up OpenWebUI differently in order to run OpenWebUI properly
>>> outside of a docker container, which is what upstream recommends and what upstream sets the defaults to
>>> cater to.
>>
>>> It becomes easier to consistently set these environment variables through a systemd service, hence
>>> it is being used here.
>>>
>>> Also, backwards compatibility with how the package was set up initially using a virtual environment
>>> is kept intact with the use of the systemd service.
>>>
>>>
>>> However, it is possible to launch open-webui using the commandline, provided certain steps are taken beforehand,
>>> as detailed below:
>>>
>>> Step 1: Copy the config file and paste it into .config/open-webui/ folder (folder may need to be created manually),
>>> like so:
>>> $ mkdir ~/.config/open-webui
>>> $ cp /usr/share/open-webui/open-webui.conf ~/.config/open-webui
>>>
>>> Step 2: Edit the configuration file and add 'export ' at the start of each line having a variable, so that each variable
>>> that looks like so initially:
>>> OLLAMA_BASE_URL=http://localhost:11434
>>> becomes:
>>> export OLLAMA_BASE_URL=http://localhost:11434
>>>
>>> Step 3: With each launch of OpenWebUI using the 'open-webui serve' command, prepend the command like so:
>>> $ source ~/.config/open-webui/open-webui.conf && open-webui serve
>>>
>>> Alternatives to sourcing the configuration file each time may be to create an alias for this command,
>>> or putting the environment variables directly into your .bashrc or .zshrc
>>>
EOF
}
post_install() {
echo "Generating random WEBUI_SECRET_KEY..."
secret_key="$(head -c 12 /dev/random | base64)"
sed -i "s/t0p-s3cr3t/${secret_key}/" "/usr/share/open-webui/open-webui.conf"
_message
}
pre_upgrade() {
rm -rf "/opt/open-webui"
rm /usr/share/open-webui/open-webui.conf
}
post_upgrade() {
echo "Generating a new random WEBUI_SECRET_KEY..."
secret_key="$(head -c 12 /dev/random | base64)"
sed -i "s/t0p-s3cr3t/${secret_key}/" "/usr/share/open-webui/open-webui.conf"
_message
}
|