Posts

Showing posts from February, 2014

Watch videos in linux terminal

To install Livestreamer on Fedora, CentOS or RHEL:  yum install python-pip   pip install livestreamer  Run livestreamer command with the URL:  livestreamer http://www.youtube.com/watch?xxxxxxxxxx You can also adjust the quality, livestreamer http://www.youtube.com/watch?xxxxxxxxx 360p Also with specific palyer, livestreamer --player=mplayer http://www.youtube.com/watch?xxxxxxxxx  360p  

script to create tar files within specific size

If you want to take backup tar of public_html folder with tar files have specific size. Please use below command. tar -cv public_html/* | split -b 25000K --suffix-length=4 --numeric-suffix - sara.tar. It creates many tar files with size of 25MB. If you place this files under same directory and execute the below command to extract it. cat falooka.tar.* | tar xvf - it provides the public_html folder. I already tested this script. Use it.

search and remove specific content in files.

f above command gives you correct output, execute following command to perform actual cleaning: grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak 's/<?php eval(base64_decode[^;]*;/<?php\n/g' Executing above will remove eval(*) codes.  Above command will also generate a backup version of files it will modify. For example, if it removes code from index.php , you will find a new file index.php.bak in same directory with original content of index.php Missing <?php tag in the beginning: To add “<?php: tag in the beginning of index.php files, in case if you remove it accidentally use following command: find /var/www/ -name "index.php" | grep "/htdocs/index.php" | xargs grep -L "<?php" | xargs sed -i "1s/^/<?php \n/" Don’t worry. If you already have a “<?php ” tag in the beginning, it won’t be added again. Extra Newlines at the top! If you find after clean

Redirect the request from Apache to tomcat using mod_proxy

If you want to redirect the apache request to tomcat[8080],use mod_proxy module. Eg: You want access http://192.168.1.10:8080/support with this url example.com/support. Please go to virtual host entry for example.com in httpd.conf, <VirtualHost 192.168.1.10:80> ServerAdmin support@example.com DocumentRoot /var/www/example.com/public_html ServerName example.com ServerAlias www.example.com ScriptAlias /cgi-bin/ /var/www/example.com/public_html/cgi-bin #Options +Indexes <Directory /var/www/example.com/public_html/cgi-bin> AddHandler cgi-script .cgi .pl </Directory> ProxyPass /support/ http://192.168.1.10:8080/support/ RewriteEngine On RewriteOptions Inherit </VirtualHost> Also if you want to redirect some specific url's to another port use below method, ProxyPassReverse / http://%{HTTP_HOST}:8080/ RewriteEngine on RewriteCond  %{REQUEST_URI} .*\.(flv|mp4|mp3)$ RewriteRule ^/(.*) http://%{HTTP_HOST}:8080/$1 [P] In this above exampl

copy some rules from a file to all .htaccess files

find /home/*/public_html -name ".htaccess" -exec cp {} "{}_$(date "+%F")_bak" \; for i in `cat htsearch.txt`; do echo $i; rsync -avzr --append /htaccess $i; sleep 1; done;

Remote smtp setup in exim

 - Copied default exim.conf from other cpanel server and added the below entries as client updated and restarted exim. Mails started working fine. In exim.conf: -------------- begin authenticators mailjet_login: driver = plaintext public_name = LOGIN client_send = : APIKey : APISecret [ Corrsponding key values here ] * Only include the begin authenticators if it does not exist already, if it does just paste the rest below it. 2) Add a route in the Router Configuration: send_via_mailjet: driver = manualroute domains = ! +local_domains transport = mailjet_smtp route_list = "* in.mailjet.com::587 byname" host_find_failed = defer no_more 3) Add a transport to the Transport Configuration: mailjet_smtp: driver = smtp hosts = in.mailjet.com hosts_require_auth = in.mailjet.com hosts_require_tls = in.mailjet.com

Trouble shoot Apache segmentation fault issues

Server restarted gracefully. Graceful restart requested, doing restart [Thu Apr 26 02:17:26 2012] [notice] seg fault or similar nasty error detected in the parent process We found the problem by using  strace  to watch httpd activity during failure. I had found that a  /etc/init.d/httpd stop  and  /etc/init.d/httpd start  worked fine, but  /etc/init.d/httpd graceful  or  apachectl graceful  brought the system down. we find the parent process to all other httpd processes, the one with ‘1’ as the parent process, and strace it to watch activity using ps, ps -aef | grep httpd Go to screen & run, strace -aef -p 8021 2>&1 | tee /tmp/strace.out issue the command apachectl graceful -Watch the file strace.out, We see access for  ioncube_loader_lin_5.3.so , which succeeds with a file handle (20), and access for an  ffmpeg.so  module, which fails with ENOENT (-1). The process then logs to the error log, and a segfault occurs. Commenting out the  f