Archive for the ‘OpenSuse’ Category

Install PostgreSQL on OpenSuse 12.1

February 6th, 2012 | admin

First,

$sudo zypper install postgresql postgresql-server pgadmin3

Start server

$sudo rcpostgresql start

Change password for postgres user

$sudo postgres -c psql postgres
ALTER USER postgres WITH PASSWORD 'postgres';
\q

Error!

“IDENT authentication failed for user”

Hence, if you do not use IDENT, edit the /var/lib/pgsql/data/pg_hba.conf file and change “ident” to “md5″. Say, for instance, the lines below

local all all ident
host all all 127.0.0.1/32 ident
host all all ::1/128 ident

to

local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5

Once done,restart postgreSQL as follows:

opensuse:~ # rcpostgresql restart

Create and Delete users

To create an user

opensuse:~ # su postgres

postgresql@opensuse:~> createuser -D

for user with password

postgresql@opensuse:~> createuser -D -p

To delete user

postgresql@opensuse:~> dropuser

Installing Oracle (sun) Java 1.7u2 openSUSE 12.1

February 6th, 2012 | admin

Download the RPM version of Java from www.oracle.com (in my case I downloaded 1.7u1).

The one I downloaded was: jdk-7u2-linux-i586.rpm

Install the jdk with yast2, zypper, or by double clicking the rpm within dolphin or nautilus:

sudo zypper in jdk-7u2-linux-i586.rpm -y

Now you have to setup the alternatives so you can use switch between Iced Tea, which is default, and the Oracle Java.

First install the alternative:

sudo /usr/sbin/update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.7.0_02/bin/java" 40

Now install the alternative for your browser plugin:

sudo /usr/sbin/update-alternatives --install "/usr/lib/browser-plugins/javaplugin.so" "javaplugin" "/usr/java/jdk1.7.0_02/jre/lib/i386/libnpjp2.so" 40

Note: the first quotes are pointing to the path, the the name of the alternative script, and the 3rd is the location to point to. The numbers at the end is the priority in case it was set to automode.

Now you have to configure the alternatives, first we’ll do java:

sudo /usr/sbin/update-alternatives java

Choose the number associated with /usr/java/jdk1.7.0_01/bin/java, in my case it was 1.

Now lets configure javaplugin:

sudo /usr/sbin/update-alternatives javaplugin

Choose the number associated with /usr/java/jdk1.7.0_01/jre/lib/i386/libnpjp2.so, in my case it was 1.

First, for the haters. I do linux for a living on servers, so I’m used to sudo, and that’s why I use it on my laptop.

Second, also for the other haters. Yes, I could have added some super high priority and kept it on auto, but I like doing it manually.

For the rest, you can check to see what you currently have set by running:

/usr/sbin/update-alternatives --query (or --display) java (or javaplugin)

You can test your java at oracles website:

Improve Battery Management for Linux(OpenSuse12.1)

February 4th, 2012 | admin

Thanks to this article:

 

openSUSE 11.3 und höher

Zur Installation von TLP auf openSUSE müssen die folgenden Schritte in einer Root-Shell ausgeführt werden.

Hinzufügen von Repositories:

openSUSE 11.3

zypper ar -f <a href="http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_11.3/home:cdersch:TLP.repo" rel="nofollow">http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_11.3/home:cdersch:TLP.repo</a>

Falls Contrib Repo noch nicht aktiv:

zypper ar -f <a href="http://download.opensuse.org/repositories/openSUSE:/11.3:/Contrib/standard/openSUSE:11.3:Contrib.repo" rel="nofollow">http://download.opensuse.org/repositories/openSUSE:/11.3:/Contrib/standard/openSUSE:11.3:Contrib.repo</a>

openSUSE 11.4

zypper ar -f <a href="http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_11.4/home:cdersch:TLP.repo" rel="nofollow">http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_11.4/home:cdersch:TLP.repo</a>

Falls Contrib Repo noch nicht aktiv:

zypper ar -f <a href="http://download.opensuse.org/repositories/openSUSE:/11.4:/Contrib/standard/openSUSE:11.4:Contrib.repo" rel="nofollow">http://download.opensuse.org/repositories/openSUSE:/11.4:/Contrib/standard/openSUSE:11.4:Contrib.repo</a>

openSUSE 12.1

zypper ar -f <a href="http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_12.1/home:cdersch:TLP.repo" rel="nofollow">http://download.opensuse.org/repositories/home:/cdersch:/TLP/openSUSE_12.1/home:cdersch:TLP.repo</a>

Falls Contrib Repo noch nicht aktiv:

zypper ar -f <a href="http://download.opensuse.org/repositories/openSUSE:/Factory:/Contrib/openSUSE_12.1/openSUSE:Factory:Contrib.repo" rel="nofollow">http://download.opensuse.org/repositories/openSUSE:/Factory:/Contrib/openSUSE_12.1/openSUSE:Factory:Contrib.repo</a>

