summarylogtreecommitdiffstats
path: root/mycroft-core.install
blob: 3ccd7bea8630c5d3e8997ac954a6bfcf112b58b4 (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
pre_install() {
  useradd -r mycroft-core -b /usr/share
}

post_install() {
  chown -R mycroft-core:mycroft-core /usr/share/mycroft-core
  chmod g+w /usr/share/mycroft-core

  touch /usr/share/mycroft-core/.bashrc
  echo "# Virtualenv initialization" >> /usr/share/mycroft-core/.bashrc
  echo "export WORKON_HOME=\$HOME/.virtualenvs" >> /usr/share/mycroft-core/.bashrc
  echo "export PROJECT_HOME=\$HOME/Devel" >> /usr/share/mycroft-core/.bashrc
  echo "source /usr/bin/virtualenvwrapper.sh" >> /usr/share/mycroft-core/.bashrc

  sudo -u mycroft-core bash -c 'source ~/.bashrc' &> /dev/null # Initialize virtualenv

  sudo -u mycroft-core bash -c 'source ~/.bashrc && mkvirtualenv mycroft --system-site-packages -p $(which python2)'
  sudo -u mycroft-core bash -c 'source ~/.bashrc && workon mycroft && pip install -r /usr/share/mycroft-core/requirements.txt'

  echo "*** ATTENTION ***"
  echo ""
  echo "* The users who will use Mycroft need to be part of the mycroft-core group"
  echo ""
  echo "* You can configure your Mycroft instance preferences systemwide at:"
  echo "    /usr/share/mycroft-core/mycroft/configuration/mycroft.conf"
  echo ""
  echo "* The systemd units are"
  echo "    - mycroft.target"
  echo "    - mycroft-service.service"
  echo "    - mycroft-skills.service"
  echo "    - mycroft-voice.service"
  echo ""
  echo "* Those are USER units which you can start issuing:"
  echo "    systemctl --user start mycroft.target"
  echo "    More information at: https://wiki.archlinux.org/index.php/Systemd/User"

}

post_upgrade() {
  sudo -u mycroft-core bash -c "source ~/.bashrc && workon mycroft && pip install -r /usr/share/mycroft-core/requirements.txt"
}

post_remove() {
  userdel mycroft-core
  rm -rf /usr/share/mycroft-core
}