summarylogtreecommitdiffstats
path: root/librechat.install
blob: 3228c7e0ed6c7b02da32222e337aefed0e554282 (plain)
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
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly CYAN='\033[0;36m'
readonly BOLD='\033[1m'
readonly NC='\033[0m' # No Color
print_header() {
  echo -e "${BOLD}${BLUE}==> $1${NC}"
}
print_info() {
  echo -e "${CYAN}    $1${NC}"
}
print_success() {
  echo -e "${GREEN} $1${NC}"
}
print_warning() {
  echo -e "${YELLOW} $1${NC}"
}
print_command() {
  echo -e "${BOLD}    $1${NC}"
}
post_install() {
  print_info "Creating LibreChat system user and group..."
  systemd-sysusers /usr/lib/sysusers.d/librechat.conf

  print_info "Setting ownership of existing files..."
  #retain group ownership of new files
  chmod g+s /usr/lib/librechat
  chown -R librechat:librechat /usr/lib/librechat
  chown -R librechat:librechat /usr/share/webapps/librechat

  echo ""
  print_header "Next Steps"
  echo ""

  print_info "To start the LibreChat service:"
  print_command "sudo systemctl start librechat"
  echo ""

  print_warning "MongoDB Database Required"
  print_info "LibreChat requires a MongoDB server to function properly."
  print_info "To install MongoDB locally, choose one of:"
  print_command "yay -S mongodb-bin    # (binary package)"
  print_command "yay -S mongodb        # (compile from source)"
  echo ""
  print_info "Then enable and start MongoDB:"
  print_command "sudo systemctl enable --now mongodb.service"
  echo ""

  print_header "Configuration"
  echo ""
  print_info "Configure LibreChat by editing files in:"
  print_command "/etc/librechat/"
  echo ""

  print_header "Running as Different User"
  echo ""
  print_info "By default, LibreChat runs as the 'librechat' user."
  print_info "To run it manually as your user, add yourself to the librechat group:"
  print_command "sudo usermod -aG librechat \"\$(whoami)\""
  print_info "Then log out and back in, and you can run:"
  print_command "/usr/bin/librechat-server"
  echo ""

  print_header "Serving the web front-end through nginx (optional)"
  echo ""
  print_info "You'll find the web root in /usr/share/webapps/librechat"
  print_info "A sample config file can be found in /usr/share/doc/librechat"
  echo ""
}

post_upgrade() {
  echo ""
  print_header "LibreChat Upgrade Complete"
  echo ""
  post_install
}

post_remove() {
  echo ""
  print_header "LibreChat Removal"
  echo ""

  if [ -d /usr/lib/librechat ]; then
    print_warning "Data Directory Preserved"
    print_info "The directory /usr/lib/librechat still exists and may contain user data."
    print_info "To completely remove all LibreChat files:"
    print_command "sudo rm -rf /usr/lib/librechat"
    echo ""
  else
    print_success "LibreChat completely removed"
    echo ""
  fi
}