WAN IPv4 checker & email notifier for computers behind dynamic IP/DHCP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.5 KiB

  1. ## sSMTP system pre-configuration
  2. Once you have installed sSMTP on your Linux system, make sure the following applies. Run these configuration commands as root or with `sudo`.
  3. ----------
  4. **1)** Check that symbolic link from `/usr/bin/ssmtp` to `/usr/bin/sendmail` exists:
  5. ```
  6. ln -s /usr/bin/ssmtp /usr/bin/sendmail
  7. ```
  8. Test:
  9. ```
  10. > stat -c "%A %a %U:%G %N" /usr/bin/sendmail
  11. lrwxrwxrwx 777 root:root /usr/bin/sendmail -> ssmtp
  12. ```
  13. ----------
  14. **NOTE:** User & group `mail` are defined on Arch Linux by default, preinstalled with `filesystem` package. If they do not exist, then do the following.
  15. **2)** Make sure user & group `mail` exists, and directory /`var/spool/mail` exists with proper permissions:
  16. ```
  17. mkdir -p /var/spool/mail
  18. chmod 1777 /var/spool/mail
  19. groupadd -g 12 mail
  20. useradd -r -d /var/spool/mail -s /sbin/nologin -u 12 -g 12 mail
  21. ```
  22. Test:
  23. ```
  24. -----
  25. > sudo stat -c "%A %a %U:%G %n" /var/spool/mail
  26. drwxrwxrwt 1777 root:root /var/spool/mail
  27. -----
  28. > grep mail /etc/passwd
  29. mail:x:12:12::/var/spool/mail:/sbin/nologin
  30. -----
  31. > grep mail /etc/group
  32. mail:x:12:
  33. ```
  34. ## sSMTP configuration files
  35. Once you have sSMTP installed on your Linux system, configure [ssmtp.conf](ssmtp.conf) and [revaliases](revaliases) in `/etc/ssmtp/` folder.
  36. ## Mail message formatting & email address
  37. Configure your message defined in [wanchecker.sh](wanchecker.sh) file.
  38. `wanchecker.sh` variables:
  39. | Variable | Value | Type |
  40. |------------------|-----------------------------------------------------------------------------|------------|
  41. | SUBJECT_EMAIL | Email title | String |
  42. | MESSAGE_EMAIL | Email message contents | String |
  43. | MESSAGE_STDOUT | Internal Linux system message about sent email message | String |
  44. | WANIP_DIR | Log file directory path. User `mail` must have write access to this folder. | String |
  45. | WANIP_LOG | Log file name | String |
  46. ## Mail sender and recipients
  47. These are found in `/etc/ssmtp/wanchecker.conf` which is a bash `source` file.
  48. The conf file has three variables: `ENABLE_FALLBACK_DNS`, `EMAIL_SENDER` and `EMAIL_RECIPIENTS` which **must be** configured. `EMAIL_SENDER` takes same value as defined in `/etc/ssmtp/ssmtp.conf` ([sample](ssmtp.conf)) and `/etc/ssmtp/revaliases` ([sample](revaliases)) files.
  49. ## Folder & file permissions
  50. Permissions for `/etc/ssmtp` folder should be:
  51. ```
  52. > stat -c "%A %a %U:%G %n" /etc/ssmtp
  53. drwxr-x--- 750 root:mail /etc/ssmtp
  54. ```
  55. Contents of `/etc/ssmtp/` folder should contain the following files & permissions:
  56. ```
  57. > stat -c "%A %a %U:%G %n" /etc/ssmtp/*
  58. -rw-r----- 640 root:mail /etc/ssmtp/revaliases
  59. -rw-r----- 640 root:mail /etc/ssmtp/ssmtp.conf
  60. -rwxr-x--- 750 root:mail /etc/ssmtp/wanchecker.sh
  61. -rwxr-x--- 640 root:mail /etc/ssmtp/wanchecker.conf
  62. ```
  63. **NOTE:** As `/etc/ssmtp/ssmtp.conf` contains a _clear-text email password_, the file must be protected from any eavesdropping with correct permission policy! The file must not be readable to any other than `mail` user, and `mail` user must not be available for normal usage. Still, any `sudo` group member can access the file, so make sure `sudo` group does not contain hostile or unwanted members, and configure your `/etc/sudoers` file properly.