OTRS on Ubuntu

First get the source code from official website, and untar it via:

$ sudo tar xjvf otrs-3.3.8.tar.bz2 -C /opt/
$ cd /opt
$ sudo mv otrs-3.3.8/ otrs

Check the modules :

$ /opt/otrs/bin/otrs.CheckModules.pl

Install following packages:

$ sudo apt-get install liblwp-useragent-determined-perl libapache2-mod-perl2 libnet-dns-perl libnet-smtp-ssl-perl libnet-smtp-tls-butmaintained-perl libyaml-perl
$ sudo apt-get install libgd-text-perl libjson-xs-perl libpdf-api2-perl libtext-csv-xs-perl libxml-parser-perl

Add corresponding users and group:

$ sudo useradd -d /opt/otrs/ -c 'OTRS user' otrs
$ sudo usermod -G www-data otrs

Create the OTRS Config Files:

$ pwd
/opt/otrs
$ sudo cp Kernel/Config.pm.dist Kernel/Config.pm
$ sudo cp Kernel/Config/GenericAgent.pm.dist Kernel/Config/GenericAgent.pm

Check dependencies via:

$ perl -cw /opt/otrs/bin/cgi-bin/index.pl
/opt/otrs/bin/cgi-bin/index.pl syntax OK
$ perl -cw /opt/otrs/bin/cgi-bin/customer.pl
/opt/otrs/bin/cgi-bin/customer.pl syntax OK
$ perl -cw /opt/otrs/bin/otrs.PostMaster.pl
/opt/otrs/bin/otrs.PostMaster.pl syntax OK

Set permission:

$ sudo bin/otrs.SetPermissions.pl --otrs-user=otrs --web-user=www-data --otrs-group=www-data --web-group=www-data /opt/otrs

Now Set the conf file for apache2:

$ sudo cp /opt/otrs/scripts/apache2-httpd.include.conf /etc/apache2/sites-available/otrs
$ sudo ln -s /etc/apache2/sites-available/otrs.conf  /etc/apache2/sites-enabled/otrs
$ sudo a2ensite otrs
$ sudo service apache2 restart

Now go to following URL for installation:
http://joggler.xxx.xxx..com/otrs/installer.pl

After installation, restart mysql and httpd, or you will meet OTRS - Access denied for user otrs@localhost

Add crontab tasks via following commands:

# su otrs
$ cd /opt/otrs/var/cron
$ pwd
/opt/otrs/var/cron
$ for foo in *.dist; do cp $foo `basename $foo .dist`; done
$ /opt/otrs/bin/Cron.sh start
/opt/otrs/var/cron
Cron.sh - start/stop OTRS cronjobs
Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
(using /opt/otrs) done
$ crontab -l

Now everything goes OK, visit joggler.xxx.xxx..com/otrs/customer.pl for visit the customer panel.

Change the password for root@localhost:

# ./otrs.SetPassword.pl root@localhost PLATFORM
Set password for user 'root@localhost'.
Done.

Install And Configure otrs On CentOS

Prerequisite

Install following Packages under CentOS:

$ sudo yum install wget mysql-server mysql php-mysql httpd perl-URI perl-Net-DNS perl-IO-Socket-SSL perl-XML-Parser mod_perl perl-TimeDate perl-Net-DNS procmail perl perl-LDAP perl-Crypt-SSLeay

Now configure the mysqld via:

$ sudo chkconfig --levels 235 mysqld on
$ sudo service mysqld start
$ sudo /usr/bin/mysql_secure_installation
$ sudo chkconfig --levels 235 httpd on

Install otrs

Download the otrs from Official website, I downloaed the rpm package for CentOS, then install it via:

sudo rpm -ivh otrs-3.3.8-01.noarch.rpm 

As root do following:

# cd /etc/httpd/conf.d/
# cp zzz_otrs.conf otrs.conf
# service httpd start

We have to disable SELinux and delete all of the iptables rules:
Close the SELinux via:

# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
# SELINUX=permissive
SELINUX=disabled

If you don’t disable SELINUX, then you may meet following error message:

消息: Kernel/Config.pm isn't writable!
If you want to use the installer, set the Kernel/Config.pm writable for the webserver user!

