Friday, November 14, 2014

Install aria2 to Raspberry Pi

Install via apt-get
#apt-get install aria2

Create init script
#! /bin/sh
# /etc/init.d/aria2

### BEGIN INIT INFO
# Provides: aria2cRPC
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c RPC init script.
# Description: Starts and stops aria2 RPC services.
### END INIT INFO

#VAR
RUN="/usr/bin/aria2c"
ARIA_PID=$(ps ux | awk '/aria2c --enable-rpc/ && !/awk/ {print $2}')

# Some things that run always
touch /var/lock/aria2cRPC

# Carry out specific functions when asked to by the system
case "$1" in

start)
echo "Starting script aria2cRPC "
if [ -z "$ARIA_PID" ]; then
nohup $RUN --enable-rpc --rpc-user=admin --rpc-passwd=rfujcfdh --rpc-listen-port=8000 --rpc-listen-all --daemon -D --conf-path=/root/.aria2/aria2.conf
/bin/mount -t cifs -o user=,password=,rw,file_mode=0777,dir_mode=0777 //192.168.1.3/DuneHDD_90eab4c2_0dd9_4cac_84fa_d551745cd532 /mnt
echo "Started"
else
echo "aria2cRPC already started"
fi
;;

stop)
echo "Stopping script aria2cRPC"
if [ ! -z "$ARIA_PID" ]; then
kill $ARIA_PID
fi
echo "OK"
;;

status)
if [ ! -z "$ARIA_PID" ]; then
echo "The aria2cRPC is running with PID = "$ARIA_PID
else
echo "No process found for aria2c RPC"
fi
;;
*)
echo "Usage: /etc/init.d/aria2cRPC {start|stop|status}"
exit 1
;;
esac

exit 0

Install no-ip to Rasberry Pi

You will be able to install No-IP.com’s DUC on Ubuntu in just a few minutes with Terminal. Once you have opened up your Terminal window you will need to login as the “root” user. You can become the root user from the command line by entering “sudo -s” followed by the root password on your machine.
cd /usr/local/src/
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar xf noip-duc-linux.tar.gz
cd noip-2.1.9-1/
make install

You will then be prompted to login with your No-IP.com account username and password.

If you get “make not found” or “missing gcc” then you do not have the gcc compiler tools on your machine. You will need to install these in order to proceed.

Resize root partition on Raspberry Pi

You have 8GB SD card for your Pi, however some images that you install to your Pi is just for 2GB, 4GB SD card. Therefor you could not use the left capacity of you SD card. In my case I have 2GB SD card on 1GB image.

To utilizes this, you must re-size the root partition and this is how to do that.
Log in to your Pi via SSH:
root@raspberry-pi:~# fdisk -l

Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes
4 heads, 16 sectors/track, 60032 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027aa3

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      104447       51200    b  W95 FAT32
/dev/mmcblk0p2          104448     1742847      819200   83  Linux
/dev/mmcblk0p3         1742848     1945599      101376   82  Linux swap / Solaris


Friday, September 19, 2014

Install Oracle 11gR2 on HP-UX 11.31

This installation of Oracle 11.2.0.1 is for HP-UX 11.31 ia64.

Pre-Instalation Tasks
1. Create oracle User Account
Login as root and create the user oracle which belongs to oinstall and dba groups.
su -
# /usr/sbin/groupadd dba
# /usr/sbin/groupadd oinstall
# /usr/sbin/useradd -g oinstall -G dba -m -s /usr/local/bin/bash -p /home/oracle oracle
# passwd oracle
# chown -R oracle:oinstall /home/oracle
Note: "#" sign means that you need execute this command as root user.

Tuesday, May 27, 2014

Debian-Installer: Preseed with minimal Debian and LVM partitioning

Modify an existing CD image to preseed d-i
Create copy of image
#mount -o loop debian-7.5.0-amd64-CD-1.iso /mnt
#mkdir Debian7x64
#rsync -a -H --exclude=TRANS.TBL /mnt Debian7x64
#umount /mnt

Hack the initrd
# mkdir irmod
# cd irmod
# gzip -d < ../Debian7x64/install.amd/initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames
# cp ../preseed.cfg preseed.cfg
# find . | cpio -H newc --create --verbose | gzip -9 > ../Debian7x64/install.amd/initrd.gz
# cd ../
# rm -fr irmod/

Friday, May 16, 2014

Install nginx naxsi mod_pagespeed and spdy on Debian/Ubuntu

This is guide to installing and configuring Nginx to serve static files. Which is to say, this is how to install and set up Nginx to serve static files whether those files are simply stylesheets, images and JavaScript or full static sites like this one. What follows is the best practices of Nginx

Nginx beats Apache for static content
Whether you’re just building a quick live prototype or running an actual live website of static files, you’ll need a good server. So why not use Apache? Simply put, Apache is overkill.

Unlike Apache, which is a jack-of-all-trades server, Nginx was really designed to do just a few things well, one of which is to offer a simple, fast, lightweight server for static files. And Nginx is really, really good at serving static files. In fact, in my experience Nginx with PageSpeed, gzip, far future expires headers and a couple other extras I’ll mention is faster than serving static files from Amazon S33 (potentially even faster in the future if Verizon and its ilk really do start throttling cloud-based services).

