summarylogtreecommitdiffstats
path: root/solr.install
blob: ae416d79cbf256788af975a19cca89a68de58eda (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
print_core_message() {
  cat <<EOT
Start the solr service first!
  $ sudo systemctl restart solr

Then, create new Solr core(s) from the command line:
  $ sudo -u solr -s /bin/bash
  $ cd
  $ bin/solr create_core -c new_core
EOT
}

# args: <group> [options]
_addgroup() {
  if ! getent group "$1" >/dev/null && groupadd "$@" >/dev/null; then
    need_group_update=1
  fi
}

# args: <group> [options]
_adduser() {
  if ! getent passwd "$1" >/dev/null && useradd "$@" >/dev/null; then
    need_passwd_update=1
  fi
}

install_solr_user() {
  _addgroup solr -g 114
  _adduser solr -c 'Apache Solr user' -u 114 -g solr -d '/opt/solr' -s /bin/bash

  # update shadow files if needed
  if (( need_group_update )); then
    grpconv >/dev/null
  fi

  if (( need_passwd_update )); then
    pwconv >/dev/null
  fi
}

post_install() {
  print_core_message
  install_solr_user
}

post_upgrade() {
  post_install $1
}