Paketquellen aktualisieren:

zypper ref

Folgende Pakete sind zu installieren:

  • tlp (TLP Repo)
  • tp_smapi-kmp-desktop (Contrib Repo) – optional nur für ThinkPads, ermöglicht das Einstellen der Akkuladeschwellen und erweiterte Statusanzeigen.

Hinweis: Paketname muss ggf. in tp_smapi-kmp-VARIANTE angepaßt werden, die Kernelvariante lässt sich mit uname -r ermitteln.

  • smartmontools (openSUSE Repo) – optional, ermöglicht die Anzeige von SMART-Daten für die Festplatte(n) durch tlp-stat.
  • ethtool (openSUSE Repo)- optional, ermöglicht es Wake On LAN zu deaktivieren.
  • powertop (openSUSE Repo) – optional, zur Messung des Stromverbrauchs.

Die Pakete installiert man im Terminal als root mit folgendem Kommando (tp_smapi-Paketname ist ggf. anzupassen):

zypper in tlp tp_smapi-kmp-desktop smartmontools ethtool powertop

Install Vmware player on opensuse 12.1

January 29th, 2012 | admin

First, download and install it.

Then, do not forget to install gcc and kernel-source via zypper.

The most important:

sudo /usr/bin/vmware-modconfig  --icon="vmware-player" --appname=Vmware --gcc=/usr/bin/gcc --headers=/lib/modules/3.1.0-1.2-default/build/include/ --gcc-ignore-minor

Then it works well for me.

Double the time for laptop running on battery

January 17th, 2012 | admin

Tested under Mandriva&OpenSuse&Slackware, all works well.

$sudo zypper install powertop
$sudo zypper install  laptop-mode-tools
$sudo zypper install cpufrequtils

also check out cpufreq-utils
http://forums.opensuse.org/blogs/jdm…ls-package-40/

Thanks, quota for remark see following:

 

I have written a bash script file designed to work with the cpufrequtils package and the programs cpufreq-info (for reading CPU speed info) and cpufreq-set (to set CPU speed governor and frequency).

This is my third attempt at writing a bash shell to interface with these two packages. After creating a blog on how to use YaST to set your CPU speed with yast-power-management you can read about here: YaST Power Management – Control Your CPU Energy Usage How To & FAQ – Blogs – openSUSE Forums, several forum users indicated they used the cpufreq utilities instead. So, I decided to see if any sort of value added bash script could be put together to work with this program set. Changes made to your CPU speed only last until you reboot your computer, but you may find the information and function it provides to be useful.

Version 1.10 of C.F.U. (works with openSUSE 12.1) Adds new features and bug fixes:

1. New Help Display is included
2. C.F.U. includes menu automation. Type cfu -h for more details
3. Better Detection for the cpufrequtils to work and to be installed
4. Better detection of available speeds usable on your PC

To use the bash script file cfu, you need to download the following text from SUSE Paste (Actual Link is shown below) into a text editor like kwrite:

C.F.U. – CPU Frequency Utility – Version 1.10

Save the text as the file cfu in the /home area bin folder (example is: /home/username/bin, also known as ~/bin). It is possible to directly download cfu from a terminal session (You must delete or rename the old version first):

rm ~/bin/cfu
wget -nc http://paste.opensuse.org/view/download/72458191 -O ~/bin/cfu

This script must be marked executable to be used. Please run the following Terminal command:

chmod +x ~/bin/cfu

It is even possible to string all three of these commands together as one. Copy the following command, open up a terminal session, paste it in and press enter:

rm ~/bin/cfu ; wget -nc http://paste.opensuse.org/view/download/72458191 -O ~/bin/cfu ; chmod +x ~/bin/cfu

To use cfu, open a terminal session and type in:

cfu &lt;OR&gt; cfu -h

If the cpufrequtils package is not installed, you will be prompted to install it. In order to change your governor or CPU speed, you must supply the root user password. Same goes for installing the cpufrequtils package if it is missing. As always, I would love to hear about any comments or problems you might have using cfu.

Thank You,

Learn more about Unit Test for Symfony2

January 12th, 2012 | admin

First of all, install PHPUnit:


$ pear channel-discover pear.phpunit.de
$ pear channel-discover components.ez.no
$ pear channel-discover pear.symfony-project.com
$ pear install phpunit/PHPUnit

Then you can start to use PHP Unit like:


$phpunit -c app/

If you want to get report on HTML format, add parameter:


$ phpunit -c app/ --coverage-html=cov/

Not everybody has xdebug installed, maybe you will meet some problems like:

The Xdebug extension is not loaded. No code coverage will be generated.