After disable the SELINUX, Restart the computer.
Flush all of the pre-defined iptables rules:

# iptables -F
# service iptables save

Now open the browser visit: http://Your_Server/ostr/installer.pl

When Configurating the database, in the second step, the machine should be selected as localhost.

If you want to delete the otrs database, or if the installation step tells you otrs database exists, you can using following command for drop this database:

[root@CentOS conf.d]# mysqladmin -u root -p  drop otrs
Enter password: 
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'otrs' database [y/N] y
Database "otrs" dropped

Configuration of otrs

The start page at:
http://Your_Machine/otrs/index.pl

Customer Start page:
http://Your_Machine/otrs/customer.pl

Enable the crons tasks(mandantory):

$ su root
# su -m otrs -c 'cd /opt/otrs/bin/ && ./Cron.sh start'
# crontab -l -u otrs

Add dynamic field via:
系统管理->工单设置->动态字段, at the field of “工单”, click it and then you can add the customized field. This will affect customer’s submitted ticket forms.

Change smtp configuration:
系统管理->系统配置-> 搜索smtp, you will meet Core::Sendmail, define the corresponding field and types, then you can use smtp for sending emails.

Uninstall otrs

Finally the team didn’t use otrs, but its email annoyed me for a long time. Finally I found it’s this machine who runs otrs. so I just login to 53, and run:

# rpm -e otrs


Also remove the crontab jobs and etc.

# su -m otrs 
bash: /root/.bashrc: Permission denied
bash-4.1$ ./Cron.sh stop
/opt/otrs/bin
Cron.sh - start/stop OTRS cronjobs
Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
done
[root@Linux01 conf.d]# crontab -l -u otrs
no crontab for otrs

Also remove the configuration file under /etc/httpd/conf.d/otrs.conf, then restart the httpd server.

Graphic Card On ArchLinux

Since I got several Intel powered PC, It’s is essential to know how graphics card works, thus I could get the fastest performance of my PC or Server.

Detect Graphics Card

Use lspci we could get the output of all PCI equipments, get the VGA related information via:

$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)

To know the detailed information of this equipment:

$ lspci -v -s 00:02.0
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])
	Subsystem: Hewlett-Packard Company Device 161c
	Flags: bus master, fast devsel, latency 0, IRQ 57
	Memory at d4000000 (64-bit, non-prefetchable) [size=4M]
	Memory at c0000000 (64-bit, prefetchable) [size=256M]
	I/O ports at 4000 [size=64]
	Expansion ROM at <unassigned> [disabled]
	Capabilities: <access denied>
	Kernel driver in use: i915
	Kernel modules: i915

Memory at c0000000 (64-bit, prefetchable) [size=256M] shows the Intel Video Card with 256MB of video RAM. Or you can get the detailed via : sudo lspci -v | more.

If you want the graphic ways, simply install following tool:

$ sudo pacman -S hardinfo
$ hardinfo

The picture shows as following:

/images/hardinfo.jpg

lshw could also shows the result:

$ sudo lshw -class display
  *-display               
       description: VGA compatible controller
       product: 2nd Generation Core Processor Family Integrated Graphics Controller
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 09
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:57 memory:d4000000-d43fffff memory:c0000000-cfffffff ioport:4000(size=64)

Get the config from Intel Doc

Refer to following link:
http://en.wikipedia.org/wiki/Comparison_of_Intel_graphics_processing_units, for example, My cpu is Intel(R) Core(TM) i5-2520M , then find the “Core i5-2xxxM”, it shows the graphic card is HD Graphics 3000.

Configure Intel Graphics Card

Install driver:

$ sudo pacman -S xf86-video-intel

32-bit 3D Support:

$ sudo pacman -S lib32-intel-dri

tmux tips

Following is my tmux cheet sheet, it will be updated from time to time.
Create a new tmux session:

$ tmux new

Given session name:

$ tmux new -s session-name

