============== Install postgresql 9.6 ============== wget https://yum.postgresql.org/9.6/redhat/rhel-7.4-x86_64/pgdg-centos96-9.6-3.noarch.rpm rpm -i pgdg-centos96-9.6-3.noarch.rpm yum install postgresql96-server postgresql96-contrib /usr/pgsql-9.6/bin/postgresql96-setup initdb mv /usr/bin/pg_ctl{,-orig} echo '#!/bin/bash' > /usr/bin/pg_ctl echo '"$0"-orig "${@/unix_socket_directory/unix_socket_directories}"' >> /usr/bin/pg_ctl chmod +x /usr/bin/pg_ctl ============== Start importing/upgrading data to new server ============== systemctl stop postgresql # At this point both servers are stoped # As Postgres user su postgres cd ~ /usr/pgsql-9.6/bin/pg_upgrade -v -b /usr/bin/ -B /usr/pgsql-9.6/bin/ -d /var/lib/pgsql/data/ -D /var/lib/pgsql/9.6/data/ exit # Back to root user # Rollback pg_ctl mv -f /usr/bin/pg_ctl{-orig,} #### APPLY OLD postgresql config params to postgresql-9.6 (pg_hba.conf, postgresql.conf) (manually), maybe use pgtune for postgresql.conf... ============== START NEW SERVER AND DISABLE THE OLD ============== systemctl start postgresql-9.6 systemctl enable postgresql-9.6 systemctl disable postgresql # temporary ln -s /usr/pgsql-9.6/bin/psql /usr/bin/psql --force ln -s /usr/pgsql-9.6/bin/pg_dump /usr/bin/pg_dump --force # Postgres user su postgres cd ~ ./analyze_new_cluster.sh exit # back as root # remove old postgresql yum remove postgresql # Export new path echo 'export PATH=$PATH:/usr/pgsql-9.6/bin' >> /etc/bashrc exit, SSH back to host and check if new path is ok for postgres commands Finally decide if you want to remove the old postgres cluster (data folder)
Category: Tutorials
Diferent tutorials
MemcacheD php client for development purpose on Laravel 5
This class simulates the real Memcached PHP extension (which doesn’t exit) on windows (php_memcached.dll) – Note the “d”.
I forked and modified this repository so that it works with few basic methods of laravel 5… Please don’t use this class in production, use it only for development purposes.
Github repo: https://github.com/altinukshini/memcached-client
Configuration in Windows machine
Before you do anything else, make sure you have Memcached server installed. Here’s a blog that shows how to do that (follow step A): https://commaster.net/content/installing-memcached-windows
Assuming you have Memcached server installed, proceed with the following.
Place memcached.php file in C:\xampp\php\pear folder
In your laravel 5 installation, edit AppServiceProvider.php and place the code below inside the boot() method.
if (!class_exists('Memcached')) { include ("memcached.php"); }
so it should look something like:
public function boot(Kernel $kernel) { if (!class_exists('Memcached')) { include ("memcached.php"); } }
…you should be good to go!
Restrict RoundCube login username to one domain
Roundcube is a client software to access IMAP mailboxes. If you already came to this post, then I’m sure you’ve figured out that RoundCube does not restrict domains in the login form, which means that as long as your username and password are OK, you can basically use any domain you like in your username field. Exc: @gmail.com, @yahoo.com etc.
This is not something that Roundcube deals with, because it should be taken care of on your IMAP server configuration, and if the IMAP server does not check for your full username (domain included), and allows access with any other domain, you get access :). However, even if it’s taken care of on your IMAP server, handling this in RoundCube will prevent an unnecessary request to your IMAP server.
One of the configuration options in Roundcube helps you append the domain to a clean username login.
Exc: if in your username field you type only the username “username” without the “@domain.com” then roundcube can help you by appending the “@domain.com”. This is helpful only for IMAP servers that require full e-mail addresses for login. You can specify this by editing $rcmail_config[‘username_domain’] variable in config/defaults.inc.php
By default that variable is blank as below:
$config['username_domain'] = '';
Above that variable, you’ll find a short description on what options can be set to this variable, one of which you might assume it is:
%d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
But in cases when your roundcube installation is in a different host/domain server than your original domain that is needed to authenticate in your IMAP server, that will not help, therefore use your domain as follows:
$config['username_domain'] = 'yourdomain.com';
Now if you type “username” (without the domain) in the username field, roundcube will append “@yourdomain.com” and the request to your IMAP server will have your username sent as “username@yourdomain.com”, otherwise if you already specify the domain in your username field, it will make the login request with the specified domain which in this case can be anything (@gmail.com, @yahoo.com etc). Continue reading “Restrict RoundCube login username to one domain”
Track user last-login with Dovecot and MySQL in Postfix setup
This will help you to set up SQL based user last-login tracking.
Beware of potential SQL injection holes if you allow users to have special characters in usernames.
Create a MySQL table named “lastauth”
CREATE TABLE IF NOT EXISTS `lastauth` ( `user` char(32) NOT NULL, `remote_ip` char(18) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY `user` );
Create the bash script in /usr/bin/trackAuth.sh
#!/bin/bash # $USER > login username # $IP > remote ip address MYSQL_USER='USERNAME' PASSWD='PASSWORD' DB_HOST='DBHOST' DB_NAME='DNAME' CHECK_USER=`mysql -h${DB_HOST} -u${MYSQL_USER} -p${PASSWD} ${DB_NAME} -AN -e "SELECT user from lastauth WHERE user='$USER' LIMIT 1"` if [ $CHECK_USER == "$USER" ]; then if [ X"${USER}" != X"dump-capability" ]; then mysql -h${DB_HOST} -u${MYSQL_USER} -p${PASSWD} ${DB_NAME} >/dev/null 2>&1 <<EOF UPDATE lastauth SET remote_ip="$IP", timestamp=NOW() WHERE user='$USER'; EOF fi else if [ X"${USER}" != X"dump-capability" ]; then mysql -h${DB_HOST} -u${MYSQL_USER} -p${PASSWD} ${DB_NAME} >/dev/null 2>&1 <<EOF INSERT INTO lastauth (user, remote_ip, timestamp) VALUES("$USER", "$IP", NOW()) EOF fi fi exec "$@"
Continue reading “Track user last-login with Dovecot and MySQL in Postfix setup”
Set up NRPE (v2.13) with xinetd in ubuntu server 14.04
Update softwar repo, install gcc, create temporary installation dirs, create nagios user, install xinetd, download and compile NRPE…
apt-get update ; apt-get install gcc -y ; mkdir /tmp/download ; useradd nagios -s /bin/false ; mkdir /usr/local/nagios ; chown nagios:nagios /usr/local/nagios ; cd /tmp/download ; apt-get install xinetd -y ; wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz ; wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz ; tar zxvf nrpe-2.13.tar.gz ; cd nrpe-2.13 ; ./configure --disable-ssl --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --libexecdir=/usr/local/nagios/libexec/ --bindir=/usr/local/nagios/bin/ --prefix=/usr/local/nagios ; make all ; make install-plugin ; make install-daemon ; make install-daemon-config ; make install-xinetd ; update-rc.d xinetd defaults
Edit /etc/xinetd.d/nrpe
nano -w /etc/xinetd.d/nrpe
add ip address of the monitoring nagios server
only_from = 127.0.0.1 <ip_address_of_monitoring_server>
Edit /etc/services
nano -w /etc/services
Make sure this line ‘nrpe 5666/tcp # NRPE‘ is on the file, or add it in the end, then save, exit and restart xinetd:
service xinetd restart
netstat -at | grep nrpe
Install nagios-plugins
cd ../ ; tar zxvf nagios-plugins-2.1.1.tar.gz ; cd nagios-plugins-2.1.1 ; ./configure --with-nagios-user=nagios --with-nagios-group=nagios ; make ; make install
Config file of NRPE (nrpe.cfg) is located in /usr/local/nagios/etc/nrpe.cfg
You can add different commands in there Continue reading “Set up NRPE (v2.13) with xinetd in ubuntu server 14.04”
/dev/mapper/cryptswap1 is not ready yet or not present
I had this error going for a long time now (usually while my system was loading from a reboot) and my swap space would usually just not work…
I finally had some time to deal with that.
I couldnt even reformat it in gparted or something similar…
This is how I fixed it:
First you turn your swap space off
$ sudo swapoff -a
commented out the existing swap line in /etc/crypttab
comment out the swap line in /etc/fstab
# /dev/mapper/cryptswap1 none swap sw 0 0
reboot your pc/laptop
now you should be working without a swap space, try reformatting your partition in gparted to a linux-swap type (in my case it was /dev/sda3)
after successfully reformatting it, proceed this way: Continue reading “/dev/mapper/cryptswap1 is not ready yet or not present”
Copy: Configure IPSEC VPN connection with Racoon, Kannel and RapidSMS in Debian server
This guide will address establishing a remote connection with a mobile operator, create a data collecting RapidSMS application, and everything in between – specifically using the Kannel SMS gateway.
I realize this guide will only cater to a very specific group of technicians seeking to use the following technologies:
-IPSec VPN, as their means of communicating with a mobile operator (SMS Center).
-Kannel, as the SMS Gateway which talks to the SMS Center, relaying messages via HTTP requests.
-RapidSMS, as their choice of data-collection and communication tool.
This guide is aimed at demystifying any confusion that may occur in an otherwise obscure and arcane world of SMS. I will use my very own examples and clarify version numbers to show what works. I am using the Debian 6.0 “Squeeze” release.
VPN
We will begin by establishing a Virtual Private Network as the very first step – without it, no data would be able to get in or out from the SMS Center.
At this point, you should have already made arrangements with at least one mobile operator to establish a VPN with their SMS Center. Additionally, they should have provided you with a list of parameters necessary for the connection, these include authentication methods, source IP addresses, ports, keys, and much more.
This guide will be focusing on establishing an IPSec VPN – solely because of the specific parameters given by my mobile operator.
Below is a copy of the sheet of parameters given to me by the local mobile operator post-agreement, use it to cross-reference with the configurations in the next few steps: Continue reading “Copy: Configure IPSEC VPN connection with Racoon, Kannel and RapidSMS in Debian server”
Recursively change permissions to all subdirectories and files in Drupal
I used to have problems with Drupal’s sites/default/files/* directories permissions because for some reason they got messed up and this is the script that I used to fix that.
find . -type d -exec chmod 753 {} \;
this is for the files:
find . -type f -exec chmod 664 {} \;
Getting started with PhoneGap for Android
First of all a short description of what’s phonegap:
PhoneGap is an open source implementation of open standards. That means developers and companies can use PhoneGap for mobile applications that are free, commercial, open source, or any combination of these.
PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores. PhoneGap leverages web technologies developers already know best… HTML and JavaScript.
During this blog I’ll be showing mostly the main things you should be knowing when you start working with PhoneGap.
So what I’ll be talking about will be:
- Importing some of the libraries that you will need…
- How to make your application go Full Screen in Phonegap
- How to add a Splash Screen and give it a (delay time)
- How to create a basic menu with quit and reload function.
- How to change the application icon instead of the default android one.
- Where to put some specific lines for the code to work properly.
- Make app compatible with older versions of Android.
OK, first of all you have to set up your environment for android developement as you have to follow the guide provided from phonegap here. Continue reading “Getting started with PhoneGap for Android”
Enable email notifications in Open Atrium
I was struggling to find the way to enable email notifications in Open Atrium because they just didn’t work after the install and finally I found out the way that works, no need for SMTP or any other module.
Only 2 steps:
1. Install/Enable PHPmailer.
2. Enable “Immediate” notification on the admin settings page
1. Steps to install PHPMailer
If you are using php5 then take this source and extract it inside:
YourAtriumRootFolder/profiles/openatrium/modules/contrib/messaging/messaging_phpmailer
and make sure you save the extracted folder name like: “PHPMailer” (case sensitive)
Go to Admin > Site building > Modules and enable “Messaging PHPMailer” module.
2. Steps to enable the notifications
Go to Admin > Messaging and Notifications > Notifications Settings and tick/enable “Immediate sending” and Save Configuration.
gimp : Depends: libglib2.0-0 (>= 2.31.2) but 2.30.0-0ubuntu4 is to be installed
After I did an upgrade gimp was automatically removed and then I couldn’t install it.
Every time I tried it showed me the error below..
It took me a while to find where is the problem and fix it, so here is what I did.
This is the error that showed when I tried to install gimp:
$ sudo apt-get install gimp Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: gimp : Depends: libglib2.0-0 (>= 2.31.2) but 2.30.0-0ubuntu4 is to be installed E: Unable to correct problems, you have held broken packages.
Then I did a:
$ apt-cache policy gimp gimp: Installed: (none) Candidate: 2.7.5-2012020901~oo Version table: 2.7.5-2012020901~oo 0 500 http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu/ oneiric/main amd64 Packages 2.7.4-2011102201~oo 0 100 /var/lib/dpkg/status 2.6.11-2ubuntu4 0 500 http://al.archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages
After that I saw that the problem stands at my PPA, (I actually added that months ago just to test some new features, I dont really remember)
What I did is, I removed my PPA from matthaeus123
(I just edited the files and commented the lines) Continue reading “gimp : Depends: libglib2.0-0 (>= 2.31.2) but 2.30.0-0ubuntu4 is to be installed”