Automatic emails using bash and sendgrid

Problem

You would like to be able to automatically send some emails (ie reports) from a linux server, using a bash script that runs in cronjob, without installing an email server on the linux server.

Solution

  • Create an account in Sendgrid and follow the directions for using WebAPI with curl
    here
  • Set up your bash script to use the API key and have a script like the following. If you want to use big or multiple files you will need to use a temporary file for the base64 encoding, as in the example below, as there is a limit in curl.
  • Add your script to crontab
  • curl: (7) Failed to connect to localhost port 80: Connection refused

    Problem

    You would like to access a host set up with nginx after adding your own vhost configuration file in /etc/nginx/conf.d/myfile.smth, but you get Connection refused.

    Solution

    Make sure that your nginx configuration file has the .conf extension as /etc/nginx/conf.d/myfile.conf.

    Cannot create container for service xxx: invalid mode: /path/to/volume/

    Problem

    You are trying to use docker-compose to get some services up with docker but you see an error like the following:

    Solution

    This is more than likely caused by a typo in your yml file, so go back and check carefully for any typos and correct them.

    ERROR: Couldn’t connect to Docker daemon at http+docker://localunixsocket – is it running?

    Problem

    Using docker-compose up (or build), displays the following error message (even though the same command used to work previously):

    Solution

    This is quite possible caused by permissions issue, as one of the folders files that docker is trying to use is owned by a different user/group from the one trying to use the docker-compose commands. Try to find the file/folder with the different permissions and change it to your user name and group, or use change the files by using something like:

    Adding missing timestamp column in MySQL table

    Problem

    You have a MySQL table that does not have any timestamp information (creating, updating) and you want to add a column that automatically adds a timestamp every time the record is created.

    Solution

    Add the column for timestamp that creates a timestamp every time a new record is created (INSERT) by using the following:

    More information here

    Find the IP Address of a running Docker container

    Problem

    You would like to know the IP Address of a running Docker container.

    Solution

    Use the following to find out the IP Address by replacing the container_name with the actual container name:

    minikube kubeconfig error

    Problem

    Trying to set up minikube you get the following error:

    Error setting up kubeconfig: writing kubeconfig: Error writing file : open : no such file or directory

    Solution

    Unset the KUBECONFIG to solve the issue (unset KUBECONFIG) as described https://pubci.com/2017/01/01/why-not-tryout-kubernetes-locally-via-minikube/

    Changing php.ini options in dreamhost

    Problem

    You would like to change the options in your application’s php.ini file (ie maximum upload file size), which is hosted in dreamhost.

    Solution

    Dreamhost is using a file called phprc which is installed in your home directory (~/phprc).
    More information here
    Edit this file and change the setting you would like.