Detach: ctrl + b, ‘d`.
List existing session:

$ tmux ls

Attached to existing session:

$ tmux a -t session-name

Attached to first session:

$ tmux a

Database In Node.js

MongoDB

Install MongoDB via:

$ sudo pacman -S mongodb
$ sudo systemctl start mongodb
$ sudo systemctl enable mongodb
$ mongodb

Later I will cover this topic.

MySQL

Installation of MySQL

The implementation chosen by Arch Linux is called MariaDB, install it via:

$ sudo pacman -S mariadb 

Configuration steps:

$ sudo systemctl start mysqld.service
[Trusty@~]$ sudo mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Now you can login the mariadb via:

$ mysql -u root -p
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

Node.js of MariaDB

Redis

Running result:

127.0.0.1:6379> SET my.key test
OK
127.0.0.1:6379> KEYS my.key
1) "my.key"
127.0.0.1:6379> VALUES my.key
(error) ERR unknown command 'VALUES'
127.0.0.1:6379> GET my.key
"test"
127.0.0.1:6379> keys *
 1) "user:jeff@amazon.com:followers"
 2) "user:jeff@amazon.com:follows"
 3) "user:bill@microsoft.com:followers"
 4) "mykey"
 5) "rq:job:b9b76e04-8bb7-4652-83e9-4453de981554"
 6) "rq:queue:default"
 7) "user:mark@facebook.com:data"
 8) "_kombu.binding.celeryev"
 9) "user:fred@fedex.com:data"
10) "user:jeff@amazon.com:data"
11) "rq:queues"
12) "user:bill@microsoft.com:follows"
13) "_kombu.binding.celery"
14) "my.key"
15) "user:bill@microsoft.com:data"
127.0.0.1:6379> KEYS my.key
1) "my.key"
127.0.0.1:6379> SET online.users 0
OK
127.0.0.1:6379> onlien.users
(error) ERR unknown command 'onlien.users'
127.0.0.1:6379> online.users
(error) ERR unknown command 'online.users'
127.0.0.1:6379> KEYS online.users
1) "online.users"
127.0.0.1:6379> GET online.users
"0"
127.0.0.1:6379> INCR online.users
(integer) 1
127.0.0.1:6379> INCR onlien.users
(integer) 1
127.0.0.1:6379> INCR online.users
(integer) 2
127.0.0.1:6379> HSET profile.1 name Guillermo
(integer) 1
127.0.0.1:6379> HGETALL profile.1
1) "name"
2) "Guillermo"
127.0.0.1:6379> HSET profile.1 last Rauch
(integer) 1
127.0.0.1:6379> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"
127.0.0.1:6379> HSET profile.1 programmer 1
(integer) 1
127.0.0.1:6379> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"
5) "programmer"
6) "1"
127.0.0.1:6379> HDEL profile.1 programmer
(integer) 1
127.0.0.1:6379> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"
127.0.0.1:6379> RPSH profile.1.jobs "job 1"
(error) ERR unknown command 'RPSH'
127.0.0.1:6379> RPUSH profile.1.jobs "job 1"
(integer) 1
127.0.0.1:6379> HGET profile.1
(error) ERR wrong number of arguments for 'hget' command
127.0.0.1:6379> HGETALL profile.1
1) "name"
2) "Guillermo"
3) "last"
4) "Rauch"
127.0.0.1:6379> LRANGE profile.1.jobs 0 -1
1) "job 1"
127.0.0.1:6379> 
127.0.0.1:6379> RPUSH profile.1.jobs "job 2"
(integer) 2
127.0.0.1:6379> LRANGE profile.1.jobs 0 -1
1) "job 1"
2) "job 2"
127.0.0.1:6379> RPUSH profile.1.jobs "job 3"
(integer) 3
127.0.0.1:6379> LRANGE profile.1.jobs 0 -1
1) "job 1"
2) "job 2"
3) "job 3"

DataSet in Redis:

127.0.0.1:6379> SADD myset "a member"
(integer) 1
127.0.0.1:6379> SMEMBERS myset
1) "a member"
127.0.0.1:6379> SADD myset "a second member"
(integer) 1
127.0.0.1:6379> SMEMEBERS myset
(error) ERR unknown command 'SMEMEBERS'
127.0.0.1:6379> SMEMBERS myset
1) "a second member"
2) "a member"
127.0.0.1:6379> SREM myset "a second member"
(integer) 1
127.0.0.1:6379> SMEMBERS myset
1) "a member"