-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.sh
More file actions
executable file
·146 lines (130 loc) · 6.33 KB
/
installer.sh
File metadata and controls
executable file
·146 lines (130 loc) · 6.33 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
# This script installs AnythingLLMDesktop on Linux.
# On systems with AppArmor enabled, the AppImage needs to also create a userspace
# apparmor profile so that the AppImage can be run without SUID requirements due to root chromium ownership.
#
# Todo: Detect the current location of the AppImage so that we can update the application
# in-place without the user needed to manually move the application to the new location.
# This is also useful so that the apparmor location is always correct if the user edits it.
set -eu
status() { echo "$*" >&2; }
error() { echo "ERROR $*"; exit 1; }
warning() { echo "WARNING: $*"; }
# Create an AppArmor profile for AnythingLLMDesktop for systems with AppArmor enabled
# https://askubuntu.com/questions/1512287/obsidian-appimage-the-suid-sandbox-helper-binary-was-found-but-is-not-configu/1528215#1528215
create_apparmor_profile() {
status "Checking for sudo privileges..."
sudo -v
if [ $? -ne 0 ]; then
error "Failed to get sudo privileges! Aborting..."
exit 1
fi
status "Creating AppArmor profile for AnythingLLM..."
APP_ARMOR_CONTENT=$(cat <<EOF
# This profile is used specifically for AnythingLLMDesktop application
# If you move the application to a different location, you will need to edit this profile.
abi <abi/4.0>,
include <tunables/global>
# Use wildcard to allow the AppImage to be in any location on system across all users.
profile anythingllmdesktop /**/AnythingLLMDesktop.AppImage flags=(unconfined) {
userns,
}
EOF
)
echo "$APP_ARMOR_CONTENT" | sudo tee /etc/apparmor.d/anythingllmdesktop > /dev/null
status "Reloading AppArmor service..."
sudo systemctl reload apparmor.service
status "AppArmor profile created - you can now run AnythingLLMDesktop without SUID requirements."
}
check_to_create_apparmor_profile() {
# Check if the system has AppArmor enabled
if [ -f /sys/kernel/security/apparmor/profiles ]; then
if ! [ -f /etc/apparmor.d/anythingllmdesktop ]; then
status "AppArmor is enabled on this system."
status "\e[31m[Warning]\e[0m You will get an error about SUID permission issues when running the AppImage without creating an AppArmor profile."
status "This requires sudo privileges. If you are unsure, you can create an AppArmor profile manually."
read -p "Do you want to auto-create an AppArmor profile for AnythingLLM now? (y/n): " create_apparmor
if [ "$create_apparmor" = "y" ]; then
create_apparmor_profile
else
status "AppArmor is enabled on this system."
status "AppArmor profile creation skipped. You may not be able to run AnythingLLMDesktop without it."
fi
else
status "AppArmor profile already exists."
read -p "Do you want to overwrite it with the latest version? (y/n): " overwrite_apparmor
if [ "$overwrite_apparmor" = "y" ]; then
create_apparmor_profile
fi
fi
else
status "AppArmor could not be automatically detected or does not exist. If you get an SUID error on startup, you may need to create an AppArmor profile for AnythingLLMDesktop.AppImage manually."
fi
}
check_or_create_desktop_profile() {
if ! [ -f $HOME/.local/share/applications/anythingllmdesktop.desktop ]; then
status "Desktop profile not found. Creating..."
# Default Exec command
EXEC_CMD="$HOME/AnythingLLMDesktop.AppImage"
# Check for Wayland + KDE specifically
# We check XDG_SESSION_TYPE for "wayland"
# We check XDG_CURRENT_DESKTOP for "KDE" (handles "KDE", "KDE-Plasma", etc)
# We use ':-' to safely handle unbound variables in 'set -u' mode
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
case "${XDG_CURRENT_DESKTOP:-}" in
*"KDE"*)
status "Detected KDE Plasma on Wayland. Adding specific flags for IME support."
EXEC_CMD="$HOME/AnythingLLMDesktop.AppImage --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime"
;;
esac
fi
DESKTOP_CONTENT=$(cat <<EOF
[Desktop Entry]
StartupWMClass=anythingllm-desktop
Type=Application
Name=AnythingLLM Desktop
Exec=$EXEC_CMD
Icon=$HOME/.config/anythingllm-desktop/storage/icon.png
Categories=Utility;
EOF
)
mkdir -p $HOME/.local/share/applications
echo "$DESKTOP_CONTENT" | tee $HOME/.local/share/applications/anythingllmdesktop.desktop > /dev/null
status "Desktop profile created!"
fi
}
arch=$(uname -m)
[ "$(uname -s)" = "Linux" ] || error 'This script is intended to run on Linux only.'
if [ "$(id -u)" -eq 0 ]; then
status "This script should not be run as root. Please run it as a regular user."
exit 1
fi
status "#########################################################"
status " Welcome to the AnythingLLM Desktop Installer"
status " by Mintplex Labs Inc (team@mintplexlabs.com)"
status " Architecture: $arch"
status "#########################################################"
if [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then
APPIMAGE_URL="https://cdn.anythingllm.com/latest/AnythingLLMDesktop-Arm64.AppImage"
else
APPIMAGE_URL="https://cdn.anythingllm.com/latest/AnythingLLMDesktop.AppImage"
fi
APPIMAGE_FILE="AnythingLLMDesktop.AppImage"
status "Downloading latest AnythingLLM Desktop ($APPIMAGE_URL)"
curl --fail --show-error --location --progress-bar -o $HOME/$APPIMAGE_FILE $APPIMAGE_URL
chmod +x $HOME/$APPIMAGE_FILE;
status "AnythingLLM Desktop is ready to run!"
status ".$HOME/$APPIMAGE_FILE to start AnythingLLMDesktop"
status "\e[36mHeads up!\e[0m You can rerun this installer anytime to get the latest version of AnythingLLM without effecting your existing data."
status "Documentation: https://docs.anythingllm.com"
status "Issues: https://github.com/Mintplex-Labs/anything-llm"
status "\e[36mThanks for using AnythingLLM!\e[0m\n\n"
status "Next, we will create a desktop profile and AppArmor profile for AnythingLLMDesktop."
status "This is required for the AppImage to be able to run without SUID requirements."
status "You can manually create these profiles if you prefer."
check_or_create_desktop_profile
check_to_create_apparmor_profile
read -p "Do you want to start AnythingLLMDesktop now? (y/n): " start
if [ "$start" = "y" ]; then
$HOME/$APPIMAGE_FILE
fi