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

post_install() {
  chown -R mycroft-core:mycroft-core /usr/share/mycroft-core

  # install packages
  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'
}

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
}