Guest User

Untitled

a guest
Apr 14th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. ## Install the unattended-upgrades package
  2.  
  3. ```bash
  4. $ sudo apt-get install unattended-upgrades
  5. ```
  6.  
  7. ## Edit the periodic configuration
  8.  
  9. ```bash
  10. $ sudo nano /etc/apt/apt.conf.d/10periodic
  11. ```
  12.  
  13. Set the following:
  14.  
  15. ```
  16. APT::Periodic::Update-Package-Lists "1";
  17. APT::Periodic::Download-Upgradeable-Packages "1";
  18. APT::Periodic::AutocleanInterval "7";
  19. ```
  20.  
  21. Where the number is the frequency (in days)
  22.  
  23. ## Edit the unattended upgrades configuration
  24.  
  25. ```bash
  26. $ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
  27. ```
  28.  
  29. ### Configure the default packages you want to automatically upgrade:
  30.  
  31. ```
  32. Unattended-Upgrade::Allowed-Origins {
  33. "${distro_id}:${distro_codename}-security";
  34. "${distro_id}:${distro_codename}-updates";
  35. // "${distro_id}:${distro_codename}-proposed";
  36. // "${distro_id}:${distro_codename}-backports";
  37. };
  38. ```
  39.  
  40. ### Optionally configure additional packages you want to upgrade
  41.  
  42. In order to automatically upgrade custom packages do the following:
  43.  
  44. 1. Look in `/var/lib/apt/lists/` to find the custom package that you want to update. It should end with `Release` e.g. `/var/lib/apt/lists/files.freeswitch.org_repo_deb_debian_dists_wheezy_InRelease`
  45. 2. Open up the file `$ nano /var/lib/apt/lists/files.freeswitch.org_repo_deb_debian_dists_wheezy_InRelease`
  46. 3. Look for the `Origin` and `Suite` entries. e.g. `Origin: freeswitch` `Suite: stable` and note these values.
  47. 4. Edit the unattended upgrades configuration again. `$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades`
  48. 5. Add an entry for the `origin` and `suite` in the configuration
  49.  
  50. E.g.
  51.  
  52. ```
  53. Unattended-Upgrade::Allowed-Origins {
  54. "${distro_id}:${distro_codename}-security";
  55. "${distro_id}:${distro_codename}-updates";
  56. "freeswitch:stable";
  57. // "${distro_id}:${distro_codename}-proposed";
  58. // "${distro_id}:${distro_codename}-backports";
  59. };
  60. ```
  61.  
  62. ### Setup automatic reboot (optional)
  63.  
  64. This will reboot the server if required automatically.
  65.  
  66. ```
  67. Unattended-Upgrade::Automatic-Reboot "true";
  68. Unattended-Upgrade::Automatic-Reboot-Time "19:00"; // Optional
  69. ```
  70.  
  71. ### Setup Mail
  72.  
  73. ```
  74. Unattended-Upgrade::Mail "someone@gmail.com";
  75. ```
  76.  
  77. ## Send notifications via Gmail
  78.  
  79. ### Install `mailx`
  80.  
  81. ```bash
  82. $ heirloom-mailx
  83. ```
  84.  
  85. ### Set mail defaults
  86.  
  87. ```bash
  88. $ sudo su
  89. $ cd ~
  90. $ nano .mailrc
  91. ```
  92.  
  93. Add the following to `.mailrc` in root's home directory.
  94.  
  95. ```
  96. set smtp-use-starttls
  97. set ssl-verify=ignore
  98. set smtp=smtp://smtp.gmail.com:587
  99. set smtp-auth=login
  100. set smtp-auth-user=someone@gmail.com
  101. set smtp-auth-password=secret
  102. set from="someone@gmail.com
  103. ```
  104.  
  105. Change the permissions of `.mailrc`
  106.  
  107. ```bash
  108. chmod 400 .mailrc
  109. ```
  110.  
  111. ## Test it out
  112.  
  113. ```bash
  114. $ sudo unattended-upgrade -v -d --dry-run
  115. ```
  116.  
  117. ## Trigger it now
  118.  
  119. ```bash
  120. $ sudo unattended-upgrade -v -d
  121. ```
Add Comment
Please, Sign In to add comment