release-upgrade-motd 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh -e
  2. #
  3. # 91-release-upgrade - display upgrade message or update the cache
  4. # in the background
  5. #
  6. # Copyright (C) 2010 Canonical Ltd.
  7. #
  8. # Authors: Dustin Kirkland <kirkland@canonical.com>
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation, version 3 of the License.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. stamp=/var/lib/ubuntu-release-upgrader/release-upgrade-available
  22. if [ -f "$stamp" ]; then
  23. # Stamp exists, see if it's expired
  24. now=$(date +%s)
  25. lastrun=$(stat -c %Y "$stamp") 2>/dev/null || lastrun=0
  26. expiration=$(expr $lastrun + 86400)
  27. if [ $now -ge $expiration ]; then
  28. # Older than 1 day old, so update in the background
  29. /usr/lib/ubuntu-release-upgrader/check-new-release -q > "$stamp" &
  30. elif [ -s "$stamp" ]; then
  31. # Less than 1 day old, and non-empty, so display now
  32. cat "$stamp"
  33. echo
  34. fi
  35. elif [ "$(id -u)" = 0 ]; then
  36. # No cache at all, so update in the background
  37. /usr/lib/ubuntu-release-upgrader/check-new-release -q > "$stamp" &
  38. fi