SSH push_key script and backup script 
backup.sh:
#!/bin/bash
HOSTNAME=`hostname --fqdn`
DATE=`date "+%d%m%Y"`
tar cvfz /var/backup/${HOSTNAME}_${DATE}.tar.gz /etc/
chown tech:tech /var/backup/${HOSTNAME}_${DATE}.tar.gz
scp -i /home/tech/.ssh/id_dsa_${HOSTNAME} /var/backup/${HOSTNAME}_${DATE}.tar.gz \
backup@backup.fsit.cz:/var/backup/

find /var/backup/ -type f -mtime +14 | xargs rm -rf



SSH push_key.sh:

#!/bin/bash
while true
do
clear
BOXNAME=`hostname --fqdn`
echo ${BOXNAME}
echo "--------------------"
echo "Generate key ... 1"
echo "Push key ... 2"
echo "Server connect ... 3"
echo "Exit ... x"
echo
echo -n ": "
read option
case $option in
1)
echo "Generatin key"
if [ -f ~/.ssh/id_dsa_${BOXNAME} ]
then
echo "WARNING: ~/.ssh/id_dsa_${BOXNAME} exists - giving up."
else
ssh-keygen -f ~/.ssh/id_dsa_${BOXNAME}
fi
sleep 8
;;
2)
echo "Pushing key"
echo -n "Target srvr: "
read remotebox
echo -n "Target user: "
read user
echo "Using id_dsa.pub: id_dsa.pub_${BOXNAME}"
ls -la ~/.ssh/id_dsa_${BOXNAME}.pub 2> /dev/null
if [ $? != 0 ]
then
echo "Problem with a key"
exit
fi
cat ~/.ssh/id_dsa_${BOXNAME}.pub | ssh ${user}@${remotebox} \
"(mkdir .ssh&>/dev/null; chmod 700 .ssh && cat - >> .ssh/authorized_keys )&&chmod 600 .ssh/authorized_keys"
echo
sleep 5
echo "Please edit the following options in /etc/ssh/sshd_config"
echo
echo "AllowUsers $user"
echo "PermitRootLogin no"
echo "PubkeyAuthentication yes"
echo "PasswordAuthentication no"
echo "ChallengeResponseAuthentication no"
echo "X11Forwarding no"
echo
echo "Press [enter]"
read
;;
3)
echo -n "Target srvr: "
read remotebox
echo -n "Target user: "
read user
ssh -l $user -i ~/.ssh/id_dsa_${BOXNAME} $remotebox
;;
x)
echo "Quit"
exit
;;
*)
echo "Wrong"
;;
esac
done



[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
Solaris: Increasing space, SVM 
DOCUMENTATION
=============
http://blogs.sun.com/lewiz/entry/growin ... olume_with
http://sysunconfig.net/unixtips/soft-partitions.html

TASK: Increase of fs



root@svg31n02:prod(global)# df -h /export/zones/embdbp02/root/opt/app/oracle
Filesystem size used avail capacity Mounted on
/dev/md/embdbp02/dsk/d0
7.9G 5.0G 2.8G 64% /export/zones/embdbp02

# metastat -s embdbp02 -c
...
embdbp02/d0 p 8.0GB embdbp02/d1000 <----------- grow this soft partition
embdbp02/d1000 m 19GB embdbp02/d1003 embdbp02/d1004
embdbp02/d1003 s 20GB d337s0 <----------- fraHDS03
embdbp02/d1004 s 20GB d46s0 <----------- kelHDS03


new disks:
5 fraHDS03 132D /dev/did/rdsk/d5 5 GB - - -
13 kelHDS03 132D /dev/did/rdsk/d13 5 GB - - -



PROCEDURE
=========

1. Grow submirrors: metattach <md_submirror> <new_disk_did/dnnns0>

# metattach -s embdbp02 d1003 /dev/did/rdsk/d5s0
embdbp02/d1003: component is attached

# metattach -s embdbp02 d1004 /dev/did/rdsk/d13s0
embdbp02/d1004: component is attached

# metastat -s embdbp02 -c
...
embdbp02/d3 p 4.0GB embdbp02/d1000
embdbp02/d2 p 4.0GB embdbp02/d1000
embdbp02/d1 p 4.0GB embdbp02/d1000
embdbp02/d0 p 8.0GB embdbp02/d1000
embdbp02/d1000 m 25GB embdbp02/d1003 embdbp02/d1004 <----- 25GB (before was 20GB)
embdbp02/d1003 s 25GB d337s0 d5s0
embdbp02/d1004 s 25GB d46s0 d13s0


2. Grow soft partition: metattach <softpart> <size>

# metattach -s embdbp02 d0 5g
embdbp02/d0: Soft Partition has been grown

# metastat -s embdbp02 -c
...
embdbp02/d0 p 13GB embdbp02/d1000 <----- 13GB (before was 8GB)
embdbp02/d1000 m 25GB embdbp02/d1003 embdbp02/d1004
embdbp02/d1003 s 25GB d337s0 d5s0
embdbp02/d1004 s 25GB d46s0 d13s0

# df -h /dev/md/embdbp02/dsk/d0
Filesystem size used avail capacity Mounted on
/dev/md/embdbp02/dsk/d0
7.9G 5.0G 2.8G 64% /export/zones/embdbp02 <---- still 8GB



3. Grow fs: growfs -M <mounted_fs> /dev/md/<metaset>/rdsk/<md_mirror>

# growfs -M /export/zones/embdbp02 /dev/md/embdbp02/rdsk/d0

# df -h /dev/md/embdbp02/dsk/d0
Filesystem size used avail capacity Mounted on
/dev/md/embdbp02/dsk/d0
13G 5.0G 7.7G 40% /export/zones/embdbp02 <----- 13GB (before was 8GB)


[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
Remote backup via ssh 
Backup of the /dev/hda1 device with gzip to remote machine via ssh and restore:

[root@vm04]# dd if=/dev/hda1 | gzip -f | ssh -C vm05.domain.com dd of=/tmp/backup.tar.gz

[root@vm05]# gunzip -c backup.tar.gz | ssh -C vm04.domain.com dd of=/some/dev


Backup with tar:

[root@vm04]# tar cvfx - . | ssh -C vm05.domain.com dd of=/tmp/tar.tgz


tips from UNIX Cheatsheet

ssh option "-C"
     -C      Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP connections).  The compres-
sion algorithm is the same used by gzip(1), and the âlevelâCompressionLevel option for protocol version
1. Compression is desirable on modem lines and other slow connections, but will only slow down things on fast networks. The
default value can be set on a host-by-host basis in the configuration files; see the Compression option.


gunzip option "-c"
 -c --stdout --to-stdout
Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a
sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.


[ add comment ] ( 3 views )   |  [ 0 trackbacks ]   |  permalink
SSH port tunnel syntax 
To get access to vm05 smtp protocol by localhost's port 2525

vm04# ssh -L 2525:localhost:25 vm05.domain.com

[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
Simple Snake in Python 
My first and probably the very last attempt to write some code in python.

#!/usr/bin/python

import os, sys, random

UP, DOWN, LEFT, RIGHT = range( 4 )

class Worm:
def __init__(self, lenght, start_x, start_y ):
self.lenght = lenght
self.x = []
self.y = []
for body in range( lenght ):
self.x.append( start_x + body )
self.y.append( start_y + 0 )

def grow( self ):
self.lenght += 1
self.x.append( 0 )
self.y.append( 0 )

def info( self ):
print "head position is %d, %d. Control keys are wasd" % ( self.x[0], self.y[0] )
print "the all body parts on inc. head", self.x
print "the all body parts ", self.y
print "my lenght is ", len( self.x )

def moveBody( self ):
delka_pole = len( self.x )
while delka_pole > 1:
self.x[ delka_pole - 1 ] = self.x[ delka_pole - 2 ]
self.y[ delka_pole - 1 ] = self.y[ delka_pole - 2 ]
delka_pole -= 1

def moveHead( self, way ):
if way == UP:
self.y[ 0 ] -= 1
elif way == DOWN:
self.y[ 0 ] += 1
elif way == LEFT:
self.x[ 0 ] -= 1
elif way == RIGHT:
self.x[ 0 ] += 1

class gameField:
def __init__(self, size):
self.size = size
self.field = [ ]
for line in range( self.size ):
self.field.append( [ "." ] )
for cell in range( self.size - 1):
self.field[line].extend('.')

def drawField(self):
sys.stdout.write(os.popen('clear').read())
for line in range( self.size ):
print self.field[ line ]

def putApple(self):
random.seed( self.size )
self.field[ random.randint( 0, self.size ) ][random.randint( 0, self.size ) ] = "$"


myWorm = Worm( 5, 5, 5 )
myGameField = gameField( 20 )
myGameField.putApple()
direction = UP

while myWorm.lenght < 6:

key = raw_input()
if key == "w": direction = UP
elif key == "s": direction = DOWN
elif key == "a": direction = LEFT
elif key == "d": direction = RIGHT

myWorm.moveBody()
myWorm.moveHead( direction )

if myGameField.field[ myWorm.y[ 0 ] ][ myWorm.x[ 0 ] ] == "$":
myWorm.grow()

for clanek_housenky in range( myWorm.lenght - 1 ):
myGameField.field[ myWorm.y[ clanek_housenky ] ][ myWorm.x[ clanek_housenky ] ] = "o"
myGameField.field[ myWorm.y[ myWorm.lenght - 1 ] ][ myWorm.x[ myWorm.lenght - 1 ] ] = "."

myGameField.drawField()
myWorm.info()

print "You successfully devoured the poisoned apple."


[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
2d array via list in Python 
>>> matrix = 10
>>> list = [ ]
>>>
>>> for line in range( matrix ):
... list.append( [ "x" ] )
... for cell in range(matrix - 1):
... list[line].extend('x')
...
>>>
>>> for line in range( matrix ):
... list[ line ]
...
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']


[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
Fomapan 100 in Ilford ID11 for 6.5mins 


[ add comment ] ( 3 views )   |  [ 0 trackbacks ]   |  permalink
Solaris: audit config 
    minfree:20
dir:/var/audit/data/files
dir:/var/audit/overflow/files
flags:lo,ex
naflags:lo,ex


/etc/system
set c2audit:audit_load = 1 # audit is enabled


http://docs.sun.com/app/docs/doc/801-66 ... dule+Guide

[ add comment ] ( 4 views )   |  [ 0 trackbacks ]   |  permalink
Solaris SVM: extending mirror on Solaris SVM by 2 disks 
extending mirror on Solaris SVM by 2 disks:

the new disks:

       2. c0t2d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>  rootdisk
/pci@1c,600000/scsi@2/sd@2,0
3. c0t3d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
/pci@1c,600000/scsi@2/sd@3,0


first, copy volume table of content from original mirrored disk:

prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t2d0s2
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t3d0s2


init partitions acting as metadevices:

metainit d30 1 1 c0t2d0s0
metainit d40 1 1 c0t3d0s0

metainit d31 1 1 c0t2d0s1
metainit d41 1 1 c0t3d0s1


metainit d35 1 1 c0t2d0s5
metainit d45 1 1 c0t3d0s5

metainit d36 1 1 c0t2d0s6
metainit d46 1 1 c0t3d0s6

metainit d37 1 1 c0t2d0s7
metainit d47 1 1 c0t3d0s7

attach devices to current mirror:

metattach d0 d30
metattach d1 d31
metattach d5 d35
metattach d6 d36
metattach d7 d37

metattach d0 d40
metattach d1 d41
metattach d5 d45
metattach d6 d46
metattach d7 d47


if metainit says "Metainit : no such file or directory", the limit defined for metainit number ( metainit d_number_ 1 1 c0t5d0s7) was higher than the limit _number_ allowed in the system configuration. The configuration file /kernel/drv/md.conf had to be changed regading the number you are willing to use ("nmd" parameter from 128 to your intended number). Changing kernel driver files requires a reboot.

[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink
SUN: service card scadm utility 
Path to scadm: /usr/platform/SUNW,Sun-Fire-V240/sbin

# ./scadm help


USAGE: scadm <command> [options]
For a list of commands, type "scadm help"

scadm - COMMANDS SUPPORTED
help, date, set, show, resetrsc, download, send_event, modem_setup,
useradd, userdel, usershow, userpassword, userperm, shownetwork,
loghistory, version

scadm - COMMAND DETAILS
scadm help => this message
scadm date [-s] | [[mmdd]HHMM | mmddHHMM[cc]yy][.SS] => print or set date
scadm set <variable> <value> => set variable to value
scadm show [variable] => show variable(s)
scadm resetrsc [-s] => reset SC (-s soft reset)
scadm download [boot] <file> => program firmware or [boot] monitor
scadm send_event [-c] "message" => send message as event (-c CRITICAL)
scadm modem_setup => connect to modem port
scadm useradd <username> => add SC user account
scadm userdel <username> => delete SC user account
scadm usershow [username] => show user details
scadm userpassword <username> => set user password
scadm userperm <username> [cuar] => set user permissions
scadm shownetwork => show network configuration
scadm loghistory => show SC event log
scadm version [-v] => show SC version (-v verbose)




[ add comment ] ( 2 views )   |  [ 0 trackbacks ]   |  permalink

<<First <Back | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | Next> Last>>