Thursday, August 19, 2010

Show passwords on Browser page

This handy piece of javascript was written by:
http://www.raymond.cc/blog/archives/2007/07/13/easily-show-the-contents-of-password-fields/


Copy and paste this into your Browser's Address bar (only works on a page where password is saved and hidden)




Definitely works on IE and Firefox.


Cheers (with props to the original author),
-n

Setting up an NFS Share on CentOS 5.x

This outlines on how to setup a NFS Client/Server architecture.Used by myself for Moodle to access Datafiles, as I employ multiple webservers.

0. Package Installation

Login as root and install the following packages on NFS Client(s) and NFS Server
yum install nfs-utils nfs4-acl-tools portmap
chkconfig nfs on
chkconfig portmap on
service nfs start
service portmap start

1. Prep NFS Server
export share
nano /etc/exports
add lines like:
/mount/folder 192.168.0.0/255.255.0.0(rw) 10.0.0.0/255.0.0.0(rw)

allow clients to be able to connect.
nano /etc/hosts.allow
add lines like:
portmap: 192.168.0.0/255.255.0.0
add clients to hosts file
nano /etc/hosts
make sure all relevant hosts are listed in the format:
192.168.x.x server1.domain.com.local server1

restart the nfs and portmap service
service nfs restart
service portmap restart
2. Prep the NFS Client(s)
Repeat this step on each NFS client.
Edit the fstab
nano /etc/fstab

adding line:
server.ip.address:/mount/folder /mnt nfs rw,hard,intr 0 0
Mount the share
mount nfshostname:/mount/folder /mnt

restart services
service netfs restart
chkconfig netfs on

3. Test NFS

Create a file from one client, and it should be automatically available on the other clients.
From Client1
echo "This is an NFS Test" > /mnt/file.txt

Cheers,
-n

Tuesday, August 3, 2010

Sending mail from command line or shell script

How to send mail from the Linux Command line (or shell script) using the mail command.

echo "This is the body of the email" | mail -s "Email Subject" recipient@domain.com -- -f senderaddress@domain.com


The -- -f section is used to plug in a sender address, otherwise the mail will be sent from your root or user account from the actual physical server name - e.g root@server1.domain.com


This comes in handy for notification of script execution, for example, jobs in the crontab. Placing this code immediately after the last command in a shell script will ensure relevant person(s) are notified when the script is called.

-n