That means you need to install xdebug for your PHP5. If you are using OpenSuse, it has a PHP Extensions repository, you can find more details from the following site:


http://download.opensuse.org/repositories/

and

http://download.opensuse.org/repositories/server:/php:/extensions/openSUSE_12.1/server:php:extensions.repo

You just need to install it simply as:

$sudo zypper ar  http://download.opensuse.org/repositories/server:/php:/extensions/openSUSE_12.1/server:php:extensions.repo

$sudo zypper install php5-xdebug

Now you fix the problem.

Start

OK, Let’s start to mark some tips about unit test for Symfony2.

First, a simple unit test:

// src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php
namespace Acme\DemoBundle\Tests\Utility;

use Acme\DemoBundle\Utility\Calculator;

class CalculatorTest extends \PHPUnit_Framework_TestCase
{
public function testAdd()
{
$calc = new Calculator();
$result = $calc-&gt;add(30, 12);

// assert that our calculator added the numbers correctly!
$this-&gt;assertEquals(42, $result);
}
}

You can run unit test via:

# run all tests in the Utility directory
$ phpunit -c app src/Acme/DemoBundle/Tests/Utility/

# run tests for the Calculator class
$ phpunit -c app src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php

# run all tests for the entire Bundle
$ phpunit -c app src/Acme/DemoBundle/

What about a functional unit test?

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
namespace Acme\DemoBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DemoControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();

$crawler = $client-&gt;request('GET', '/demo/hello/Fabien');

$this-&gt;assertTrue($crawler-&gt;filter('html:contains("Hello Fabien")')-&gt;count() &gt; 0);
}
}

Something more about links:

$link = $crawler-&gt;filter('a:contains("Greet")')-&gt;eq(1)-&gt;link();

$crawler = $client-&gt;click($link);

And form:


$form = $crawler-&gt;selectButton('submit')-&gt;form();

// set some values
$form['name'] = 'Lucas';
$form['form_name[subject]'] = 'Hey there!';

// submit the form
$crawler = $client-&gt;submit($form);

Now that you can easily navigate through an application, use assertions to test that it actually does what you expect it to. Use the Crawler to make assertions on the DOM:

// Assert that the response matches a given CSS selector.
$this-&gt;assertTrue($crawler-&gt;filter('h1')-&gt;count() &gt; 0);

Or, test against the Response content directly if you just want to assert that the content contains some text, or if the Response is not an XML/HTML document:

$this-&gt;assertRegExp('/Hello Fabien/', $client-&gt;getResponse()-&gt;getContent());

The test Client simulates an HTTP client like a browser and makes requests into your Symfony2 application:

$crawler = $client-&gt;request('GET', '/hello/Fabien');

The request() method takes the HTTP method and a URL as arguments and returns a Crawler instance.

Use the Crawler to find DOM elements in the Response. These elements can then be used to click on links and submit forms:

$link = $crawler-&gt;selectLink('Go elsewhere...')-&gt;link();
$crawler = $client-&gt;click($link);

$form = $crawler-&gt;selectButton('validate')-&gt;form();
$crawler = $client-&gt;submit($form, array('name' =&gt; 'Fabien'));

The click() and submit() methods both return a Crawler object. These methods are the best way to browse your application as it takes care of a lot of things for you, like detecting the HTTP method from a form and giving you a nice API for uploading files.

The request method can also be used to simulate form submissions directly or perform more complex requests:

// Directly submit a form (but using the Crawler is easier!)
$client-&gt;request('POST', '/submit', array('name' =&gt; 'Fabien'));

// Form submission with a file upload
use Symfony\Component\HttpFoundation\File\UploadedFile;

$photo = new UploadedFile(
'/path/to/photo.jpg',
'photo.jpg',
'image/jpeg',
123
);
// or
$photo = array(
'tmp_name' =&gt; '/path/to/photo.jpg',
'name' =&gt; 'photo.jpg',
'type' =&gt; 'image/jpeg',
'size' =&gt; 123,
'error' =&gt; UPLOAD_ERR_OK
);
$client-&gt;request(
'POST',
'/submit',
array('name' =&gt; 'Fabien'),
array('photo' =&gt; $photo)
);

// Perform a DELETE requests, and pass HTTP headers
$client-&gt;request(
'DELETE',
'/post/12',
array(),
array(),
array('PHP_AUTH_USER' =&gt; 'username', 'PHP_AUTH_PW' =&gt; 'pa$$word')
);

Last but not least, you can force each request to be executed in its own PHP process to avoid any side-effects when working with several clients in the same script:

$client-&gt;insulate();

Browsing

The Client supports many operations that can be done in a real browser:


$client-&gt;back();
$client-&gt;forward();
$client-&gt;reload();

// Clears all cookies and the history
$client-&gt;restart();
Accessing Internal Objects

