My asterisk version is 1.6.2.6
My freepbx version is 2.7.0.1
To get music-on-hold from a live source, i made a script (/scripts/streamx.ksh):
#!/bin/ksh
/usr/bin/ogg123 -q -b 128 -p 32 -d wav -f – http://kraftek.com:8000/stream.ogg| sox -t wav – -r 8000 -c 1 -t raw
- vol 0.10
27/433
and configured /etc/asterisk/musiconhold_additional.ksh with:
[default]
mode=custom
application=/scripts/streamx.ksh
And that is it!, just dial a conference room and you’ll get live music on hold while waiting for your friends to
join ![]()
May
1
Apr
30
you will love it, it rephrases whatever you tell it ti
http://kraftek.com/cgi-bin/rephrase/index.sh
#!/bin/bash
echo “Content-type: text/html”
echo “”
echo “<html><body bgcolor=white><font size=-1>”
QUERY=`echo “$QUERY_STRING” | sed -n ‘s/^.*query=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g;s/ //g”`
QUERY=`echo $QUERY|sed ‘s/+/ /g’`
wget=/usr/bin/wget
thesaurize(){
l=`echo $1|wc -c`
if [ $l -le 5 ];then
echo $1
else
S=`$wget -nv -O – http://thesaurus.reference.com/search?q=”$1″ 2>&1|sed ‘s/>/>\n/g;/^<script/,/<\/script>/d;/^<style/,/<\/style>/d;/^<form/,/<\/form>/d;s/<[^>]*>//g;s/,/,\n/g’|sed -e ’1,/Main Entry/d’ -e ‘/Antonyms/,$d;s/^[ \t]*//;1,/Synonyms/d’ -e ‘/Antonyms/,$d’| sed ‘s/,//g’|egrep -v ‘^Part of Speech|^Main Entry|^Synonyms|^Antonyms|^Definition|\*’|grep .|head -10|shuf -n 1`
SL=`echo $S|wc -c`
if [ $SL -gt 1 ];then
echo $S
else
echo $1
fi
fi
}
cat <<EOF
<style type=”text/css”>
form {
margin: 0px;
}
</style>
<form action=index.sh method=get>
Regurgitate: <input type=text size=80 name=query>
<input type=submit value=search>
</form><br><br>
EOF
echo “<b>Original:</b><br> $QUERY<br><br>”
echo “<b>Re-interpreted:</b><br>”
for i in 1 2 3 4 5;do
for word in $QUERY;do
echo -n “`thesaurize $word` “
done
echo “<br>”
done
echo “</body></html>”
Apr
3
#!/bin/ksh
( N=`format < /dev/null | egrep -i 'emc|hit' | wc -l| sed 's/ //g'`
/usr/ucb/echo -n "metainit d1 $N "
format < /dev/null | egrep -i 'emc|hit' | awk '{ print $2 }' | while read d;do
/usr/ucb/echo -n "1 ${d}s2 "
done
echo "" ) > /tmp/makevol.ksh
chmod 755 /tmp/makevol.ksh
Mar
30
Mounting example
$ sshfs -p 32 kraftek.com:/u01 /u01
To unmount it
$ fusermount -u /u01
Nov
3
# cat /proc/sys/fs/aio-nr;cat /proc/sys/fs/aio-max-nr
110456
1048576
Oct
31
To get all the wwns attached to an hba you can use this
# cfgadm -al -o show_FCP_dev | egrep ‘disk|tape’
Oct
29
i don’t like to do a # cat /etc/passwd and manually create the users and chown their dirs… So, this is a one liner:
# grep -i home /etc/passwd | awk -F: ‘{print “mkdir ” $6 ” ; chown ” $1 ” ” $6 }’ > somefile; chmod 755 somefile;./somefile 183/433
Oct
28
Just do this:
ls /sys/class/scsi_host/ | while read h;do echo “- – -” > /sys/class/scsi_host/$h/scan;done
Jan
28
Use the queryformat modifier to print more info about your rpm
# rpm -qa –queryformat %-{name}-%{version}-%{release}-%{arch}”n”
You can grep for something there, because it is a full listing
Thanks to Fergus O’hea
Jan
28
[root@mylinux]# swapon -s
Filename Type Size Used Priority
/dev/systemvg/swapvol (deleted) partition 4095992 0 -3
According to http://kbase. redhat.com/faq/FAQ_79_4331.shtm we need to
add “swapoff -a && swapon -a” to the end of /etc/rc.d/rc. sysinit
We can also run
#swapoff -a && swapon -a
To fix it live, and we’ll see:
[root@mylinux]# swapon -s
Filename Type Size Used Priority
/dev/systemvg/swapvol partition 4095992 0 -3
114/433
Jan
28
If your slice 2 is empty and you got partitions 0-9 in your disk when checkign it in “format”, you have an EFI label.
If you want to change it to a SMI label, you need to use “format -e” and when prompted for the label type,
choose SMI
partition> label
[0] SMI Label
[1] EFI Label
Specify Label type[1]: 0
Warning: This disk has an EFI label. Changing to SMI label will erase all
current partitions.
Continue? y
Auto configuration via format.dat[no]?
Auto configuration via generic SCSI-2[no]?
partition>
68/433
Jan
28
I already have a script like this in “miniexplorer”, but it generates html and that may be overkill, so this is a quickie one to
query all network card ports in your solaris server about NIC speed.
#!/bin/ksh
ifconfig -a | grep flags | grep -v ‘lo’ |awk -F: ‘{ print $1 }’ |uniq|while read IF;do
D=`echo $IF| sed s/[0-9,:]*$//`
IN=`echo $IF| sed ‘s/^[a-z]*//’`
echo “$D $IN ————————————————-”
ndd -set /dev/$D instance $IN
(ndd -get /dev/$D ?|awk ‘$1!~/^?/{print$1}’|while read p;do
/usr/ucb/echo -n $p:;ndd -get /dev/$D $p;
done
kstat ${D}:${IN}) | egrep ‘adv|link|speed’ |sed ‘s/ //g’
done
121/433
Jan
28
I got a TV card, it appears like this in lspci:
01:08.0 Multimedia controller: Philips Semiconductors SAA7131/SAA7133/SAA7135 Video Broadcast
Decoder (rev d1)
In order to stream 3 simultaneous streams, very low, low and high quality, you can do this:
#!/bin/ksh
#
/sbin/modprobe saa7134-alsa
sleep 2
DEV=/dev/tvcard
ps -ef | grep -i vlc | grep -v grep |grep -i $DEV | awk ‘{ print $2 }’| while read P;do
kill -9 $P
done
VBR=96
ABR=24
W=320
H=240
### –deinterlace-mode {discard,blend,mean,bob,linear} : deinterlacing mode (default: discard)
# width=320,height=240 qpmax=40 x264{crf=5,profile=extended,level=1.0}
# :standard{access=http{user=video,pwd=cable},mux=asf,dst=0.0.0.0:8088}
#
venc=x264{level=2,nr=1000,me=tesa,b-pyramid,bitrate=64,ref=4,b-adapt=2,bframes=2,partitions=all, keyint=2500}
VLC=”/usr/local/bin/cvlc –logo-file /disk2/logox.png v4l2://$DEV :input=2 :standard=8 :input-slave=alsa://hw:1
,0 –alsa-samplerate=32000 –deinterlace-mode linear –sout ”
35/433
VERYLOW=”transcode{vcodec=h264,acodec=mp4a,channels=1,width=160, height=120,vb=24,ab=16,venc=x264{bframes=0,leve
l=5,nr=1000,b-pyramid,b-adapt=2, hurry-up},audio-sync,sfilter=logo}:standard{access=http,dst=0.0.0.0:8011/stream
.flv}”
LOW=”transcode{vcodec=h264,acodec=mp4a,channels=1,width=${W},height=${H},vb=${VBR},ab=${ABR},venc=x264{bframes=
0,level=5,nr=1000,b-pyramid,b-adapt=2},audio-sync,sfilter=logo}: standard{access=http,dst=0.0.0.0:8012/stream.fl
v}”
36/433
HIGH=”transcode{vcodec=h264,acodec=mp4a,channels=2,ab=128,venc=x 264{bframes=0,level=5,nr=1000,b-pyramid,b-adapt
=2,hurry-up},deinterlace,audio-sync,sfilter=logo}:standard{access=http,dst=0.0.0.0:8013/stream.flv}”
/usr/local/bin/v4l2-ctl -d $DEV –set-tuner=stereo
/usr/local/bin/v4l2-ctl -d $DEV –set-standard=0
/usr/local/bin/ivtv-tune -d $DEV -t us-cable -c3
#— audio codecs can be mpga or mp3 or m4a
#— mux can be ogg,ts,mp4,asf,ps,mpeg1,asfh, mpjpeg
#— low quality
#$VLC “#$VERYLOW”
#— low quality
#$VLC “#$LOW”
#— LAN quality
#$VLC “#$HIGH”
#—- single command, high quality AND low quality using h264_vdpau and x264 as encoder
$VLC “#duplicate{dst=”$VERYLOW”,dst=”$LOW”,dst=”$HIGH”}”
#$VLC “#duplicate{dst=”$VERYLOW”,dst=”$HIGH”}”
#$VLC “#duplicate{dst=”$LOW”,dst=”$HIGH”}”
#$VLC “#duplicate{dst=”$VERYLOW”,dst=”$LOW”}”
“#duplicate” is used in order to have 2 streams working simultaneously from the same input device, for each
output srteam we use a “dst=”
37/433
Jan
28
Say you want a random Gnome wallpaper from google each 60 seconds, but if your machine is not connected, just take
the backdrop from a local directory ~/Desktop/backdrops. you can put up a couple of scripts to do this, the main one
would be /scripts/changewall.ksh
#!/bin/bash
mkdir -p /tmp/wallpapers
E=`ps -ef | grep -i changewall | grep -i $USER | grep -iv grep | wc -l`
if [ $E -gt 2 ];then
echo “wallpaper changer already running for $USER”
exit 1
fi
i=120
while true;do
i=`cat /scripts/time.txt`
rm -fR /tmp/wallpapers/*
RANGE=10
number=$RANDOM
let “number %= $RANGE”
number=$(($number))
ping -w 10 -c 2 www.google.com > /dev/null 2>&1
R=$?
if [ $R -eq 0 ] && [ $number -lt 9 ];then
/scripts/wallpaper.ksh > /dev/null 2>&1
F=`ls /tmp/wallpapers`
N=`echo $F | wc -c`
if [ $N -gt 1 ];then
gconftool-2 -t string -s /desktop/gnome/background/picture_filename “/tmp/wallpapers/$F”
# cp “/tmp/wallpapers/$F” $HOME/Desktop/backdrops/
else
cd $HOME/Desktop/backdrops
ls -1 *.jpg | head -n`expr $RANDOM % \`ls -1 *.jpg | wc -l\“ | tail -n1 | echo `pwd`/`xargs` | gconftool-2 -t string -s /desktop/gnome/background/picture_filename “`xargs`”
fi
else
cd $HOME/Desktop/backdrops
ls -1 *.jpg | head -n`expr $RANDOM % \`ls -1 *.jpg | wc -l\“ | tail -n1 | echo `pwd`/`xargs` | gconftool-2 -t string -s /desktop/gnome/background/picture_filename “`xargs`”
fi
sleep $i
done
Then you would need the support script, to get images from google according to a random word that comes
from /scripts/wallpaper-subjects.txt program: /scripts/wallpaper.ksh
#!/bin/ksh
cat /scripts/wallpaper-subjects.txt | head -n`expr $RANDOM % \`cat /scripts/wallpaper-subjects.txt | wc -l\“ | tail -n1 > /tmp/subject
QUERY=`cat /tmp/subject | sed ‘s/ /%20/g’`
RANGE=10
number=$RANDOM
let “number %= $RANGE”
number=$(($number + 1))
IMG=`curl -m 10 -A “Mozilla/3.0 (compatible; AvantGo 3.2)” “http://images.google.com/images?as_q=${QUERY}&as_filetype=jpg&biw=1680&bih=1024&safe=active&as_st=y&tbs=isch:1,itp:photo,islt:2mp,isz:l,ift:jpg” 2>/dev/null |sed -e ‘s/>/>\n/g’ | awk ‘{s=substr($0,index($0,”http”),index($0,”jpg”));print substr(s,1,index(s,”.jpg”)+3)}’ | grep jpg |egrep -v ‘starkeith|gstatic|scaredmonkeys|tripod|flickr’|sed ‘s/2520/20/g’ | head -$number | tail -1`
mkdir -p /tmp/wallpapers
cd /tmp/wallpapers
wget –timeout=10 $IMG
you can add /scripts/changewall.ksh to your autostart stuff in gnome, going to system –> preferences –>
startup applications
ENJOY!
Jan
28
If you don’t like graphics…
go to /etc/sysconfig/rhn
and edit “up2date” and “rhn_register”
… and a happy new year
212/433
Jan
28
if you need to make a copy of your boot disk, and you don’t have
disksuite, and you only have one slice as “/”, and this is solaris 10,
you can do:
#prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s – /dev/rdsk/c0t1d0s0
#newfs /dev/dsk/c0t1d0s 0
#mount /dev/dsk/c0t1d0s0 /a
#cd /
#find . -mount | cpio -pmdv /a
#installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
#vi /a/etc/vfstab
(change references from c0t0d0s0 to c1)
#mkdir /a/tmp
#mkdir /a/dev
#mkdir /a/proc
#touch /a/etc/mnttab
#mkdir /a/etc/svc/volatile
#mkdir /a/system/object
#mkdir /a/system/contract
#umount /a
#init 0
#boot otherdisk -r
And the system will boot fine from the other disk.
Remember it should be better to do this in single user mode, and with apps down.
200/433
Jan
28
I was been attacked by comment spam in this blog… this had me a bit down for a while.
Soon i found out there is an easy way to make comment spam difficult on serendipity(s9y) blog.
Go to “Configure Plugins” —> “Event Plugins” —-> “Spam Protector”
And you’ll solve all your problems ![]()
- rdircio
253/433
Jan
28
dmidecode | more
Thanks to Justin Lim
Disable NIS client in solaris
mv /a/usr/lib/netsvc/yp/ypbind /a/usr/lib/netsvc/yp/ypbind.orig
mv /a/usr/lib/netsvc/yp/ypserv /a/usr/lib/netsvc/yp/ypserv.orig
init 6
97/433
Jan
28
This is basic ssh port forwarding, but i always forget…
so, you have hosta, hostb and yourpc.
you’re not in the same network as hostb, so you need to connect this way
yourpc –> hosta —> hostb
and you have a vnc session at hostb:1 (5901)
you want to connect to hosta:11 (5911) and get your vnc screen at hostb:1 (5901)
All you have to do is, from hosta
rdircio@hosta $ ssh -g -C hostb -L 5911:localhost:5901
then point the vnc client on yourpc to hosta:11.
196/433
Jan
28
First, check the status of your pool
bash-3.00# zpool status -v
pool: amx002zpool1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
amx002zpool1 ONLINE 0 0 0
c6t60060480000190101353533030393543d0 ONLINE 0 0 0
c6t60060480000190101353533030393536d0 ONLINE 0 0 0
c6t60060480000190101353533030393530d0 ONLINE 0 0 0
c6t60060480000190101353533030393441d0 ONLINE 0 0 0
c6t60060480000190101353533030393434d0 ONLINE 0 0 0
c6t60060480000190101353533030433435d0 ONLINE 0 0 0
errors: No known data errors
Then add a couple of disks to it:
bash-3.00# zpool add amx002zpool1 c6t60060480000190101353533031343236d0
bash-3.00# zpool add amx002zpool1 c6t60060480000190101353533031343243d0
Now check if they’re added:
bash-3.00# zpool status -v
pool: amx002zpool1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
amx002zpool1 ONLINE 0 0 0
c6t60060480000190101353533030393543d0 ONLINE 0 0 0
c6t60060480000190101353533030393536d0 ONLINE 0 0 0
c6t60060480000190101353533030393530d0 ONLINE 0 0 0
c6t60060480000190101353533030393441d0 ONLINE 0 0 0
c6t60060480000190101353533030393434d0 ONLINE 0 0 0
c6t60060480000190101353533030433435d0 ONLINE 0 0 0
c6t60060480000190101353533031343236d0 ONLINE 0 0 0
c6t60060480000190101353533031343243d0 ONLINE 0 0 0
errors: No known data errors
List free space on the pool:
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
99/433
gskhr009zpool1 69.5G 5.87G 63.6G 8% ONLINE -
gskhr009zpool2 139G 73.6G 65.4G 52% ONLINE -
gskhr009zpool3 1.70T 1.24T 468G 73% ONLINE -
List all the filesystems in the pool:
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
amx002zpool1 345G 157G 24.5K /amx002zpool1
amx002zpool1/amx21 64.6G 6.37G 64.6G /amx21
amx002zpool1/amx22 32.9G 4.12G 32.9G /amx22
amx002zpool1/amx23 26.1G 4.95G 26.1G /amx23
amx002zpool1/amx24 58.9G 6.15G 58.9G /amx24
amx002zpool1/amx25 49.6G 7.39G 49.6G /amx25
amx002zpool1/oracle 6.50G 1.50G 6.50G /oracle
amx002zpool1/oracle-export 21.6G 23.4G 21.6G /oracle/export
amx002zpool1/oracle2 24.5K 8.00G 24.5K /opt/oracle
amx002zpool1/psreports 24.5K 3.00G 24.5K /opt/reports
amx002zpool1/vendor 690K 20.0G 690K /opt/vendor
Get a quota and reservation for the filesystem to grow:
bash-3.00# zfs get quota amx002zpool1/amx21
NAME PROPERTY VALUE SOURCE
amx002zpool1/amx21 quota 71G local
bash-3.00# zfs get reservation amx002zpool1/amx21
NAME PROPERTY VALUE SOURCE
amx002zpool1/amx21 reservation 71G local
Grow the filesystem:
bash-3.00# zfs set quota=100G amx002zpool1/amx21
bash-3.00# zfs set reservation=100G amx002zpool1/amx21
That’s it, have fun
100/433
Jan
28
if you get that error while trying to boot from a USB disk, and you’re 100% sure it is the right disk and partition, then
pass:
rootdelay=10
to your grub parameters. That will make the kernel wait a bit until your usb drive appears.
76/433
Jan
28
You want to know for the latest N days who was able/unable to su, in solaris. Sulog is in /var/adm/sulog, and we don’t
have the niceties of GNU date, so we use perl inside a shell… “suentries.ksh”
#!/bin/ksh
#— n has how many days ago we want
n=$1
today=`/usr/bin/perl -e ‘printf “%dn”, time;’`
x=$n
while [ $x -gt -1 ];do
ago=$(($today-86400*${x}))
export ago
DAY=`perl -e ‘($a,$b,$c,$d,$e,$f,$g,$h,$i) =localtime($ENV{‘ago’});printf”%02d/%02dn”,$e+1,$d’`
echo “—- $DAY”
cat /var/adm/sulog | grep $DAY
x=$(($x-1))
done
Jan
28
this is first grade, but in case you forget how to create a tar and gzip on the fly if you do not have gnu tar…
to unpack on the fly:
# gunzip < filename.tar.gz | tar xvf -
to pack on the fly:
# tar cvf – files_to_tar | gzip -c > filename.tar.gz
249/433
Jan
28
If sendmail starts only using local.cf and something like this appears:
# ps -ef | grep -i sendmail
root 22616 1 0 11:13:11 x y z 0:00 /usr/lib/sendmail -bd -q15m -C /etc/mail/local.cf
smmsp 22614 1 0 11:13:10 x y z 0:00 /usr/lib/sendmail -A
And you want it not to run only local, you can do:
# svccfg -s svc:/network/smtp:sendmail setprop config/local_only = false
# svcadm refresh svc:/network/smtp:sendmail
# /usr/bin/svcprop -p config/local_only svc:/network/smtp:sendmail
false
# svcadm disable sendmail
# svcadm enable sendmail
And now it runs without local.cf
# ps -ef | grep -i sendmail
root 24465 1 0 11:18:13 x y z 0:00 /usr/lib/sendmail -bd -q15m
smmsp 24463 1 0 11:18:13 x y z 0:00 /usr/lib/sendmail -Ac -q15m
18/433