воскресенье, 20 февраля 2011 г.

SAMBA PDC - контроллер домена и перемещаемые профили

 Основные источники:
  • http://www.ibm.com/developerworks/ru/edu/au-samba/section2.html
  • http://www.howtoforge.com/samba_setup_ubuntu_5.10_p5
  • http://www.ibm.com/developerworks/ru/edu/samba2/section2.html
  • http://forums.contribs.org/index.php/topic,28808.0.html
  • http://helgeklein.com/blog/2008/10/deleting-a-local-user-profile-not-as-easy-as-one-might-assume/

вторник, 15 февраля 2011 г.

mysql dump DB structure in bash

for i in `mysql DB -e "SHOW TABLES" | tail -n +2`; do mysql DB -e "SHOW CREATE TABLE $i" | tail -n +2 | cut -f 2-; break;  done; 

Дублирование базы:
#!/bin/bash
DBUSER=user
DBPASSWORD=pwd
DBSNAME=sourceDb
DBNAME=destinationDb
DBSERVER=db.example.com

fCreateTable=""
fInsertData=""
echo "Copying database ... (may take a while ...)"
DBCONN="-h ${DBSERVER} -u ${DBUSER} --password=${DBPASSWORD}"
echo "DROP DATABASE IF EXISTS ${DBNAME}" | mysql ${DBCONN}
echo "CREATE DATABASE ${DBNAME}" | mysql ${DBCONN}
for TABLE in `echo "SHOW TABLES" | mysql $DBCONN $DBSNAME | tail -n +2`; do
        createTable=`echo "SHOW CREATE TABLE ${TABLE}"|mysql -B -r $DBCONN $DBSNAME|tail -n +2|cut -f 2-`
        fCreateTable="${fCreateTable} ; ${createTable}"
        insertData="INSERT INTO ${DBNAME}.${TABLE} SELECT * FROM ${DBSNAME}.${TABLE}"
        fInsertData="${fInsertData} ; ${insertData}"
done;
echo "$fCreateTable ; $fInsertData" | mysql $DBCONN $DBNAME

пятница, 11 февраля 2011 г.

openerp like module

возможность доступна в Сервере версии trunk

 import openerp
   openerp.tools.config['addons_
path'] = '/home/openerp/repo/addons/'
   db, pool = openerp.pooler.get_db_and_pool('test')
   cr = db.cursor()

   res_users = pool.get('res.users')
   ids = res_users.search(cr, 1, [('active', '=', False)])

   for record in res_users.browse(cr, 1, ids):
       print record.name
       res_users.write(cr, 1, [record.id], {'active': True})

   cr.commit()
   cr.close()

ssh reverse dns

Проблема: долгое время подключение к серверу  (long timeout)

Решение:
  • добавить в /etc/ssh/sshd_config :
    UseDNS no

wu-ftpd reverse dns

Проблема: долгое время подключения(long timeout)

Решение:
  • Добавить в /etc/wu-ftpd/ftpaccess
    dns refuse_no_reverse /etc/ftpd/no_reverse override
    dns refuse_mismatch /etc/ftpd/no_reverse override
  • изменить строку в /etc/nsswitch.conf
    hosts:          files dns
    на
    hosts:          files
  • в /etc/resolv.conf  должен быть указан работающий nameserver x.x.x.x
    в случае с домашним роутером, надо поменять
    nameserver 192.168.1.1 на nameserver 8.8.8.8
  • чтобы при каждой перезагрузке настройки /etc/resolv.conf не сбрасывались надо добавить в /etc/dhcp3/dhclient.conf  строку
    supersede domain-name-servers 8.8.8.8;

понедельник, 20 декабря 2010 г.

share OpenVpn server LAN

### VPN share server LAN
cat /proc/sys/net/ipv4/ip_forward
iptables  -t nat -A POSTROUTING -s 10.50.0.0/24 -o vmbr0 -j MASQUERADE

пятница, 17 декабря 2010 г.

linux RAM

Список процессов отсортированый по потребляемой памяти

ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=rss
 
VSIZE (Virtual memory SIZE) - The amount of memory the process is
    currently using. This includes the amount in RAM and the amount in
    swap.

    RSS (Resident Set Size) - The portion of a process that exists in
    physical memory (RAM). The rest of the program exists in swap. If
    the computer has not used swap, this number will be equal to
    VSIZE.
 
Очистить кэшированую память
# sync; echo 3 > /proc/sys/vm/drop_caches