Advertisement
Guest User

autoupdate

a guest
Jul 6th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. update() {
  4. #update interval in days
  5. intervall=10
  6.  
  7. path="/var/tmp/autoupdate"
  8.  
  9. update=$((`cat $path` + $intervall))
  10.  
  11. if [ `date +%Y%j` -gt $update ]; then
  12.    stat_busy "Updating"
  13.    pacman --noconfirm -Suy && date +%Y%j > $path  
  14. fi
  15.  
  16. }
  17.  
  18. . /etc/rc.conf
  19. . /etc/rc.d/functions
  20. case "$1" in
  21.   start)
  22.     stat_busy "Activating auto update"
  23.     add_daemon autoupdate
  24.     stat_done
  25.     ;;
  26.   stop)
  27.     stat_busy "Checking auto update"
  28.     update
  29.     rm_daemon autoupdate
  30.     stat_done
  31.     ;;
  32.   restart)
  33.     $0 stop
  34.     sleep 1
  35.     $0 start
  36.     ;;
  37.   *)
  38.     echo "usage: $0 {start|stop|restart}"  
  39. esac
  40. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement