Kategori: Linux

  • Defining Motherboard, CPU and BIOS info in Linux terminal

    In this article, I’m going to explain how to read motherboard, cpu and bios information under linux terminal.

    Reading Motherboard Information:

    # sudo dmidecode -t 2

     

    Reading Motherboard Serial Number:

    # sudo dmidecode -t 2 | grep Serial

     

    And OEM Information:

    # sudo dmidecode -t 11

    (daha&helliip;)

  • Preparing virtual environment for running with apache mod_wsgi & postgresql

    For completing postgresql requirements of virtual environment, install “libpq-dev” and “python-dev” packages, outside of virtual environment.

    $ deactivate (if you are in virtual environment)
    $ sudo apt-get install libpq-dev python-dev

    Re-activate virtual environment and install psycopg2 from pip repo.

    $ pip install psycopg2

    By the way, in the name of  conformist approach install ipython in virtual environment.

    $ pip install ipython

    PostgreSQL engine and python connection libraries are ready.
    Now, lets prepare wsgi file for current project. (I assumed apache and mod_wsgi installed and configured) I’m going to use /var/www/project path for example for environment root in wsgi file.

    ENV_DIR = [‘/var/www/project’]

    import site, os, sys

    base = os.path.dirname(__file__)
    sys.path.insert(0, base)
    sys.path.append(os.path.dirname(base))

    # Remember original path.
    prev_sys_path = list(sys.path)

    # Add each new site-packages directory.

    for directory in ENV_DIR:

    site.addsitedir(directory)

    # For taking new directories to the front reorder path.

    new_sys_path = []
    for item in list(sys.path):

    if item not in prev_sys_path:

    new_sys_path.append(item)
    sys.path.remove(item)

    sys.path[:0] = new_sys_path
    os.environ[‘PYTHON_EGG_CACHE’] = ‘/tmp/project_eggs’
    sys.stdout = sys.stderr
    os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘%s.settings’ % os.path.basename(base)
    from django.core.handlers.wsgi import WSGIHandler
    application = WSGIHandler()

    Place the wsgi file above into root of the django project which created inside of the virtual environment directory (eg. /var/www/project/django/)

    So wsgi file is ready, and we can configure apache to use this wsgi file:

    <VirtualHost *:80>

    WSGIDaemonProcess project_name user=username group=usergroup processes=3 threads=15 inactivity-timeout=120 maximum-requests=50 python-path=/var/www/project/lib/pyton2.7/site-packages
    WSGIProcessGroup project_name
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias / /var/www/project/django/wsgi
    ServerName project_name.com
    ServerAdmin admin@project_name.com
    CustomLog /var/www/project/django/log/access_log combined
    ErrorLog /var/www/project/django/log/error_log
    Alias /static “/var/www/project/django/static”

    </VirtualHost>

    Save this file under /etc/apace/sites-available as “project.conf”

    Run “$ a2ensite project.conf” command and restart (or reload) the apache service.

    Now you can see the running django installation at “http://www.project_name.com”

  • Installing Django-CMS over Python Virtual Environment on Ubuntu based systems

    Prepare for virtual environment:

    $ sudo apt-get install python-setuptools python-dev build-essential
    $ sudo easy_install pip
    $ sudo pip install virtualenv

    Creating a virtual environment:

    $ virtualenv example_env -p python2.7 –no-site-packages –distribute

    Activating virtual environment:

    $ source example_env/bin/active

    Installing Django and Django-CMS in to virtual environment:

    $ pip install PIL
    $ pip install django-cms

    the command above is also installs those required packages:

    django
    django-mptt
    django-classy-tags
    django-sekizai
    south
    html5lib

    Thats all. Library installation on virtual environment is complete. On the next, how to run django-cms on django with apache…

     

    Note: If you want to exit from virtual environment just type this:

    $ deactivate

  • PyCharm & Linux FS Notifier

    Native file system watcher for Linux

    If you’re an IntelliJ user working under Linux you’ve probably seen that boring “Synchronizing files…” spinning icon in a left corner of a status bar. It is there because for an intelligent IDE it is a must to be in the know about any external changes in files it working with – e.g. changes made by VCS, or build tools, or code generators etc. On Windows and Mac OS X native file system watchers used to facilitate this task but on Linux the only option was to recursively scan directory tree. Now you’re welcome to give a try to native file system watcher for Linux.
    Prerequisites
    File system watcher requires inotify(7) facility. It is in mainstream kernel for more than two years (since 2.6.13, and in glibc since 2.4) so chances are your distribution don’t missing it. The sign of inotify availability in a system is a presence of /proc/sys/fs/inotify/ directory.
    Download and setup
    File system watcher is a single binary executable (fsnotifier) and can be downloaded directly from our Git repository. It should be named ‘fsnotifier’, placed into bin/ directory of your IDE and granted execution rights. Inotify requires a “watch handle” to be set for each directory it monitors. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects (e.g. IntelliJ IDEA sources contain 30000+ directories). The current limit can be verified by executing:

    cat /proc/sys/fs/inotify/max_user_watches

    It can be raised by adding following line to the /etc/sysctl.conf file:

    fs.inotify.max_user_watches = 524288

    … and issuing this command to apply the change:

    sudo sysctl -p

    64-bit systems
    If your system is strictly 64-bit (i.e. doesn’t contains 32-bit runtime libraries in /lib32 directory) you should download 64-bit version here. Rename downloaded file to “fsnotifier”, rest of setup is same.

  • Resolving Tomboy Ubuntu One issue on Mint 11 Katya

    Mint Linux 11 Katya
    Tomboy & Ubuntu One.

    Tomboy notes… You know,.. In this world, people uses for taking notes and take a look at them from any where, who knows this app.. Because it’s online, ermmm… Any way, this app doesn’t needs to be clearifying about what it is…

    Main problem is:
    I installed Mint Linux 11 Katya and I can’t find ubuntu one service in the tomboy options like before…

    Let’s resolve this problem and make me a hero who saved the DAY one:
    Open tomboy notes from “Menu/Accessories”
    Click to “Preferences” in “Edit” menu and tab to “Synchronization”
    Select “Tomboy Web” from “Services” pulldown
    Add “https://one.ubuntu.com/notes/” address to “Server” line
    Click to “Connect to Server” button.

    Now you must sent to “https://login.ubuntu.com/” over your default web browser when clicked to “Connect to Server”
    Take a login to your account by your mail address and passwd, click to “Continue” and wait a moment for logging in.
    Whe you logged in they asks you to add “this” computer connection list. Give a name for your already configuring computer and continue.
    Then you redirected to your computer “http://localhost:8000/” address you had to be saw “Tomboy Web Authorization Successful” page.

    Congrats, you are connected!

    Now you can return to tomboy notes application preferences and click to “Save” button to make everything permanent.
    It’s synchronizing now…. Aaand Voi’la! All your old notes back and everything setted up for re-use.

  • Yarım kalan SCP kopyalamayı devam ettirmek…

    Secure Copy ile dosya kopyalarken bağlantı sorunlarından kopyalamanın yarım kalmasına gıcık olup el mahkum yeniden kopyalamaya başlayıp bir o kadar daha vakit harcayanlardan mısınız? Artık buna mecbur değilsiniz…

    SCP ile yapılan kopyalamalarda genellikle büyük dosya transferleri yurdum internet distabilitesi yüzünden kıç ağrısı olmakta. Bunun çözümü ise RESUMEable scp kopyalaması başlatmaktan geçmekte. Diyeceksiniz ki SCP’nin resume özelliği yok. Evet yok! Ama Rsync ile kullanınca gayet güzel o işi görmekte =)

    Bunun için kopyalam için sadece SCP değil Rsync’le bileştirilmiş bir komut dizisi ile kopyalamalarınız kesintisiz devam edebilir, kesilse bile rsync sayesinde kaldığınız yerden devam edebilirsiniz. Bunun nasıl yapıldığı ise aşağıdaki komutla örneklenmiştir. Kolay gelsin:

    # rsync –partial –progress –rsh=ssh user@host:remote_file local_file

    Uzak sunucudan devastator boyutlarında dosya almak için bunun tam tersi işlem yapmak da mümkün. Sadece kaynak ve hedef adreslerin yerini değiştirmeniz yeterli.

  • Linux üzerinde USB Bellek ile Windows 7 kurulumu hazırlamak

    Windows 7’yi usb bellekten kurulabilir hale getirmemiz için elimizde minimum 4GB boyutlu bir usb bellek olmalıdır. Çünkü en düşük Win7 kurulum dvd boyutu 2.2GB’tır.

    USB Belleği bootable flag’ini açıyoruz ki usb stick’ten boot edebilsin. Daha sonra USB Belleği NTFS olarak formatlıyoruz. Formatlama işleminden sonra Win7 CD’sindeki tüm dosyaları olduğu gibi USB Belleğin root’una kopyalıyoruz.

    Kopyalama işlemi bittikten sonra şu adresteki kaynak dosyayı indiriyoruz: http://ms-sys.sourceforge.net/#Download

    Ben bu işlemi yaptığımda son stabil sürüm “2.2.1”di. Daha günceli varsa onu indirin.

    indirdiğiniz tar.gz dosyasını açıp aşağıdaki konutlar ile derleyip kurun:

    tar xvf ms-sys-2.1.5.tar.gz
    cd ms-sys
    make
    sudo make install
    Bu işlemden sonra ms-sys komutu ile usb belleğinizin master boot record'unu usb bellekten boot edilebilecek hale getiriyoruz.
    
    
    ms-sys -7 /dev/sdX

    Böylece USB'den Win7 kurabileceğimiz bir belleğimiz oluyor...

    Bundan sonra belleği kurulum yapacağınız bilgisayara takıp, bilgisayarın BIOS ayarlarını değiştirerek ya da BIOS'unuz yeterince marifetliyse, Boot menüsünden seçerek USB'den boot etmesini sağlamak...

  • squeeze/sid'e PostgeSQL entegreli eJabberD kurulumu

    apt-get install ejabberd postgresql

    mkdir ejabberd-modules
    :~$ svn checkout http://svn.process-one.net/ejabberd-modules ejabberd-modules
    :~$ cd ejabberd-modules/pgsql/trunk
    :~/ejabberd-modules/pgsql/trunk$ ./build.sh
    :~/ejabberd-modules/pgsql/trunk$ cd ebin
    :~/ejabberd-modules/pgsql/trunk/ebin$ sudo cp * /usr/lib/ejabberd/ebin/
    :~/ejabberd-modules/pgsql/trunk/ebin$ cd ~/
    :~$ wget http://svn.process-one.net/ejabberd/tags/ejabberd-2.1.2/src/odbc/pg.sql

    :~$ sudo su postgres -c psql template1
    Welcome to psql 8.2.7, the PostgreSQL interactive terminal. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit
    postgres=# ALTER USER postgres WITH PASSWORD ‘my_postgres_user_password_here’;
    ALTER ROLE
    postgres=# q

    :~$ sudo -u postgres createdb ejabberd
    :~$ sudo su postgres
    postgres@ubuntu:~$ psql ejabberd < pg.sql
    postgres@ubuntu:~$ exit
    :~$ sudo pico /etc/ejabberd/ejabberd.cfg

    Konfigürasyon ayarlarından aşağıdaki satırda ejabberd sunucusunun dns adresi yazılır:
    {hosts, [“my_xmpp_server_dns_here”]}.

    Dahili authentication kontrolünü sağlayan bu satırın başına %% işareti koyarak kapatıyoruz:
    %%{auth_method, internal}.

    Ardından ODBC authentication ayarını açıyoruz:
    {auth_method, odbc}.

    Bu satırda da yönetici tanımlıyoruz:
    {acl, admin, {user, “myadmin_username_here”, “my_xmpp_server_dns_here”}}.

    PostgreSQL Veritabanı erişimini ayarlamayı da unutmayalım:
    {odbc_server, {pgsql, “localhost”, “ejabberd”, “postgres”, “my_postgres_user_password_here”}}.

    Eğer gerekliyse aşağıdaki satırları da değiştirebilirsiniz:
    mod_last <-> mod_last_odbc >>PostgreSQL’de son login tarihi kaydı tutulması için.
    mod_offline <-> mod_offline_odbc >> PostgreSQL’de kullanıcı offline mesajlarını tutabilmesi için.
    mod_roster <-> mod_roster_odbc >>  PostgreSQL’de kontak listesi tutlabilmesi için.
    mod_vcard <-> mod_vcard_odbc >> PostgreSQL’de kullanıcı tanımlaması tutulması için.

    Dosyayı saklayın ve çıkın.

    
  • Apache'ye gönderilen isteklerini başka makineye yönlendirmek (Apache Proxy)

    Son zamanlarda sanal sunucularla haşır neşir olduğumu son iki yazımdan anlamışsınızdır. Tabi çok profesyonel çözümler olmamakla birlikte şirket içinde 4 çekirdekli 8GB bellekli bir sunucunun hiçbir çekirdeğini ve 1mb belleğini heba etmeyecek şekilde hem dışarıya hem içeriye hizmet verebilmesini sağlamak amacıyla çözüm üretme çabası içindeyim. Buna sebep olarak geçen iki yazımdan sonra şimdi de Host makinedeki Apache dışarıya hizmet verirken Guest makinada kurulu olan Apache’nin apayrı veritabanı motoru ile apayrı bir projeyi sunmasını sağlamak gerekliliği doğdu.

    Bunu yapmak için daha önce kurmuş olduğumuz sanal makineye geçen yazımda belirttiğim gibi Host makinedeki herhangi boş bir portu (faraza 2156.port) Guest makinenin 80.portuna yönledirerek işe başlayabiliriz. Daha sonra Guest makineye yayımlanacak olan projemizi yerleştiriyoruz ve Guest lokalinde çalıştığından emin olduktan sonra, Host makinenin http://localhost:2156/ adresinden de yönlendirmenin çalışıp çalışmadığın kontrol edebiliriz. Buraya kadar her şey yolunda ise bundan sonra Host makinemizin Apache ayarlarında yapacağımız değişiklikler ile http://adres:port/ yerine http://proje.falanca.com.tr/ adresi ile herhangi bir yerden sanal makinedeki projemize erişebilir hale geleceğiz.

    (daha&helliip;)

  • Sanal Makineye dışarıdan istek yönlendirmek (VirtualBox)

    Son yazımızdan bu yana uzun bir süre geçmiş. Yeni bir şeyler eklemek lazım.

    Hatırlayacağınız gibi son yazımda Ubuntu server’a VirtualBox için Headless modda hazırlanmış bir sanal makinenin nasıl servis olarak çalıştırılabileceğine değinmiştik. Şimdi ise hazırladığımız bu sanal makineye dışarıdan gelecek istekleri nasıl yönlendirebileceğimizi anlatacağım.

    Sanal makinemizin xml konfigürasyon dosyasına ekleyeceğimiz birkaç satır ve sanal makineyi yeniden başlatmaktan ibaret bir işlem. Çok bir teferruatı yok. Örnek olarak ssh ile sanal makinaya erişmek için nasıl bir yönlendirme yapacağımızı anlatacağım.

    .VirtualBox/Machines/makine/makine.xml dosyasını bir editör ile açıp içinceki

    <Machine uuid={“………….>

    </Machine>

    etiketleri arasına

    <ExtraData>
    </ExtraData>

    etiketleri yerleştiriyoruz. Bu extradata etiketlerinin arasına satırlarını ekliyoruz.

    <ExtraDataItem name=”VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/HostPort” value=”22222″/>
    <ExtraDataItem name=”VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/GuestPort” value=”22″/>
    <ExtraDataItem name=”VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/Protocol” value=”TCP”/>

    Sonra dosyayı kaydedip sanal makinemizi YENİDEN BAŞLATARAK xml dosyasının işletildiğinden emin oluyoruz. Artık Host (gerçek) makinadan Guest (sanal) makinaya  ssh localhost -p 22222 komutu ile ulaşmamız mümkün.

    Yukarıdaki üç satırı tek tek açıklamak gerekirse; ilk satırda host makinenin hangi portunu sanal makineye yönlendireceğimizi belirliyoruz. İkinci satırda Guest makinenin hangi portuna erişmek istediğimizi belirtiyoruz. Son satırda ise bu portlar arasındaki iletişim protokolünün ne olacağını belirliyoruz. Koyu renklerle yazılmış olan SSH yazısına dikkatinizi çekmek istiyorum. Bu koyu yazılmış olan SSH aslında başka birşey de olabilirdi örneğin HEDE. Bu HEDE sadece bir belirteç o konfigörasyonun ne olduğuna dair bir isimlendirme gibi bir şeyden ibarettir.