Monday, February 28, 2011

Curl to download a file

curl -C - -O http://www.mirror.com/path/to/file.zip

Thursday, February 10, 2011

Mysql

To dump data from mysql table to txt file:

mysqldump --no-create-info --extended-insert=FALSE --compact  psydex_rss_twitter MESSAGES > /tmp/testinsert.sql

(--extended-insert makes every row it's own insert statement)



SELECT col1,col2,col3
INTO OUTFILE '/tmp/file.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table_here
WHERE col1 > 857461

LOAD DATA LOCAL INFILE '/tmp/file.csv'
INTO TABLE table_here
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Wednesday, January 26, 2011

ASUS RT-N10 with Tomato Firmware

The following outlines steps taken to load the Tomato firmware on an ASUS RT-N10 wireless router.  I used Fedora 13 as my desktop to download and update the firmware on the ASUS router.

0.  Reset the ASUS to the factory firmware.  Turn off the router and hold the reset button in while powering it back on.  Stopping pressing the reset button  after the power light blinks.

1.  Download the firmware which works with the ASUS RT-N10 router.  The main Tomato download page is located at http://tomatousb.org/download Look for the link to the Older Firmware Versions.  I used the following firmware http://sourceforge.net/projects/tomatousb/files/Rotten/tomato-K26-1.28.9052MIPSR2-beta23-Std.rar/download

2. On your linux box, install tftp.


# yum install tftp

3.  Turn off you network interface

# ifconfig eth0 off

4. Plug Ethernet cable from Linux box into one of the LAN ports on the ASUS RT-N10.


5. Turn on Linux Box network interface

# ifconfig eth0 192.168.1.2 on

6. Flash the ASUS RT-N10

# CD <directory where firmware is located>
# unrar e tomato-K26-1.28.9052MIPSR2-beta23-Std.rar
# tftp 192.168.1.1
tftp> binary
tftp> put tomato-K26-1.28.9052MIPSR2-beta23-Std



When the tftp> prompt returns, the firmware has been pushed to the router.  There is no response from the router to indicate the firmware has completed loading.  I waited about five minutes, then powered cycled the router.

On boot-up I hit the router via the url http://192.168.1.1  I was presented with a menu about clearing the NVRAM, which I selected and the router started rebooting.  I waited about a minute and hit the URL again, and was presented with the Tomato Web admin page.  The default username was admin and the password was admin.  Be sure to changed after logging into the router.

I configured my router as wireless ethernet bridge.  I followed the guide at http://www.wi-fiplanet.com/tutorials/article.php/3810281/How-to-Set-Tomato-Firmware-for-Wireless-Client-Modes.htm


I have not tried any other firmwares or updates.

Friday, January 14, 2011

AWS firewall commands

#show current settings
ec2-describe-group Test 

# Authorized to a group

ec2-authorize Test -P tcp -p 53 -o Test -u XXXXXXXXX



#Authorize to internet cidr block (all)
ec2-authorize Test -P tcp -p 8080 -s 0.0.0.0/0

 # Revoke
 ec2-revoke Test -P tcp -p 8080 -s 0.0.0.0/0

Tuesday, December 14, 2010

Mail Server Install

http://workaround.org/articles/ispmail-etch/
http://www.postfixvirtual.net/postfixantivirus.html#amavisdnew


yum install openssl
yum install openssl-devel
yum groupinstall 'Development Tools'
yum install ncurses-devel
yum install ncurses

DOVECOT



mkdir /usr/local/dovecot-1.1.7
ln -s dovecot-1.1.7 dovecot/a
configure --prefix=/usr/local/dovecot --with-mysql

if the configure bombs with message stating libmysqlclient not found,
then install mysql and set the ldflags to the mysql libraries:

LDFLAGS='-L/usr/lib64/mysql -L/usr/local/mysql/lib/mysql' \
./configure --prefix=/usr/local/dovecot --with-mysql

follow guide http://workaround.org/articles/ispmail-etch/
copy over the mysql files
edit postfix/main.cf

create /etc/postfix/ssl
http://www.projektfarm.com/en/support/howto/postfix_smtp_auth_tls.html


Edit /usr/local/dovecot/etc/dovecot.conf and /usr/local/dovecot/etc/dovecot-sql.conf.

dovecot-sql.conf contents:
driver = mysql
connect = host=127.0.0.1 dbname=mailserver user=mailuser password=mailuser2008
default_pass_scheme = PLAIN-MD5
password_query = SELECT email as user, password FROM view_users WHERE email='%u';


cmusieve

./configure --with-dovecot=../dovecot-1.1.7 --prefix=/usr/local/dovecot/plugin/cmusieve



mysql


mkdir /usr/local/mysql-5.1.30
cd /usr/local

ln -s mysql-5.1.30 mysql

groupadd mysql
useradd -g mysql mysql

./configure --prefix=/usr/local/mysql --with-plugins=innobase
make
make install

mkdir /usr/local/mysql/data
cp a my.cnf to /etc/my.cnf, modify
set basedir=/usr/local/mysql
set datadir=/usr/local/mysql/data

chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql &

logging with bin/mysql
add to .bashrc export PATH=${PATH}:/usr/local/mysql/bin
cp support-files/mysql.server /etc/init.d
chkconfig --add /etc/init.d/mysql.server



POSTFIX

yum install db4-devel

--Build Src
p122: make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\" -DUSE_TLS -I/usr/include/openssl -DHAS_MYSQL -I/usr/include/mysql' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib64 -lssl -lcrypto'


--ops1:
make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\" -DUSE_TLS -I/usr/include/openssl -DHAS_MYSQL -I/usr/local/mysql/include/mysql' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/lib64 -lssl -lcrypto'

# mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
# mv /usr/bin/newaliases /usr/bin/newaliases.OFF
# mv /usr/bin/mailq /usr/bin/mailq.OFF
# chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF \
/usr/bin/mailq.OFF

postfix:x:1000:1000:Postfix User:/no/where:/sbin/nologin

postfix:x:1000:
postdrop:x:1001:

make
ldconfig /usr/local/mysql/lib/mysql
make install


AMAVIS
http://www.postfixvirtual.net/postfixantivirus.html#amavisdnew
Stored copy

yum install CPAN
yum install perl-Archive-Tar perl-Archive-Zip
yum install perl-Convert-UUlib
yum install perl-MIME-tools
yum install perl-Net-Server
yum install perl-IO-Socket-SSL
yum install perl-IO-stringy
yum install perl-MailTools
yum install perl-Unix-Syslog
yum install perl-BerkeleyDB
yum install perl-DBD-MySQL perl-DBI
yum install perl-Convert-TNEF
yum install perl-Crypt-OpenSSL-RSA
yum install perl-Crypt-OpenSSL-Random
yum install perl-Mail-DKIM
yum install spamassassin

---Start
/etc/init.d/amavis start

--Send spam
sendmail email@email.email < /usr/share/doc/spamassassin-3.2.5/sample-nonspam.txt sendmail dude@email.email 



SpamAssassin

yum install spamassissin

BashRC

Add the the /root/.bashrc file:

export PATH=${PATH}:/usr/local/mysql/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64/mysql:/usr/local/apr/lib
export JAVA_HOME=/usr/local/java
ulimit -n 10000



Insert New users

# mysql -p (xedysp#qts)
# use mailserver
# insert into virtual_users (domain_id,user,password) values (1,'virusalert',MD5('xxxxxx'));
# insert into virtual_aliases (domain_id,source,destination) values (1,'virusalert','t@example.com');







COMPILE CLAMAV
#cd /usr/local/src
#groupadd clamav
#useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav
#tar -zxf clamav-0.88.2.tar.gz
#cd clamav-0.88.2
#./configure --sysconfdir=/etc
#make
#make install
#mkdir /var/lib/clamav
#chown clamav:clamav /var/lib/clamav

Clamav is installedl Lets make a test to see how clamav is working. We are doing our test under /usr/local/clamav-88.2 directory which
contains sample virus-like files. This test will write the output into scan.txt file.
#/usr/local/bin/clamscan -r -l scan.txt /usr/local/clamav-0.88.2
Edit /etc/clamav.conf and modify variables like below; Don't forget to put "#" in front of "Example" text.
#Example
LogFile /tmp/clamd.log
DatabaseDirectory /var/lib/clamav
User amavis
UPDATING CLAMAV VIRUS DATABASE
Every second a new virus/worm is created, we must update our virus database. Freshclam program does this for us.
Before running freshclam edit /etc/freshclam.conf file and modify the line "Example" like below. (Put # in front of it)
#Example
No create necessary log file and run freshclam;
#touch /var/log/clam-update.log
#chmod 600 /var/log/clam-update.log
#chown amavis /var/log/clam-update.log
#/usr/local/bin/freshclam --datadir=/var/lib/clamav -l /var/log/clam-update.log
CLAMAV IN CRONTAB
Create a crontab entry so that clamav will update its database everyday at 08:00 regularly. Put these lines into
your crontab
06 08 * * * /usr/local/bin/freshclam --quiet -l /var/log/clam-update.log

02,03,04 etc. minutes instead of 10 multiples (00,10,20)

RUN CLAMD
#/usr/local/sbin/clamd

Wednesday, December 8, 2010

Eclipse and Restrict Access to rt.jar

Edit project properties.
Under the "Libraries Tab" select the "JRE System Libary" > to expand.


Then click to select the "Acces rules:" item and click the "Edit" button.


Add a rule, by selecting the "Add Button"


Enter the rule pattern.  For example, I am trying to use sun.misc.BASE64Encoder.  Therefore, I add the rule pattern "sun/misc/**"


The Eclipse Editor should no long complain about accessing the sun.misc.BASE64Encoder.

Monday, November 29, 2010

Fedora 13 setup

yum update
reboot
yum install httpd
yum install createrepo rpm-devel rpmdevtools expat-devel zlib-devel
reboot

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
dracut /boot/initramfs-$(uname -r).img $(uname -r)

vi /etc/grub.conf
Add to end of Kernel line:
rdblacklist=nouveau nomodeset nouveau.modeset=0

Make sure kernel mod is allowed to load.
setsebool -P allow_execstack on

yum install kmod-nvidia xorg-x11-drv-nvidia-libs.x86_64
reboot

nvidia-settings
reboot

Install Firefox
rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm
yum --enablerepo=remi list firefox
yum --enablerepo=remi install firefox


Download Adobe 64-bit flash player from adobe home page.
Untar downloaded file.
Install libflashPlayer.so in ~tmurray/.mozilla/plugins directory.

Install skype
yum -y install libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686

wget http://download.skype.com/linux/skype-2.1.0.81-fc10.i586.rpm

rpm -ivh skype-2.1.0.81-fc10.i586.rpm


Install Virtualbox

http://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel/

cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
yum install gcc kernel-devel kernel-headers

vi /root/.bashrc
KERN_DIR=/usr/src/kernels/`uname -r`
export KERN_DIR

yum install VirtualBox-3.2

yum install thunderbird
yum install thunderbird-lightning
 yum install mysql-workbench

Download/install latest jre and jdk java rpms