Category Archives: Miscellaneous
Very Good Guide on Setting up DKIM
Zipped version of the page attached in case the main article becomes inaccessible for whatever reason
WP Code Highlight – gives preg_replace error
With updated PHP version WP Code Highlight – gives preg_replace error. Do the following. Remove the “e” from /ise
return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is", function($m){ return "<pre class='wp-code-highlight prettyprint$line_numbers'>".wch_stripslashes($m[2])."</pre>"; }, $content);
Setup Free SSL Certificate on your Server
Please note : This article (and the repo mentioned here) is deprecated. Certbot now recommends installation through Snap. For more details please see – https://certbot.eff.org/docs/install.html.
More info at: https://launchpad.net/~certbot/+archive/ubuntu/certbot
Electronic Frontier Foundation (EFF) provides Let’s Encrypt SSL Certificates through their Certbot service. They don’t provide any Organization Validation (OV) or Extended Validation (EV) certificate. As per plans, from January 2018, they will provide wildcard certificates also.
The Let’s Encrypt Policy and Legal documents can be found here : https://letsencrypt.org/repository/ and the FAQ page is at https://letsencrypt.org/docs/faq/
Below are the steps to install the free SSL certificate on an Ubuntu server running Apache
apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install certbot
certbot certonly --standalone --standalone-supported-challenges http-01 -d <server fqdn>
It will ask, “Temporary” or “Standalone” server. Choosing temporary is fast and easy.
After that it will ask a few more general question like, email id for contact etc. Once all details supplied it will install the certificate and show the path where the certificates and key file is stored. Please make a note of the path for later use or reference.
The certificates are valid for 90 days only. After the 90 days it has to be renewed. What can be done to solve this is to set a cron that will automatically renew the certificate after every 60 days or so. Steps to set cron below
Open Cron file using
crontrab -e
Now put the following line to renew the certificate automatically every 2 months
0 0 1 */2 * certbot renew --noninteractive --post-hook "systemctl restart mosquitto apache2"
Save and exit Cron file.
All set for a secured connection.
Steps for other Servers can be found here https://certbot.eff.org/
How to Setup MQTT Server on a Windows 10 Desktop
- Download the Win32 installer from the below link (I couldn’t successfully installed the CygWin version)
https://mosquitto.org/download/ - Once downloaded, install the package
- During the start of the installation process it will show links from where some dependencies will have to be downloaded
- Copy/Open the links
- Once the installation finishes go to the websites opened in the previous step
- Download the OpenSSL installer and the pthreadVC2.dll file
- Install the OpenSSL
- Copy the pthreadVC2.dll file to the directory where mosquitto executable has been installed. Normally C:\Program Files (x86)\mosquitto
- Open folder where OpenSSL got installed (normally C:\OpenSSL\) and open the lib folder (normally C:\OpenSSL\lib)
- Copy ssleay32.lib and libeay32.lib into the folder where mosquitto executable has been installed.
- Please note – while copying the files Windows might ask for giving Admin permission. Go ahead.
- At this point Mosquitto should be ready to run————————————————————–
- Now testing mosquitto
- Open a Command Prompt
- Goto the folder where mosquitto is installed
- Give command mosquitto.exe -v -c mosquitto.conf
- The server should now start listening on port 1883
- Now open another Command Prompt
- Give the command mosquitto_sub -h localhost -t channel1/data1
- Open a third Command Prompt and give the command mosquitto_pub -h localhost -t channel1/data1 -m “test data”
- In the command prompt where we used mosquitto_sub (step 18 and 19) will show the message “test data” sent from the third command prompt.
- Reaching this point means mosquitto is working fine———————————————-
- To secure the transmission we can username and password authentication
- Open a command prompt with Admin privileges
- Goto the folder where Mosquitto is installed
- Create a password file (for the first time only) using the command mosquitto_passwd.exe -c passfile.txt username
- It will ask for password. Give the password and confirm the password
- After this point further users can be added using the below command mosquitto_passwd.exe -b passfile.txt username password
Please note – this time we supplied the password also along with the username - Now edit the config file (mosquitto.conf normally located in C:\Program Files (x86)\mosquitto) to enforce only authenticated data transfers
- Uncomment allow_anonymous and set it false
- Uncomment password_file and put the password file name after it. It will look like password_file passfile.txt
- Now onwards all sub and pub requests will have to be with username and password of a user whose details exists in the password file. Examples below
mosquitto_pub -h localhost -t channel1/data1 -m "test data" -u john -P johnpass mosquitto_sub -h localhost -t channel1/data1 -u jane -P janepass
- Access control can be done using a acl file or using mosquitto-auth-plug (https://github.com/jpmens/mosquitto-auth-plug)
- There should be a aclfile.example inside your mqtt directory. If not then also no problem we will shortly see the contents of the file below.
- Create a file with any name. Here we will use aclFile.txt
- In the mosquitto.conf file uncomment acl_file and put the name of your acl file after that. It will look something like acl_file aclFile.txt
- Example content of aclFile.txt as below
# user jane given full permission to channel1/data1 and only read permission to channel1/data2 user jane topic channel1/data1 topic read channel1/data2 # user jane given full permission to both data1 and data2 channel user john topic channel1/#
Please put in your suggestions in comment.
MQTT on Windows — Download link of Word File containing the above steps. WordPress had made some filenames missing. So uploaded the original word doc.
DHT 22 or AM2302 – Temperature and Humidity sensor
Mostly made by Aosong. Here is the datasheet. The library from Adafruit on GIT works fine. The library has been attached here also in case the GIT one is not available for any reason.
There are example codes in the library. Wiring the module is pretty simple.
The module works on 3.3v – 5v and uses I2C for communication.
As per the datasheets the module will malfunction under harsh conditions and contamination. But it may recover if left for sometime.
Change the photo auto retrieved by FB when posting link or URL
- Open this link https://developers.facebook.com/tools/debug/
- Paste the URL
- Hit “Debug”
- Hit “Scrape Again”
- Didn’t work? Use the “Batch Invalidator” to invalidate the cache and then try steps 3 and 4
- Didn’t work? Try “Scrape Via API” and then try steps 3 and 4
Aletrnate URL : https://developers.facebook.com/tools/debug/og/object/
Install PHPMumbleAdmin
https://sourceforge.net/projects/phpmumbleadmin/?source=typ_redirect
Quick Guide of Requirements
Install PHP* 5.3
wget http://in1.php.net/distributions/php-5.3.29.tar.bz2
tar -xvf php-5.3.29.tar.bz2
cd php-5.3.29
./configure
make
make install
Notes:
Additional packages might need to be installed
apt-get install gcc
apt-get install libxml2-dev
apt-get install libapache2-mod-php5
Install ZeroC ICE (Slice)
Though the requirement guide says the max version should be 3.4.x, but 3.6 also works fine.
- apt-get install php5-zeroc-ice
- apt-get install php5-zeroc-ice-dev
- wget https://zeroc.com/download/GPG-KEY-zeroc-release
- apt-key add GPG-KEY-zeroc-release
- apt-add-repository “deb http://zeroc.com/download/apt/ubuntu14.04 stable main”
- apt-get update
- apt-get install php5-zeroc-ice
- apt-get install libmcpp0 php5-common php5-json
- apt-get remove libzeroc-ice3.6 // apt-get remove libzeroc-ice
- apt-get install zeroc-ice-all-runtime zeroc-ice-all-dev
- apt-get install db5.3-util
- apt-get source zeroc-ice3.6
- apt-get install php5-zeroc-ice
- apt-get install php5-zeroc-ice-dev
- apt-get install zeroc-ice-slice
Install DBUS
- wget http://dbus.freedesktop.org/releases/dbus/dbus-1.2.14.tar.gz
- tar -zxf dbus-1.2.14.tar.gz
- Add Group if not there:
groupadd -g 18 messagebus && useradd -c "D-Bus Message Daemon User" -d /var/run/dbus \ -u 18 -g messagebus -s /bin/false messagebus
-
./configure --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --disable-doxygen-docs \ --disable-xml-docs \ --disable-static \ --disable-systemd \ --without-systemdsystemunitdir \ --with-console-auth-dir=/run/console/ \ --docdir=/usr/share/doc/dbus-1.10.8 && make
-
make install
Notes Additional packages might be needed apt-get install libexpat1-dev
Install PHPMumleAdmin
- wget http://tenet.dl.sourceforge.net/project/phpmumbleadmin/phpMumbleAdmin-0.4.4.zip
- unzip phpMumbleAdmin-0.4.4.zip
- Open in browser
- Default SuperUser is “SuperUser” and the password that was given at the time of setup of Mumble Server.
Notes:
Had to change all folders to 777 ( find ./ -type d -exec chmod 777 {} \; ) as quick fix for folder permissions.
To-do:
Need to cleanup, optimize the installation and set proper folder permissions.
Installing Mumble on Ubuntu 14.04
The installation steps
- add-apt-repository ppa:mumble/release
- apt-get update
- apt-get install mumble
- apt-get install mumble-server
- dpkg-reconfigure mumble-server (select High in the priority step)
Adding Users
- adduser <username>
Addition of channels
- Can be done from the Mumble desktop client (The desktop clients are available here http://www.mumble.com/mumble-download.php)
Wiki Page
Todo:
- http://wiki.mumble.info/wiki/Features#Access_Control_Groups
- http://wiki.mumble.info/wiki/Authenticators
USB To RS232 convertor drivers
The two most popular USB to RS232 converters are based on either “CH340G” chip or the “PL2303” chip. Below are the drivers (latest as on 02-March-2016) for both.
While purchasing, check if the module has the DTR pin or not. It is not a necessity but will be easy to program the Arduino boards. Without the DTR line the Arduino will have to be RESET manually while uploading the codes to the Arduino.