How to check squid statistics on debian linux?
install application squidclient
apt-get install squidclient
and then execute aplilaction:
squidclient -p 3128 mgr:counters
for all options execute:
squidclient -p 3128 mgr:
How to check squid statistics on debian linux?
install application squidclient
apt-get install squidclient
and then execute aplilaction:
squidclient -p 3128 mgr:counters
for all options execute:
squidclient -p 3128 mgr:
Step 1: Generate a Private Key
openssl genrsa -des3 -out server.key 1024
Step 2: Generate a CSR (Certificate Signing Request)
openssl req -new -key server.key -out server.csr
Step 3: Remove Passphrase from Key
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
Step 4: Generating a Self-Signed Certificate
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
Step 5: Installing the Private Key and Certificate
cp server.crt /etc/apache2/ssl/
cp server.key /etc/apache2/ssl/
Step 6: Configuring SSL Enabled Virtual Hosts
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl//server.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Step 7: Restart Apache and Test
/etc/init.d/apache2 stop
/etc/init.d/apache2 stop
https://test.site.com
Some providers put the DID in the TO: field.
To extract DID form SIP header use new context:
[from-pstn-toheader]
exten => s,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
and in incoming trunk set
context=from-pstn-toheader
AvantFax has ability to automatically print received fax.
first you have to edit config file to enable global printing
edit includes/local_config.php file
# pico includes/local_config.php
and find line $PRINTFAXRCVD = false;
false change to true and that is all.
If you get following error on debian Lenny
just do:
apt-get install cupsys-bsd
I wrote a litle bash script for mydns DNS server to act as slave DNS server.
All records are transfered from master ISPConfig 3 Server.
On second server install mydns server, and configure it for ISPConfig use.
then edit file pico /etc/mydns.conf and replace lines
soa-where = server_id = 2 # or any other number
rr-where = server_id = 2 # or any other number
with server id of master server , in my case 1
soa-where = server_id = 1 # Extra WHERE clause for SOA queries
rr-where = server_id = 1 # Extra WHERE clause for RR queries
all user names and password can be found in
/usr/local/ispconfig/server/lib/config.inc.php file
note: you can manualy transfer 1 one zone by issue: dns_transfer.sh zone_id
zone ID you can find in ispconfig database in table dns_soa
save this script in eg: /root/dns_transfer.sh
chmod u+x /root/dns_transfer.sh
and insert in crontab (scrip will be executed every 10 min):
*/10 * * * * root /root/dns_transfer.sh
logfile is created in /var/log/dns_transfer/
please replace needed data and email address.
email address is used when some error generated.
here is the script:
#!/bin/bash
#(c) 2009 by franz@franz-net.info
#
h_x=master_hostname
u_x=master_database_user_name
p_x=master_database_password
db_x=dbispconfig
#
u2_x=local_database_user_name
p2_x=local_database_password
db2_x=local_dababase_dbispconfig2
#
TMP=/tmp/dns_transfer.tmp
path=/var/log
logfile=$path/dns_transfer/ISPconfig3-dns_transfer-`date +'%F'`
error=/tmp/error.log
zamail=/tmp/zamail$datum_x.txt
#Email adderss
email="email@example.com"
#
function check_log {
if [ -d $path/dns_transfer ]; then
log "Log directory exist"
else
mkdir $path/dns_transfer
log "Log directory creted"
fi
}
#
function log {
curenttime_x=`date +"+%Y-%m-%d %H:%M:%S"`
echo "$curenttime_x - $1 $2 $3 $4 $5 $6 $7 $8 $9" >> $logfile
}
#
function sendmail {
echo "" >> $error
echo "for manual retransfer execute '$0 $1'" >> $error
log "Sending mail: `cat $error`"
mail -s"ERROR - DNS transfer on `hostname`" $email < $error
}
#
function transfer {
echo "delete from dns_soa where id = $1;" > $TMP
mysqldump --no-create-info -u$u_x -p$p_x -h$h_x $db_x dns_soa -w " id = $1 " >> $TMP 2>> $error
exitcode=$?
if [ $exitcode != 0 ]; then
log "Error connecting to database for dns_soa, ID: $1, or something..."
sendmail $1
exit 1
fi
log "data fatched dns_soa.id=$1."
mysql -u$u2_x -p$p2_x $db2_x < $TMP 2>>$error
exitcode=$?
if [ $exitcode != 0 ]; then
log "Error while inserting data to table dns_soa for id: $1..."
sendmail $1
exit 1
fi
log "Data imported for dns_soa.id=$1"
echo "delete from dns_rr where zone = $1;" > $TMP
mysqldump --no-create-info -u$u_x -p$p_x -h$h_x $db2_x dns_rr -w " zone = $1 " >> $TMP 2>> $error
exitcode=$?
if [ $exitcode != 0 ]; then
log "Error connecting to database for dns_rr, ID: $1, or something..."
sendmail $1
exit 1
fi
log "data fatched dns_rr.id=$1."
mysql -u$u2_x -p$p2_x $db2_x < $TMP 2>> $error
exitcode=$?
if [ $exitcode != 0 ]; then
log "Error while inserting data to table dns_rr, for id: $1..."
sendmail $1
exit 1
fi
log "Data imported for dns_rr.id=$1"
log "Done for ID: $1"
}
#############
# S T A R T #
#############
check_log
log "Start dns_transfer"
#taking all zone ID's
if [ $1 ]; then
log "Manual transfer dor zone $1"
transfer $1
exit 0
fi
ID=`mysql -u$u_x -p$p_x -h$h_x $db_x -Bse 'select id from dns_soa'`
#chechink if all id's have the same serial, if not, delete all data fopr this serial, and inport new one
for id in $ID; do
echo "Start ID=$id" > $error
serial=`mysql -u$u_x -p$p_x -h$h_x $db_x -Bse "select serial from dns_soa where id = $id"`
serial2=`mysql -u$u2_x -p$p2_x $db2_x -Bse "select serial from dns_soa where id = $id"`
if (( serial != serial2 )); then
transfer $id
else
log "No Change for ID: $id"
fi
done
This is updated backup script which can be run on ISPConfig3 server (locally) and copy files to already mounted drive.
Original post_ http://blog.it-podrska.info/2009/08/backup-remote-linux-mysql-and-data/
Variables which are removed:
sshuser=”remote_username_root” # remote ssh username
sshhostname=”remote_hostname” # remote hostname
sshport=”remote ssh port” # remote ssh port
variables which you mast verify:
path=/disk2/pub/Backup
dbuser_x=root #mysql root password
dbpassword_x=mysqlrootpass #mysql password
remotepath=/backup # remote path where will be temporary files
lista=/home/franz/bin/lista.txt #path and filename of txt file where are stored remote directory paths
and here is the script:
#!/bin/bash
#(c) ISPBackup3 by Franz@franz-net.info
#local backup on mounted directory
#define local path
#This path must exist, this is destination path
path=/disk2/pub/Backup1
#define logfile
logfile=$path/log/ISPconfig3-backup-`date +'%F'`
#define week number
week_x=`date +'%V'`
#define locapl final path path/weeknumber/date
dirname=$path/$week_x/`date +'%F'`
#define day of week number
DF_X=`date +'%u'`
#define curent date and time: 2009-08-16_23-01
datum_x=`date +'%F_%I-%M'`
#define database access
dbuser_x="root"
dbpassword_x="password"
#define local temp path, must exist
remotepath="/backup"
#define list of directories in format:
#name /path
lista="/home/franz/bin/lista.txt"
#define temp file for email text, and email address for sending report
zamail="/tmp/zamail$datum_x.txt"
email="franz@franz-net.info"
function check_log {
if [ -d $path/log ]; then
log "Log directory exist"
else
mkdir $path/log
log "Log directory creted"
fi
}
function log {
curenttime_x=`date +"+%Y-%m-%d %H:%M:%S"`
echo "$curenttime_x - $1 $2 $3 $4 $5 $6 $7 $8 $9" >> $logfile
}
function check_dirs {
log "Cheching local directory for saving files..."
if [ -d $path/$week_x ]; then
log "Directory week direcotry exist: $path/$week_x"
else
mkdir $path/$week_x
log "Week directory created: $path/$week_x"
fi
if [ -d $dirname ]; then
rm -r $dirname
mkdir $dirname
log "Destination directory recreated: $dirname"
else
mkdir $dirname
log "Destination directory created: $dirname"
fi
}
#########
# START #
#########
#
log "Starting daily backup"
echo "`date "+%Y-%m-%d %H:%M:%S"` - Starting daily backup" > $zamail
#cheching local path
check_log
check_dirs
log "$dirname"
#
#### define standard commands
SCP="cp $remotepath"
#
#find all databases for backup
#clear remote directory
log "Deleting files from remote directory"
#command for clear all data from remote directory
find $remotepath -name \*.bz2 -type f -exec rm {} \;
log "Deleting OK"
#
echo "All data will be saved in: $dirname. Today is $DF_X day of week" >> $zamail
log "All data will be saved in: $dirname. Today is $DF_X day of week"
### Starting database dumps and copy to local host
for i in `mysql -u$dbuser_x -p$dbpassword_x -Bse 'show databases'`; do
log "Starting mysqldump $i"
`mysqldump -u$dbuser_x -p$dbpassword_x $i | bzip2 > $remotepath/mysql-$i-$datum_x.sql.bz2`
log "Dump OK. Starting SCP"
$SCP/mysql-$i-$datum_x.sql.bz2 $dirname/
echo "`date "+%Y-%m-%d %H:%M:%S"` - mysql: $i" >> $zamail
log "SCP done. $i database saved OK!!!!"
done
#
#prepare for directory dump
IFS=$'\n'
for i in `cat $lista`; do
XX=`echo $i | awk '{print $1}'`
YX=`echo $i | awk '{print $2}'`
unset IFS
if [ $DF_X == 1 ]; then
log "Deleting TAR increment files...."
BRISI="rm /backup/$XX.increment"
$BRISI
FileName="dirbackup_$XX-${datum_x}_Full.tar.bz2"
TAR="tar --exclude='mysqld.sock' -g /backup/$XX.increment -cjPf $remotepath/$FileName $YX"
else
FileName="dirbackup_$XX-${datum_x}_Increment_$DF_X.tar.bz2"
TAR="tar --exclude='mysqld.sock' -g /backup/$XX.increment -cjPf $remotepath/$FileName $YX"
fi
log "Starting to prepare files for $XX"
$TAR
log "Done, starting to copy...."
$SCP/$FileName $dirname/
log "Done. Directory copied."
echo "`date "+%Y-%m-%d %H:%M:%S"` - Directory: $FileName -> $dirname" >> $zamail
done
log "Done copy.."
echo "`date "+%Y-%m-%d %H:%M:%S"` - All Done." >> $zamail
log "send mail to $email:"
cat $zamail >> $logfile
mail -s"Daily ISPConfig3 backup `date +'%F'`" "$email" < $zamail
log "All Done."
Here is description how to compile pure ftp to run in openVZ server.
First install needed packages and pure-ftpd-mysql:
apt-get install pure-ftpd-mysql build-essential libpam0g-dev libmysqlclient15-dev
Then download and compile new pure-fptd:
cd /tmp
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.22.tar.gz
tar -xvzf pure-ftpd-1.0.22.tar.gz
cd pure-ftpd-1.0.22
./configure --prefix=/usr/sbin --without-capabilities --with-virtualchroot --with-mysql --with-pam --with-altlog --with-wrapper --with-mysql --with-cookie --with-throttling --with-ratios --with-paranoidmsg --with-quotas
make
make install
and finally replayce original binnary with compiled one:
cp /usr/sbin/pure-ftpd /usr/sbin/pure-ftpd-mysql
and normaly startup pure-ftpd:
/etc/init.d/pure-ftpd-mysql start
How to generate SSH keys and implement for key authentication.
login to local machine with user you will be using for connect to remote.
1. generate keys:
ssh-keygen -t dsa
2. copy id_dsa.pub to remote machine to /tmp directory
scp ~/.ssh/id_dsa.pub remote_machine:/tmp
3. login to remote machine and append new key to authorized_keys2 file in home folder
cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys2
4. log out and that it is.
You can try with:
ssh remoteuser@remoteserver
and you will be connected to remote server without password.
Whit little bash script you can backup remote linux server.
I wrote this script for backup my web server powered by ISPconfig 3.
Backup is started from local linux machine.
For this script ssh key authentication must be set.
This script will create sub directory with week number and sub directory for current date. eg:
/path/34/2009-08-17
On beginning of week (Monday) full directory backup will be made, and for rest days only increment (changed files) backup.
After backup is done, email is send with short log data.
Log files are also implement.
Script is run from local machine.
For directory backup I use local txt files with list of directories for backup and names how backup file will begin:
here is example of lista.txt file:
root /root
etc /etc
www /var/www
usr_ispconfig /usr/local/ispconfig
maildir /var/vmail
variables which you must verify/change:
path=/disk2/pub/Backup
dbuser_x=root #mysql root password
dbpassword_x=mysqlrootpass #mysql password
sshuser="remote_username_root" # remote ssh username
sshhostname="remote_hostname" # remote hostname
sshport="remote ssh port" # remote ssh port
remotepath=/backup # remote path where will be temporary files
lista=/home/franz/bin/lista.txt #path and filename of txt file where are stored remote directory paths
This scrip can be added to cron for daily execution:
2 2 * * * franz /home/franz/bin/backup_web.sh
Here is the script:
#!/bin/bash
#SSH remote backup script
#by Franjo Posavec
#define local path
#This path must exist
path=/disk2/pub/Backup
#define logfile
logfile=$path/log/ISPconfig3-backup-`date +'%F'`
#
#define week number
week_x=`date +'%V'`
#
#define locapl final path path/weeknumber/date
dirname=$path/$week_x/`date +'%F'`
#
#define day of week number
DF_X=`date +'%u'`
#
#define curent date and time: 2009-08-16_23-01
datum_x=`date +'%F_%I-%M'`
#
#define remote database access
dbuser_x=mysqlroot
dbpassword_x=mysqlrootpass
#define remote ssh access
sshuser="remote_username_root"
sshhostname="remote_hostname"
sshport="remote ssh port"
#
#define remote backup path, must exist on remote server and have RW for user
remotepath=/backup
#
#define list of directories for backup in format:
#list is on local machine
#name /path
lista=/home/franz/bin/lista.txt
#
#define temp file for email text
zamail=/tmp/zamail$datum_x.txt
email="franz@franz-net.info"
#
function check_log {
if [ -d $path/log ]; then
log "Log directory exist"
else
mkdir $path/log
log "Log directory creted"
fi
}
#
function log {
curenttime_x=`date +"+%Y-%m-%d %H:%M:%S"`
echo "$curenttime_x - $1 $2 $3 $4 $5 $6 $7 $8 $9" >> $logfile
}
#
function check_dirs {
log "Cheching local directory for saving files..."
if [ -d $path/$week_x ]; then
log "Directory week direcotry exist: $path/$week_x"
else
mkdir $path/$week_x
log "Week directory created: $path/$week_x"
fi
if [ -d $dirname ]; then
rm -r $dirname
mkdir $dirname
log "Destination directory recreated: $dirname"
else
mkdir $dirname
log "Destination directory created: $dirname"
fi
}
#########
# START #
#########
#
log "Starting daily backup"
echo "`date "+%Y-%m-%d %H:%M:%S"` - Starting daily backup" > $zamail
#cheching local path
check_log
check_dirs
log "$dirname"
#
#### define standard commands
SSH="ssh $sshuser@$sshhostname -p $sshport"
SCP="scp -P $sshport $sshuser@$sshhostname:$remotepath"
#
#command for clear all data from remote directory
FIND="find $remotepath -name \*.bz2 -type f -exec rm {} \;"
#
#find all databases for backup
MYSQLDATABASE="mysql -u$dbuser_x -p$dbpassword_x -Bse 'show databases'"
database_x="$($SSH $MYSQLDATABASE)"
#
#clear remote directory
log "Deleting files from remote directory"
$SSH $FIND
log "Deleting OK"
#
echo "All data will be saved in: $dirname. Today is $DF_X day of week" >> $zamail
log "All data will be saved in: $dirname. Today is $DF_X day of week"
#
### Starting database dumps and copy to local host
for i in $database_x; do
log "Starting mysqldump $i"
MYSQLDUMP="mysqldump -u$dbuser_x -p$dbpassword_x $i | bzip2 > $remotepath/mysql-$i-$datum_x.sql.bz2"
# $SSH $MYSQLDUMP
log "Dump OK. Starting SCP"
# $SCP/mysql-$i-$datum_x.sql.bz2 $dirname/
echo "`date "+%Y-%m-%d %H:%M:%S"` - mysql: $i" >> $zamail
log "SCP done. $i database saved OK!!!!"
done
#
#prepare for directory dump
IFS=$'\n'
for i in `cat $lista`; do
XX=`echo $i | awk '{print $1}'`
YX=`echo $i | awk '{print $2}'`
unset IFS
if [ $DF_X == 1 ]; then
log "Deleting TAR increment files...."
BRISI="rm /backup/$XX.increment"
$SSH $BRISI
FileName="dirbackup_$XX-${datum_x}_Full.tar.bz2"
TAR="tar --exclude='mysqld.sock' -g /backup/$XX.increment -cjPf $remotepath/$FileName $YX"
else
FileName="dirbackup_$XX-${datum_x}_Increment_$DF_X.tar.bz2"
TAR="tar --exclude='mysqld.sock' -g /backup/$XX.increment -cjPf $remotepath/$FileName $YX"
fi
log "Starting to prepare files for $XX"
$SSH $TAR
log "Done, starting to copy...."
$SCP/$FileName $dirname/
log "Done. Directory copied."
echo "`date "+%Y-%m-%d %H:%M:%S"` - Directory: $FileName -> $dirname" >> $zamail
done
log "Done copy.."
echo "`date "+%Y-%m-%d %H:%M:%S"` - All Done." >> $zamail
log "send mail to $email:"
cat $zamail >> $logfile
mail -s"Dnevni backup servera `date +'%F'`" "$email" < $zamail
log "All Done."