If you use the client to test your application, you might want to access the client’s internal objects:


$history = $client-&gt;getHistory();
$cookieJar = $client-&gt;getCookieJar();

You can also get the objects related to the latest request:


$request = $client-&gt;getRequest();
$response = $client-&gt;getResponse();
$crawler = $client-&gt;getCrawler();

If your requests are not insulated, you can also access the Container and the Kernel:

$container = $client-&gt;getContainer();
$kernel = $client-&gt;getKernel();

Accessing the Container

It’s highly recommended that a functional test only tests the Response. But under certain very rare circumstances, you might want to access some internal objects to write assertions. In such cases, you can access the dependency injection container:


$container = $client-&gt;getContainer();

Be warned that this does not work if you insulate the client or if you use an HTTP layer. For a list of services available in your application, use the container:debug console task.

 

Something more details you should refer to the official symfony book from here.

Remove ibus, back to fcitx.

December 14th, 2011 | admin

$sudo zypper install fcitx fcitx-qt4 fcitx-devel fcitx-config-kde4
$sudo vim /etc/sysconfig/language

change :
INPUT_METHOD="fcitx"

Then,

export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
#export QT_IM_SWITCHER=imsw-multi #I do not know more about this line
export QT_IM_MODULE=fcitx

Reboot.

Enable mod_rewrite for OpenSuse 12.1

December 13th, 2011 | admin

I can not believe that mod_rewrite is not enabled by default on OpenSuse 12.1

First,

$sudo vim /etc/sysconfig/apache2

find the following line, it must look like:

APACHE_MODULES="suexec access actions alias auth auth_dbm autoindex cgi dir env expires
include log_config mime negotiation setenvif userdir ssl php5"

Add “rewrite” between “”.

Then,

$sudo /etc/init.d/apache2 restart

Now it works.

Repository for OpenSuse 12.1 in China

December 12th, 2011 | admin

http://mirrors.ustc.edu.cn/opensuse/distribution/12.1/repo/oss/

http://mirrors.ustc.edu.cn/opensuse/distribution/12.1/repo/non-oss/

http://mirrors.ustc.edu.cn/opensuse/update/12.1/

http://geeko.ioda.net/mirror/ati/openSUSE_12.1/

http://packman.inode.at/suse/12.1/

http://download.videolan.org/pub/vlc/SuSE/12.1/

#for Alipay, stardict and so on

http://download.opensuse.org/repositories/home:/hillwood/openSUSE_12.1/

http://download.opensuse.org/repositories/home:/swyear/openSUSE_12.1/

http://download.opensuse.org/repositories/home:/opensuse_zh/openSUSE_12.1/

PhpStorm does not work on OpenSuse 12.1 with Sun JDK(solution)

December 5th, 2011 | admin

After Sun JDK 1.7.0_01 configured for OpenSuse 12.1, PhpStorm does not work, I think it invokes /usr/lib/jvm/bin/java, but I can not find the folder, so I use the following solution:

$sudo ln -s /usr/lib/jdk1.7.0_01/ /usr/lib/jvm/java

Now it works.

Setup Sun JDK on OpenSuse

December 5th, 2011 | admin

Download JDK from http://java.sun.com, extra to /usr/lib/, mine is: /usr/lib/jdk1.7.0_01

Then:

$sudo /usr/sbin/update-alternatives --install /usr/bin/java java /usr/lib/jdk1.7.0_01/bin/java 3
$sudo /usr/sbin/update-alternatives --install /usr/bin/javac javac /usr/lib/jdk1.7.0_01/bin/javac 3

The last parameter is 3, it’s priority, not very important, you can find other by

$sudo /usr/sbin/update-alternatives --list java

It’s not important, do not care about it.

Now you have new JDK installed, let’s configure it:

$sudo /usr/sbin/update-alternatives --config java
$sudo /usr/sbin/update-alternatives --config javac

See the details, you can choose your new installed Sun JDK from list.

Build PHP 5 Development enviroment on OpenSuse 12.1

December 5th, 2011 | admin

First of all, you must have OpenSuse 12.1 installed. Then let’s start.

Install and configure MySQL

$sudo zypper install mysql mysql-client

$sudo /sbin/chkconfig --add mysql

$sudo /etc/init.d/mysql start

$sudo mysql_secure_installation

Optional, let’s create a test database

$mysql -uroot -p
$CREATE DATABASE `voicens` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Install and configure Apache2

$sudo zypper install apache2

$sudo /sbin/chkconfig --add apache2

$sudo /etc/init.d/apache2 start

Install and configure PHP5

$sudo zypper install apache2-mod_php5

$sudo /etc/init.d/apache2 restart

$sudo zypper install php5-mysql php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm php5-pdo

$sudo /etc/init.d/apache2 restart

cheers.