Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. VERSION_INSTALLED=`cat /opt/UniFi/data/db/version`
  4. VERSION_LATEST=`curl --silent https://help.ubnt.com/hc/en-us/articles/115000441548-UniFi-Current-Controller-Versions|grep -w Stable|grep -v Candidate|grep -v LTS|grep http|sed 's/<[^>]\+>//g'`
  5.  
  6. function clean()
  7. {
  8.     [ -e file ] && rm /tmp/unifi.zip
  9. }
  10. function unifi_backup()
  11. {
  12.     systemctl stop unifi
  13.     tar -zcvf /shared/backup/sth-ka-net000.cinqore.se/unifi_controller.tar.gz /opt/UniFi/data/
  14.     systemctl start unifi
  15. }
  16. function unifi_download()
  17. {
  18.     VERSION=$1
  19.     wget -q https://dl.ubnt.com/unifi/${VERSION}/UniFi.unix.zip -O /tmp/unifi.zip
  20. }
  21. function unifi_upgrade()
  22. {
  23.     systemctl stop unifi
  24.     unzip -qq -o /tmp/unifi.zip -d /opt
  25.     chown -R ubnt:ubnt /opt/UniFi
  26.     # OpenSuSE Leap fix for broken mongodb symlink
  27.     ln -sf /usr/sbin/mongod /opt/UniFi/bin/mongod
  28.     systemctl start unifi
  29. }
  30.  
  31. if [ ${VERSION_INSTALLED} = ${VERSION_LATEST} ]
  32. then
  33.     echo "latest version already installed, exiting script"
  34.     exit 0
  35. fi
  36.  
  37. clean
  38. echo "Downloading version ${VERSION_LATEST} (installed version is ${VERSION_INSTALLED}"
  39. unifi_download ${VERSION_LATEST}
  40. echo "Stopping UniFi Controller and upgrading software"
  41. unifi_upgrade
  42. echo "cleaning temporary upgrade files"
  43. clean
  44. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement