Wednesday, 22 June 2011

Archiving and extracting tar files

Create tar.gz file:
tar -czf /path/to/output/folder/filename.tar.gz/path/to/folder
Extract tar.gz to folder:
tar -xvzf /path/to/output/folder/filename.tar.gz -C /path/to/folder
List the contents of a tar.gz file:
tar -ztvf file.tar.gz
Where:

c: create
x: extract
t: List the contents of an archive
v: Verbosely list files processed (display detailed information)
z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
j: Filter archive through bzip2, use to decompress .bz2 files.
f filename: Use archive file called filename

Possibly Related Posts

Connect to a WPA/WPA2 Secured network in Linux

A combination of wpa_supplicant and wpa_passphrase will do the trick.

First, you need to install the relevant software. You need to have a wired connection at this point, otherwise this wont work.
sudo apt-get install wireless-tools wpasupplicant
Run iwlist scanning, and check your card can see the wireless network in question If it can, run:
wpa_passphrase [your-wireless-network-name] > wpa.conf
The prompt will wait for you to enter a passphrase. Do this and hit enter.
Run wpa_supplicant. Replace wext with the correct wireless driver (which is probably wext, but run wpa_supplicant --help to check) and wlan0 with your wireless interface
wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf
If that works, you should see text to the effect of “successfully associated”. If not, try again with a different driver, make sure your passphrase is correct, and make sure your wireless interface is working properly.
Hit Ctrl+c, then the up arrow, then add a -B (for background) onto the end of the last command, thus:
wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf -B
Run dhclient -r to release any DHCP leases you have.
Run dhclient wlan0 to get a new IP address. Substitute wlan0 for your wireless interface, of course.
You should now be connected.

Possibly Related Posts

Sunday, 19 June 2011

OpenKM LDAP auth

Hello, after some time kicking the machine and trying a several configurations, i got it working..

NOTE: for the config options to be red from the file you must first delete the equivalent configs from the web user interface (those are stored in the DB and override the config file)

Checkout the relevant parts of the final configuration files after the break

Possibly Related Posts

Install OpenKM on ubuntu 10.04 LTS

There’re several ways to install it, we use to install in Ubuntu but can be used any other Linux flavor.

Enable the partner repository:
sudo su
vi /etc/apt/sources.lst
Uncomment the following lines:
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner
Install needed packages:

Execute on terminal the command
$ sudo aptitude install sun-java6-bin sun-java6-jdk sun-java6-jre imagemagick openoffice.org-core openoffice.org-java-common openoffice.org-writer openoffice.org-impress openoffice.org-calc swftools tesseract-ocr
set the Java Home environment variable
vi /etc/environment
add this line at the end of the file:
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
Now update the environment variables:
# source /etc/environment
Install OpenKM

Download (http://www.openkm.com/Download.html) OpenKM 5.0.x + JBoss 4.2.3.GA bundle and uncompress on your file system disk (a good option is to uncompress under /opt/).

Execute on terminal the command
$ unzip OpenKM-5.0.x-JBoss-4.2.3.GA.zip
For document preview you need add these two entries in the OpenKM.cfg file:
system.openoffice=on
system.swftools.pdf2swf=/usr/bin/pdf2swf
You can configure OpenKM to use a remote server for OpenOffice document conversion:
system.openoffice.server=http://localhost:8080/converter/convert
Or you can configure OpenOffice.org listen port and a maximun conversion tasks:
system.openoffice.path=/usr/lib/openoffice
system.openoffice.tasks=5
system.openoffice.port=2222
Note that system.openoffice.tasks and system.openoffice.port have already a default value and is not needed to be set.

Enabling OCR

To enable OCR you must put the files system path of OCR engine:
system.ocr=/usr/local/bin/tesseract
Enable PS to SWF conversion

To enable postscript document preview, OpenKM need to convert PS files to SWF using the ps2pdf utility from Ghostscript:
system.ghostscript.ps2pdf=/usr/bin/ps2pdf
Enable image preview

To enable image preview, you need to install que ImageMagick convert utility and configure:
system.imagemagick.convert=/usr/bin/convert
Configuring chat service

By default chat and autologin are enabled. In order to enable or disable values can be "on" or "off".
chat.enabled=off
chat.autologin=off
Check http://wiki.openkm.com/index.php/Application_configuration for more information

First login

Execute the file /opt/jboss-4.2.3.GA/bin/run.sh to run OpenKM + JBoss application server.

If you want your OpenKM installation to be accessed from other computers add the -b 0.0.0.0 command line parameter (see Basic application knowledge)

Open on a client browser the URL http://localhost:8080/OpenKM/.

Autenticate to OpenKM using user "okmAdmin" with password "admin".

Note: From OpenKM 5.x there's a property definition in OpenKM.cfg to create automatically database. Once the tables are created, change the hibernate.hbm2ddl property from create to none. Do it after first time running, in other case all repository it'll be deleted and created in next OpenKM starting.

Please take a look at http://forum.openkm.com/ if you have any problem

Possibly Related Posts

Gammu SMSD files backend conf

References:
http://wammu.eu/docs/manual/smsd/config.html#gammu-smsdrc
http://wammu.eu/docs/manual/smsd/files.html#gammu-smsd-files
http://wammu.eu/docs/manual/smsd/run.html#gammu-smsd-run

Instead of using a MySQL backend you can use a files backend:
[gammu]
port = /dev/ttyUSB0connection = at19200
# Debugging
#logformat = textall
synchronizetime = yes
# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = files
logfile = syslog
# Increase for debugging information
debuglevel = 0
# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/

Possibly Related Posts

Setting up SMS gateway using Gammu

Install Gammu and Gammu SMS Daemon by running the command
sudo apt-get install gammu gammu-smsd
Create a gammu configuration file /etc/gammurc, whose contents look like this
[gammu]
port=/dev/ttyUSB0
connection=at9600
Test that the SMS functionality by sending a message like this
$ echo "Test message"|gammu sendsms TEXT <Phone Number>
Setting up the SMS Daemon
A prerequisite is that a MySQL server is installed (either local or remote). Create the necessary tables in the database by running the SQL statements in /usr/share/doc/gammu/examples/sql/mysql.sql.gz. Create a gammu-smsd configuration file /etc/gammu-smsdrc
[gammu]
port = /dev/ttyUSB0model =
connection = at19200
synchronizetime = yes
logfile =
logformat = nothing
use_locking =
gammuloc =

[smsd]
debuglevel = 255
logfile = smsd.log
Service = mysql
User = root
Password = <Password>
Database = smsd
Now test that the daemon is receiving the messages by sending an SMS to the number associated with the SIM in the modem. Verify that the message is written into the table named "Inbox". Similarly you can send a message out by creating a row in the "Outbox" table.

Notes:
  • You can inject sms into the daemon from the command line with gammu-smsd-inject example:
    • echo "All your base are belong to us" | gammu-smsd-inject TEXT 123456
  • Gammu-smsd also supports other backends like txt files in a specified folder
  • To use SMSD as a daemon, you might want to use the init script which is shipped with Gammu in contrib/init directory. It is not installed by default, either install it manually or check INSTALL file for instructions.

Possibly Related Posts

Using Gammu

Install:
sudo apt-get install gammu
To configure:
edit /etc/gammurc:

[gammu]
port = /dev/ttyUSB0model =
connection = at19200
synchronizetime = yes
logfile =
logformat = nothing
use_locking =
gammuloc =
Or run gammu-config

Send sms:
echo "boo" | gammu --sendsms TEXT [recipient mobile number]
Read all sms:
gammu --getallsms
Get sms folders:
gammu --getsmsfolders
Delete all sms:
gammu --deleteallsms [folder number]

Possibly Related Posts

Zabbix - SMS with Gammu

Create an sms script (and make it executable) on the zabbix server in the AlertScriptsPath (=/etc/zabbix/alert.d/ on ubuntu)
#!/bin/sh
HOME=/etc
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LOGFILE="/var/log/zabbix-server/zabbix-sms.log"
echo "Recipient='$1' Message='$3'" >> ${LOGFILE}
MOBILE_NUMBER=`echo "$1" | sed s#\s##`
# Log it
echo "echo $3 | /usr/bin/sudo /usr/bin/gammu --sendsms TEXT ${MOBILE_NUMBER}" >>${LOGFILE}
# Send it
echo "$3" | /usr/bin/sudo /usr/bin/gammu --sendsms TEXT "${MOBILE_NUMBER}" 1>>${LOGFILE} 2>&1
# EOF
Add:
zabbix ALL = NOPASSWD:/usr/bin/gammu
to the sudoers to make it available for the zabbix user

Configure a media type (menu administration) with the same name as your script (without path, without parameters)

Link this media type to a user (menu administration) and use the phone number as Send to parameter.

Dont forget to give zabbix a shell in /etc/passwd and permissions to write in the log file...

Note: if you have gammu configured as a daemon use gammu-smsd-inject instead of gammu --sendsms or
echo "$3" > /var/spool/gammu/outbox/OUT"${MOBILE_NUMBER}".txt
If you are using the files backend

I use a hawaii usb gsm modem and my /etc/gammurc looks like this:
[gammu]
port = /dev/ttyUSB0
model =
connection = at19200
synchronizetime = yes
logfile =
logformat = nothing
use_locking =
gammuloc =

Possibly Related Posts

Saturday, 4 June 2011

Configure LDAP authentication for Alfresco

Under the /subsystems/authentication structure, there are folders for ldap, passthru, etc. In the ldap folder, there is a .properties file... ldap-authentication.properties.
This is what you have to edit...
Specifying your server, ldap structure, authentication account, if you sync or not, etc. Go through it, there are pretty good explanations in the comments.

Lastly, edit the repository.properties file... add ldap1:ldap to the chain (probably only has alfrescoNtlm on it?) to activate your ldap config. You can also set this in the alfresco-global.properties file
file: /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/repository.properties
 - or -
file: /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
# The default authentication chain
authentication.chain=ldap1:ldap,alfrescoNtlm1:alfrescoNtlm
restart, test...

Check out the example after the break.

Possibly Related Posts

Install Alfresco on Ubuntu 10.04 LTS

Enable the partner repository:
sudo su
vi /etc/apt/sources.lst
Uncomment the following lines:
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner
update your system:
# apt-get update
# apt-get upgrade
Install the needed packages:
# apt-get install mysql-server sun-java6-jdk imagemagick openoffice.org-core openoffice.org-java-common openoffice.org-writer openoffice.org-impress openoffice.org-calc swftools
set the Java Home environment variable
vi /etc/environment
add this line at the end of the file:
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
Now update the environment variables:
# source /etc/environment

Create the alfresco database:
# mysql -uroot -p

CREATE DATABASE alfresco DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL PRIVILEGES ON alfresco.* TO alfresco@localhost IDENTIFIED BY 'alfresco';
GRANT SELECT,LOCK TABLES ON alfresco.* TO alfresco@localhost IDENTIFIED BY 'alfresco';
FLUSH PRIVILEGES;
quit;
Create a directory for alfresco:
# mkdir -p /opt/alfresco# cd /opt/
Download the latest alfresco release (replace the url if necessary)
# wget http://dl.alfresco.com/release/community/build-3370/alfresco-community-3.4.d-installer-linux-x32.bin
# sudo chmod +x alfresco-community-3.4.d-installer-linux-x32.bin
# ./alfresco-community-3.4.d-installer-linux-x32.bin
And follow the wizard

Then point your browser to:

http://yourserver:8080/alfresco (Alfresco DMS)
and
http://yourserver:8080/share (Alfresco Share)


Log in with user:admin e password:admin

Possibly Related Posts

Friday, 3 June 2011

Xenserver Backup solution

After reviewing some of the available backup solutions (see my previous post) I've opted to use the script provided by Mark Round but I've modified it a bit to allow backing up the VMs to .xva files with an independent schedule from the template backups, I use this to store xva files of my VMs in tapes monthly.

To use it you just have to place the script in /usr/local/bin/snapback.sh in your pool master host and add a line to /etc/crontab:
2 1 * * * root /usr/local/bin/snapback.sh > /var/log/snapback.log 2>&1
Then you can configure the scheduling and retention for each VM, from the XenCenter, by adding the following costume fields:
  • backup - to set the schedule for the template backups (daily, monthly or weekly)
  • retain - to set the number of backup templates to keep
  • xva_backup - to set the schedule for the xva backups (daily, monthly or weekly)
  • xva_retain - to set the number of xva files to keep
Click in the "read more" link to see the script.

Possibly Related Posts