Plesk email users and passwords
Wed, 06/09/2010 - 14:42 — sandipBelow is sql, if you ever need to test out your users email accounts on plesk server:
mysql> use psa
mysql> select concat(mail_name,"@" ,name) as email_address, accounts.password from mail left join domains on domains.id=mail.dom_id left join accounts on accounts.id=mail.account_id;
- sandip's blog
- Login or register to post comments
Check for entries in passwd file
Mon, 05/10/2010 - 00:51 — sandipCheck for entries in passwd file:
getent passwd username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
id username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
awk -F':' '$1 ~ /^username$/ {print $0}' /etc/passwd | grep -w username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
- sandip's blog
- Login or register to post comments
How to mount RAMFS, TMPFS in Centos, Redhat, Fedora, Ubuntu
Sat, 05/08/2010 - 11:58 — ashwinmuni
How to Use and mount RAMFS / TMPFS in Centos, RHEL, Fedora, Ubuntu?
Definition :
RAMFS Random Access Memory Filing System
TMPFS Temporary File System / Temporary File Storage
RAMFS / TMPFS is used to assign or allocate a part of physical memory to be used as a individual partition which can be used for storing data (Reading, Writing) like all other Disk partition on a system. As the data is stored in RAM (Random Access Memory) it is much faster than that of writing or reading from a System Physical disk Partition.
- ashwinmuni's blog
- Login or register to post comments
- Read more
Using a .forward to send mail to multiple accounts
Thu, 05/06/2010 - 14:00 — sandipIf you put multiple addresses in a .forward file, a copy will be sent to each.
remoteuser1@domain.tld, remoteuser2@domain.tld, remoteuser3@domain.tld
If you want to keep a copy of each message in the original account without causing a .forward infinite loop, put a backslash in front of the account name.
\localuser, remoteuser1@domain.tld, remoteuser2@domain.tld, remoteuser3@domain.tld
- sandip's blog
- Login or register to post comments
Howto Install RED5 Flash Media Server in Fedora 11, Centos 5.4, Redhat
Thu, 04/15/2010 - 01:49 — ashwinmuniRed5 is an Open Source Flash Media Server written in Java that supports:
* Streaming Audio/Video (FLV and MP3)
* Recording Client Streams (FLV only)
* Shared Objects
* Live Stream Publishing
* Remoting (AMF)
This is a reverse engineered open source project which aims to produce a feature-complete implementation written in Java. It os one of the Full implementation RTMP servers other than:
Adobe Flash Media Server,
Onlinelib VCS Video Communication Server
Wowza Media Server
WebORB Integration Server
haXeVideo
Search bot report
Mon, 03/22/2010 - 13:41 — sandipHere is a simple bash script to get a daily report of search bot results of Success (200) and Failed (404) hits:
#!/bin/bash
# bot_report.sh
# usage: ./bot_report.sh [botName] [logPath]
# default: ./bot_report.sh Googlebot /var/log/httpd/access_log
############################ ##########
# Run this in a daily cron &n bsp; &n bsp; #
# 59 23 * * * /path/to/bot_report.sh #
############################ ##########
# Commands
GREP=/bin/grep
DATE=/bin/date
MKDIR=/bin/mkdir
AWK=/bin/awk
SORT=/bin/sort
UNIQ=/usr/bin/uniq
TMPWATCH=/usr/sbin/tmpwatch< br />CAT=/bin/cat
MAIL=/bin/mail
ECHO=/bin/echo
# Global Variables
DEFAULT_BOT_NAME=Googlebotr />DEFAULT_LOG_FILE=/var/log/ht tpd/access_log
if [ -z "$1" ]; then
BOT_NAME=${DEFAULT_BOT_NAME}r />else
BOT_NAME=$1
fi
if [ -z "$2" ]; then
LOG_FILE=${DEFAULT_LOG_FILE}r />else
LOG_FILE=$2
fi
PREFIX_LOG=`$ECHO $LOG_FILE | sed 's/\//_/g'`
TMP_LOG_PATH=/tmp/bot_report
TMP_LOG_FILE=${TMP_LOG_PATH} /${PREFIX_LOG}_`${DATE} +%F`.log
TMP_REPORT_FILE=${TMP_LOG_PA TH}/${BOT_NAME}_report.txt
EMAIL=user@domain.tld
###########################< br /># Nothing to change below #
###########################< br />
# Produce a temp file to work with for todays date
tmp_file_out() {
[ -d "${TMP_LOG_PATH}" ] || $MKDIR ${TMP_LOG_PATH}
if [ ! -f "${TMP_LOG_FILE}" ]; then
$GREP `$DATE +%d/%b/%Y` $LOG_FILE > $TMP_LOG_FILE
fi
}
# Clean up temp file older than a day
tmp_file_clean() {
$TMPWATCH 24 $TMP_LOG_PATH
}
# Create report
report_out() {
$ECHO "######## Success Hits ########" > $TMP_REPORT_FILE
$GREP " 200 " $TMP_LOG_FILE | $AWK -v bot="$BOT_NAME" '$0 ~ bot {print $7}' | $SORT | $UNIQ -c | $SORT -rn >> $TMP_REPORT_FILE
$ECHO >> $TMP_REPORT_FILE
$ECHO "######## Failed Hits ########" >> $TMP_REPORT_FILE
$GREP " 404 " $TMP_LOG_FILE | $AWK -v bot="$BOT_NAME" '$0 ~ bot {print $7}' | $SORT | $UNIQ -c | $SORT -rn >> $TMP_REPORT_FILE
}
# Mail report
mail_report() {
$CAT $TMP_REPORT_FILE | $MAIL -s "bot report: ${BOT_NAME}" $EMAIL
}
#
# Main
#
tmp_file_out
report_out
mail_report
tmp_file_clean
exit 0
- sandip's blog
- Login or register to post comments
php with mysqlnd support
Sat, 03/13/2010 - 02:11 — sandipYou can now get the latest PHP with mysqlnd (MySQL Native Driver) support via remis' yum repository as mentioned in PHP-5.3,-zts-and-mysqlnd. The blog mentions that this is enabld in php-zts. However, no php-pecl extension are available and neither are some of the extensions thread safe. So I went about rebuilding php package from source for mysqlnd support.
-
Download the source php rpm from http://rpms.famillecollet.com/
Install and apply the below diff patch to the spec file via `patch -p0 < {new_patch_file}` where "new_patch_file" has the below contents:
--- php-5.3.2-remi.spec.orig 2010-03-11 23:07:04.000000000 -0600
+++ php-5.3.2-remi.spec 2010-03-11 23:36:03.000000000 -0600
@@ -24,6 +24,7 @@
%global phpversion 5.3.2
# Optional components; pass "--with mssql" etc to rpmbuild.
+%define with_mysqlnd %{?_with_mysqlnd:1}%{!?_with_m ysqlnd:0}
%define with_oci8 %{?_with_oci8:1}%{!?_with_oci8 :0}
%define with_ibase %{?_with_ibase:1}%{!?_with_iba se:0}
%if %{?rhel}%{?fedora} > 4
@@ -677,6 +678,11 @@
%if %{?fedora}%{?rhel:99} >= 10
&nbs p; --with-system-tzdata \
%endif
+%if %{with_mysqlnd}
+ &nb sp; --with-mysql=shared,mysqlnd \
+ &nb sp; --with-mysqli=shared,mysqlnd \
+ &nb sp; --with-pdo-mysql=shared,mysqln d \
+%endif
$*
if test $? != 0; then
tail -500 config.log
@@ -704,8 +710,13 @@
&nbs p; --enable-dba=shared --with-db4=%{_prefix} \
&nbs p; --with-xmlrpc=shared \
&nbs p; --with-ldap=shared --with-ldap-sasl \
+%if %{with_mysqlnd}
+ &nb sp; --with-mysql=shared,mysqlnd \
+ &nb sp; --with-mysqli=shared,mysqlnd \
+%else
&nbs p; --with-mysql=shared,%{_prefix} \
&nbs p; --with-mysqli=shared,%{_bindir }/mysql_config \
+%endif
%ifarch x86_64
&nbs p; %{?_with_oci8:--with-oci8=shar ed,instantclient,%{_libdir}/or acle/%{oraclever}/client64/lib ,%{oraclever}} \
%else
@@ -725,7 +736,11 @@
&nbs p; --enable-fastcgi \
&nbs p; --enable-pdo=shared \
&nbs p; --with-pdo-odbc=shared,unixODB C,%{_prefix} \
+%if %{with_mysqlnd}
+ &nb sp; --with-pdo-mysql=shared,mysqln d \
+%else
&nbs p; --with-pdo-mysql=shared,%{_pre fix} \
+%endif
&nbs p; --with-pdo-pgsql=shared,%{_pre fix} \
&nbs p; --with-pdo-sqlite=shared,%{_pr efix} \
&nbs p; --with-pdo-dblib=shared,%{_pre fix} \
@@ -756,6 +771,16 @@
&nbs p; --with-recode=shared,%{_prefix }
popd
+%if %{with_mysqlnd}
+without_shared="--with out-gd \
+ &nb sp; --disable-dom --disable-dba --without-unixODBC \
+ &nb sp; --disable-xmlreader --disable-xmlwriter \
+ &nb sp; --without-sqlite \
+ &nb sp; --disable-phar --disable-fileinfo \
+ &nb sp; --disable-json --without-pspell --disable-wddx \
+ &nb sp; --without-curl --disable-posix \
+ &nb sp; --disable-sysvmsg --disable-sysvshm --disable-sysvsem"
+%else
without_shared="--without -mysql --without-gd \
&nbs p; --disable-dom --disable-dba --without-unixODBC \
&nbs p; --disable-pdo --disable-xmlreader --disable-xmlwriter \
@@ -764,6 +789,7 @@
&nbs p; --disable-json --without-pspell --disable-wddx \
&nbs p; --without-curl --disable-posix \
&nbs p; --disable-sysvmsg --disable-sysvshm --disable-sysvsem"
+%endif
# Build Apache module, and the CLI SAPI, /usr/bin/php
pushd build-apache
rpmbuild -bb --with mysqlnd --define "rhel 5" SPECS/php-5.3.2-remi.specTo install via yum, change to the directory where rpms are located and recreate the repodata via:
createrepo .
In place variable substitution with AWK
Thu, 02/04/2010 - 12:21 — sandipThe content of the input file becomes stdin for rm and awk. rm ignores the input and removes the file, but its file descriptor remains open until both commands, rm and awk is complete. AWK process this "nameless" file and creates a new file:
{ rm $CSV_FILE && awk -F',' -v stid="$ST_ID" '$1 ~ stid {gsub(/&/,"",$7) }1' > $CSV_FILE; } < $CSV_FILE
-
"-v" sets the awk variable that is passed in via shell script variable.
"gsub" replaces with "" all occurrence of & in the 7th field. Use "sub" for single/first occurrence substitution or GNU Awk's gensub for more articulated substitutions.
"1" is a shortcut which means print the current record:
pecl runkit with php-5.2.x
Thu, 01/21/2010 - 16:11 — sandipAs of writing, the current pecl runkit-0.9 package does not compile with PHP 5.2+ . Below is how I got the latest installed from svn trunk on CentOS-5.4 with php-5.2.9.
-
Install runkit:
svn co http://svn.php.net/repository/ pecl/runkit/trunk/
&nbs p; cd trunk
&nbs p; phpize
&nbs p; ./configure
&nbs p; make
&nbs p; make install
extension=runkit.so
Note: you would need php-pear and php-devel installed already.
- sandip's blog
- Login or register to post comments
- Read more
y2k10 bug in SpamAssassin
Tue, 01/19/2010 - 11:29 — sandipIf running 3.2.x version of SpamAssassin... (check with `spamassassin -V`) there is a y2k10 bug in the FH_DATE_PAST_20XX rule, causing all mails getting an extra 3.4 points:
Reference: SA Bugzilla – Bug 6269
The fix mentioned is to update the rules using `sa-update` and restart spamd. The rules in the update directory at /var/lib/spamasassin will get updated.
With the fix applied you should no longer see FH_DATE_PAST_20XX in the logs.
For a manual fix, update /usr/share/spamassassin/72_act
header FH_DATE_PAST_20XX & nbsp; Date =~ /20[1-9][0-9]/ [if-unset: 2006]
to:
header FH_DATE_PAST_20XX & nbsp; Date =~ /20[2-9][0-9]/ [if-unset: 2006]
Related reading on sa-update: SpamAssassin RuleUpdates
- sandip's blog
- Login or register to post comments
- Read more