News for April 2007

Creating DNS Pointer Records using C

#include <stdio.h>
 
/* creates dns ptr records - aka reverse IP */
 
main()
{
  int i;
  FILE * readfile;
  readfile = fopen ("point.txt","a");
 
  for ( i = 150; i <= 250; i++ )
    fprintf ( readfile, "%d\t\tIN\tPTR\tdhcp-%d.domain.com.\n" ,i ,i );
  fclose ( readfile );
}
Posted: April 25th, 2007
Categories: C, programming
Tags:
Comments: No Comments.

Import DiskGroup & Enable

dg="devint_appsdg devint_datadg devint_homedg prod_appsdg prod_datadg prod_homedg" for diskgroup in ${dg} do echo echo Importing the diskgroup $diskgroup .... vxdg import $diskgroup echo Enabling the diskgroup $diskgroup vxrecover -g $diskgroup -sb echo Done importing diskgroup $diskgroup .... done 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Cloning a disk using dd

#!/bin/sh # # To dd copy the bootdisk # # bootdisk=/dev/rdsk/c0t0d0s2 altdisk=/dev/rdsk/c0t1d0s2 echo echo Starting dd of boot disk : ${bootdisk} ... `date +%T` echo echo dd if=${bootdisk} of=${altdisk} bs=65536k echo dd if=${bootdisk} of=${altdisk} bs=65536k echo Finished dd of ${bootdisk} to ${altdisk} ...`date +%T` echo 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Convert password to LDIF password

#!/usr/bin/perl open(PWD, "/etc/passwd") || die "Can't open input file!"; open(LDIF, ">/home/staff/bsung/passwd.ldif") || die "Can't open output file"; while () { ($userid, $pwd, $uid, $gid, $gecos, $homedir, $shell) = split($_, ":"); print LDIF "dn: uid=$userid, ou=People, o=domain.org\n"; print LDIF "objectclass: top\n"; print LDIF "objectclass: account\n"; print LDIF "objectclass: posixaccount\n"; print LDIF "uid: $userid\n"; print LDIF "userPassword: {crypt}$pwd\n"; print LDIF "uidNumber: $uid\n"; print LDIF "gidNumber: $gid\n"; print LDIF "gecos: $gecos\n"; print LDIF "homeDirectory: $homedir\n"; # Blank line needed between records, so two newlines on the last one... print LDIF "loginShell: $shell\n\n"; } close (LDIF); close (PWD); 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Convert /etc/passwd to LDIF

!/bin/ksh -x OUTPUT_FILE=/home/staff/bsung/doit.ldif if [ -f ${OUTPUT_FILE}]; then rm ${OUTPUT_FILE} fi touch ${OUTPUT_FILE} for user in `cat /etc/passwd` do UN="`echo ${user} | cut -d: -f1`" PW="`grep ${UN} /etc/shadow | cut -d: -f2`" UID="`echo ${user} | cut -d: -f3`" GID="`echo ${user} | cut -d: -f4`" GECOS="`echo ${user} | cut -d: -f5`" HD="`echo ${user} | cut -d: -f6`" SHELL="`echo ${user} | cut -d: -f7`" echo "dn: cn=${UN}, ou=People,dc=domain,dc=org" >> ${OUTPUT_FILE} echo "changetype: add" >> ${OUTPUT_FILE} echo "objectclass: top" >> ${OUTPUT_FILE} echo "objectclass: account" >> ${OUTPUT_FILE} echo "objectclass: posixAccount" >> ${OUTPUT_FILE} echo "uid: ${UN}" >> ${OUTPUT_FILE} echo "userpassword: ${PW}" >> ${OUTPUT_FILE} echo "uidnumber: ${UID}" >> ${OUTPUT_FILE} echo "gidnumber: ${GID}" >> ${OUTPUT_FILE} echo "gecos: ${GECOS}" >> ${OUTPUT_FILE} echo "homedirectory: ${HD}" >> ${OUTPUT_FILE} echo "loginshell: ${SHELL}" >> ${OUTPUT_FILE} echo " " >> ${OUTPUT_FILE} echo " " >> ${OUTPUT_FILE} done 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Convert VxVM UFS to VxVM VxFS

Verify the space to convert storvol1 from ufs to vxfs /opt/VRTSvxfs/sbin/vxfsconvert -e /dev/vx/rdsk/storedgedg/storvol1 /opt/VRTSvxfs/sbin/vxfsconvert -e /dev/vx/rdsk/storedgedg/storvol2 Convert storvol1 from ufs to vxfs /opt/VRTSvxfs/sbin/vxfsconvert /dev/vx/rdsk/storedgedg/storvol1 /opt/VRTSvxfs/sbin/vxfsconvert /dev/vx/rdsk/storedgedg/storvol2 Run fsck to clean up the fs fsck -F vxfs -o full -y /dev/vx/rdsk/storedgedg/storvol1 fsck -F vxfs -o full -y /dev/vx/rdsk/storedgedg/storvol2 Verify fs type fstyp /dev/vx/dsk/storedgedg/storvol1 fstyp /dev/vx/dsk/storedgedg/storvol2 Remove plex storvol1-02 from storvol1 vxplex -o rm dis storvol1-02 Remove plex storvol2-02 from storvol2 vxplex -o rm dis storvol2-02 Verify volumes vxprint -ht Remove c5t1d0s2 & c5t1d1S2 disks from storedgedg diskgroup vxdg -g storedgedg rmdisk c5t1d0s2 vxdg -g storedgedg rmdisk c5t1d1S2 Remove the c5t1d0s2 & c5t1d1S2 disks from veritas control vxdisk rm c5t1d0s2 vxdisk rm c5t1d1S2 Console to the T3 array On Mac OS X, Zterm On Solaris, tip hardwire or tip -9600 /dev/ttyb Umount volumes on T3 array vol umount v0 vol umount v1 Remove volumes on T3 array vol remove v0 vol remove v1 Create RAID 7+1 (RAID 5) disk with a hot spare on T3 master vol add v0 data u1d1-8 raid 5 standby u1d9 Create RAID 7+1 (RAID 5) disk with a hot spare on T3 slave vol add v1 data u2d1-8 raid 5 standby u2d9 Reboot system with the reconfigure flag reboot -- -r Verify LUNs can now be reconized format Bring new disks under veritas control to a existing diskgroup called storedgedg, nohotuse vxdiskadd c5t1 Mirror the volume storvol1 to c5t1d0 (verify luns) vxassist -g storedgedg mirror storvol1 c5t1d0 & Mirror the volume storvol2 to c5t1d1 (verify luns) vxassist -g storedgedg mirror storvol2 c5t1d1 & Monitor mirroring progress vxtask list 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Shell script to add users

#/bin/ksh # ID=200 for USER in `cat sun` do echo "Creating sun account for $USER ..." useradd -c Staff -d /home/sun/$USER -g sun -s /bin/ksh -u $ID $USER echo "Assigning default passwords of sun..." passwd $USER sun echo "Creating directory for $USER..." mkdir /home/sun mkdir /home/sun/$USER echo "Setting permissions..." chown -fR $USER:sun /home/sun/$USER chmod 700 /home/sun/$USER (( ID = ID + 1 )) done 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Modify Solaris HostID

#!/bin/sh adb -w -k /dev/ksyms /dev/mem << END hw_serial/W 0x31393230 hw_serial+4/W 0x33383839 hw_serial+8/W 0x36390000 END 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

Shell script to add hp printers using HP printer utility

#!/bin/ksh echo "adding queues to local spooler" /opt/hpnpl/hppi -addq -q sa_1 -h sa_1 /opt/hpnpl/hppi -addq -q lab1_1 -h lab1_1 /opt/hpnpl/hppi -addq -q lab2_1 -h lab2_1 /opt/hpnpl/hppi -addq -q admin1_1 -h admin1_1 /opt/hpnpl/hppi -addq -q admin2_1 -h admin2_1 echo "finished." echo "executing lpstat -s" lpstat -s echo "adding default of admin1_1..." echo " " >> /etc/printers.conf echo "_default:\\" >> /etc/printers.conf echo " :use=admin1_1:" >> /etc/printers.conf echo "completed." 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.

IOS Access Control List

 ! ! remove current access-list 101 no access-list 101 ! ! Permit established connections access-list 101 permit tcp any any established ! ! Permit ssh access-list 101 permit tcp any host 10.0.0.20 eq 22 access-list 101 permit tcp any host 10.0.0.21 eq 22 access-list 101 permit tcp any host 10.0.0.31 eq 22 access-list 101 permit tcp any host 10.0.0.32 eq 22 access-list 101 permit tcp any host 10.0.0.41 eq 22 access-list 101 permit tcp any host 10.0.0.42 eq 22 access-list 101 permit tcp any host 10.0.0.51 eq 22 access-list 101 permit tcp any host 10.0.0.52 eq 22 access-list 101 permit tcp any host 10.0.0.61 eq 22 ! ! Permit email services plus webmail 80 access-list 101 permit tcp any host 10.0.0.20 eq 25 access-list 101 permit tcp any host 10.0.0.20 eq 110 access-list 101 permit tcp any host 10.0.0.20 eq 143 access-list 101 permit tcp any host 10.0.0.20 eq 80 ! ! Permit web services access-list 101 permit tcp any host 10.0.0.41 eq 80 access-list 101 permit tcp any host 10.0.0.51 eq 80 access-list 101 permit tcp any host 10.0.0.41 eq 443 access-list 101 permit tcp any host 10.0.0.51 eq 443 ! ! Permit DNS access-list 101 permit tcp any host 10.0.0.41 eq 53 access-list 101 permit tcp any host 10.0.0.51 eq 53 access-list 101 permit udp any any eq 53 ! ! Permit ident to not slow stuff down access-list 101 permit tcp any any eq 113 ! ! Permit high tcp and udp for streaming media access-list 101 permit tcp any any gt 1023 access-list 101 permit udp any any gt 1023 ! ! Deny everything else and send it the syslog machine access-list 101 deny ip any any log 
Posted: April 25th, 2007
Categories: Uncategorized
Tags:
Comments: No Comments.