Tuesday, May 13, 2014

Install nginx with naxsi and doxi rules

Install nginx with naxsi and doxi rules
apt-get install nginx nginx-naxsi

Enable naxsi core rules

nano /etc/nginx/nginx.conf
Uncomment
#include /etc/nginx/naxsi_core.rules;

to
include /etc/nginx/naxsi_core.rules;

Enable naxsi basic rule and check rule
nano /etc/nginx/sites-enabled/default

Under location /
Uncomment
#include /etc/nginx/naxsi.rules;

to
include /etc/nginx/naxsi.rules;

You've enabled naxsi for nginx, now look at the file /etc/nginx/naxsi.rules
cat, this is sample configuration
# Sample rules file for default vhost.

#LearningMode;
SecRulesEnabled;
#SecRulesDisabled;
#DeniedUrl "/RequestDenied";
DeniedUrl "/denied.html";

## check rules
CheckRule "$SQL >= 8" BLOCK;
CheckRule "$RFI >= 8" BLOCK;
CheckRule "$TRAVERSAL >= 4" BLOCK;
CheckRule "$EVADE >= 4" BLOCK;
CheckRule "$XSS >= 8" BLOCK;


Thursday, May 8, 2014

Postfix dovecot sasl amavisd-new clamav spamassassin postgrey opendkim vitual domains on Debian 7 (Wheezy)

Introduction
In this setup is for a small to medium sized email server with Postfix virtual mailboxes which can be used for multiple domains and non-Linux accounts. If you are new to Postfix please read PostfixBasicSetupHowto to understand the basics before proceeding with this Howto. Also, information is presented about integration with ClamSMTP (an SMTP filter for Postfix) and other mail servers that check for viruses (using the ClamAV anti-virus software).

Example Setup
In this example emails are hosted for two separate domains, domain1.com and domain2.com. (Replace these with your own domain names.

Install Postfix
Install the postfix package.
For convenience in testing mail delivery, also install mailx package for use as command line mail utility program. (mailx is a dummy package for one of three mail programs, the most widely used of which is bsd-mailx.)
$ sudo apt-get install postfix bsd-mailx

Wednesday, February 26, 2014

Issue with nagios notify ping 'WARNING'

I installed nagios version 4.0.2 on CentOS 6.5 64bit from source, the installation succeeded  and nagios could start. However there is issue with notification when nagios checking 'check_ping' command, the host is alive and packet lost is 0%, nagios still send alert to my email. This is quite annoying.

Email notification like this:

***** Nagios *****

Notification Type: RECOVERY

Service: PING
Host: x.x.x.x
Address: x.x.x.x
State: OK

Date/Time: Wed Feb 26 16:08:46 ICT 2014

Additional Info:

PING OK - Packet loss = 0%, RTA = 341.55 ms

After searching around, I found solution related to check_ping command defined in /usr/local/nagios/etc/objects/commands.cfg. You need to make the check_ping command definition the same as check-host-alive. Otherwise you will get the same notification when it happens next.

define command{
        command_name    check-host-alive
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5

        }

define command{
        command_name    check_ping
        #command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5

        }

Monday, February 17, 2014

ORA-01194: file 1 needs more recovery to be consistent : No archivelog database asking for recovery

ORA-01194: file 1 needs more recovery to be consistent

This is the case datafiles were inconsistent and it is asking for recovery when you try to start the noarchivelog mode database.

Step 1: Start the database in mount.
$sqlplus / as sysdba

SQL>startup mount;

Step 2: Check the datafiles which required recovery.
SQL>select * from v$recover_file;

Step 3: As you do not have the needed archivelogs to recover those files, you should drop them offline then recover database and open.

SQL>alter database datafile <FILE#> offline drop;

NOTE: For sure you will loose data inside those files.

Step 4: Recover the database.
SQL>recover database;

If you come across below error

ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

then, do the following
SQL>recover database using backup controlfile until cancel;

It will ask to Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

When the session request a sequence for recovery please point write the path of the each online redolog one after another untill its say database recovered. You can select the redolog member from below query.

SQL>select group#, member FROM v$logfile;
    GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
         3
/home/oracle/u01/oradata/SID/redo03.log

         2
/home/oracle/u01/oradata/SID/redo02.log

         1
/home/oracle/u01/oradata/SID/redo01.log
NOTE: Please repeat the recovery process, When the session request a sequence for recovery please point write the path of the online redolog:

Step 5: Then open the database resetlogs.
SQL>alter database open resetlogs;

Wednesday, February 12, 2014

Nano – Shortcuts, Syntax Highlight And Nanorc Config File

I have been using nano as my favorite console editor (i use emacs/kate for the rest) for some time now. It’s simplicity, the speed and usefulness of it made it what it is. But recently, i’ve been trying to find out more features that i might been missing. One of those were the shortcuts. The other was syntax highlighting! Meanwhile, the things i discovered!

Before we start, here’s some useful links:

So let’s start with the basic shortcuts!
“Special functions use the Control (Ctrl) key, displayed in the help and shortcut lists as ^; the Meta key, displayed as M; or the Escape (Esc) key.”
The help system in nano is available by pressing ^G.