06 Jun 2014 Matteo Mattei backup centos plesk ftp mysql I am working for a client that needs a system to backup a CentOS server hosted by OVH that uses Plesk. I didn’t know that Plesk already implemented a way to backup all domains and MySQL data so I cerated a script to do that:
As you can see this script keeps the last 7 days of backups. However after googling a while I found that the same thing could be done directly using a Plesk utility called pleskbackup, so I developed an alterlate script that uses it:
I hope it can help you.
07 Jul 2013 Matteo Mattei audio skype ubuntu If you have problems with Skype audio on Ubuntu (distortion, croak, noise…) the simple way to get it fixed is editing the file /etc/pulse/default.pa, change one line and restart the system.
From:
load-module module-udev-detect use_ucm=0
To:
load-module module-udev-detect use_ucm=0 tsched=0
For simplicity you can execute the following command that will do all the job:
sudo sed -i "{s/^load-module module-udev-detect use_ucm=0$/load-module module-udev-detect use_ucm=0 tsched=0/g}" /etc/pulse/default.pa
Restart now the system and the Skype audio should work fine!
03 Feb 2013 Matteo Mattei bash linux php email postfix security server spam If you have a website in a virtualhost environment that is under attack and starts sending tons of emails, is sometimes difficult to understand from where the attack is started (especially if you have several virtual hosts). However with a little PHP script you can understand from which folder the attack is coming.
Create the following file in a secure place and call it phpsendmail:
Now create the log file and set the correct permissions:
touch /var/log/mail_php.log
chmod 777 /var/log/mail_php.log
chmod 777 /path/to/phpsendmail
Now you have to edit the php.ini configuration (/etc/php5/apache2/php.ini in Debian). Search the [mail_function] section and set it in this way:
[mail function]
;SMTP = localhost
;smtp_port = 25
sendmail_path = /path/to/phpsendmail
Now you can restart Apache and look at /var/log/mail_php.log file.
Its content shoud be someting similar to this:
2013-02-03 17:50:57 To: mail1@domain1.com From: mail2@domain2.com ==> /var/www/vhosts/domain1/httpdocs
2013-02-03 17:50:59 To: mail3@domain3.com From: mail4@domain4.com ==> /var/www/vhosts/domain2/httpdocs/libraries
2013-02-03 17:51:02 To: mail5@domain5.com From: mail6@domain6.com ==> /var/www/vhosts/domain2/httpdocs/assets
Update August 2014 —————— I found a more convenient way to do it… and it saved my life with some servers that were affected by thousands of SPAM emails. You just need to create a couple of files:
Now, in the same way as above set the correct permissions and edit php.ini:
chmod +x /usr/local/bin/sendmail-wrapper
chmod +x /usr/loca/bin/env.php
[mail function]
;SMTP = localhost
;smtp_port = 25
sendmail_path = /usr/local/bin/sendmail-wrapper
auto_prepend_file = /usr/local/bin/env.php
Restart Apache and look at /var/log/mail.info. Now the content is similar to the following:
Aug 18 20:35:42 vps74403 logger: sendmail-wrapper.sh: site=www.example.com, client=77.221.130.44, script=/WP/wp-content/uploads/flags/plugin.php, pwd=/var/www/vhosts/example.com/WP/wp-content/uploads/flags, uid=, user=www-data
Aug 18 20:35:42 vps74403 logger: sendmail-wrapper.sh: site=www.example.com, client=77.221.130.44, script=/WP/wp-content/uploads/flags/plugin.php, pwd=/var/www/vhosts/example.com/WP/wp-content/uploads/flags, uid=, user=www-data
Aug 18 20:35:42 vps74403 logger: sendmail-wrapper.sh: site=www.example.com, client=77.221.130.44, script=/WP/wp-content/uploads/flags/plugin.php, pwd=/var/www/vhosts/example.com/WP/wp-content/uploads/flags, uid=, user=www-data
05 Jan 2013 Matteo Mattei python py2exe tk When I have to develop background console applications in Python that have to be executed in Windows, I usually use py2exe and Inno Setup for creating installer. However the big issue is always how to report and show errors to the users. My preferred solution is to keep the application as a pure console application (no graphical), set the py2exe application as a window application and handle the errors with graphical messagebox.
And since the Tk library is included in the Python standard library, it is worth using it.
Lines 10 and 11 are needed to don’t show the main Tk window in background. Updated with support for both python 2.7 and python 3.x