post_install() {
  if [[ -z $(getent group plex) ]]; then
    groupadd -g 421 plex
  fi
  if [[ -z $(getent passwd plex) ]]; then
    useradd -c 'Plex User' -u 421 -g plex -d /var/lib/plex -s /usr/bin/nologin plex
  fi
  passwd -l plex > /dev/null

  chown -R plex:plex /var/lib/plex
  chown -R plex:plex /opt/plexmediaserver 

  cat << "EOM"
  ####
  #  Installation done
  #  - Change default configurations in:
  #    /etc/conf.d/plexmediaserver
  #  - Launch the server with:
  #    systemctl start plexmediaserver
  #  - WebUI is available at http://<ip>:32400/web
  #  - After first run let it settle down for 10-20 min
  #    or you won't be able to add anything to library
  #
  # This is an UNOFFICIAL package. Please don't go to plex forums
  # asking for help as they don't support it on ArchLinux ARM.
  #
  # Redistributed with permission from Plex team.
  ####
EOM
}

post_upgrade() {
  post_install
  if [[ $(vercmp 0.9.11.1.678-1 $2) == "1" ]]; then
    echo "
Plex' home is now located in '/var/lib/plex'. You will have to move the 'Plex M
edia Server' directory located in '/opt/plexmediserver/Library/Application Supp
ort' into the new home. Please refer to 'https://support.plex.tv/hc/en-us/artic
les/201370363-Move-an-Install-to-Another-System' for detailed instructions.
"
  fi
}

# vim: ts=2 sw=2 et:
