Advertisement
peetaur

openSUSE zypper auto-patch

Apr 29th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. ======================================
  2. /usr/local/bin/pm_zypper_patch.bash
  3. ======================================
  4. #!/usr/bin/env bash
  5. # Author: Peter Maloney
  6. set -u
  7.  
  8. type="${1:+$1}"
  9.  
  10. if [ -n "$type" ]; then
  11.     args=()
  12.     args[0]="-g"
  13.     args[1]="$type"
  14. fi
  15.  
  16. echo "====================================="
  17. echo -n $(date "+%Y-%m-%d %H:%M:%S")" - "
  18. echo "zypper -n patch ${args[@]:+${args[@]} }-l"
  19. echo "====================================="
  20.  
  21. zypper -n patch ${args[@]:+${args[@]} } -l
  22.  
  23. ======================================
  24. /etc/logrotate.d/pm_zypper.lr
  25. ======================================
  26. /var/log/pm_zypper_patch.log {
  27.     compress
  28.     dateext
  29.     notifempty
  30.     missingok
  31.     nocreate
  32.  
  33.     maxage 60
  34.     rotate 10
  35.     size 10M
  36. }
  37.  
  38.  
  39. ======================================
  40. /etc/cron.d/pm_zypper
  41. ======================================
  42. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
  43.  
  44. # Refresh repos daily
  45. 0 1 * * * root zypper -n refresh >/dev/null 2>&1
  46. # Security patches daily
  47. 0 2 * * * root pm_zypper_patch.bash security >> /var/log/pm_zypper_patch.log 2>&1
  48. # all patches daily
  49. #0 2 * * * root pm_zypper_patch.bash >> /var/log/pm_zypper_patch.log 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement