Oct 6 2013

433MHz USB sender

Usb sender 433MHz incl antenna

20131006-012343.jpg

20131006-012441.jpg


May 11 2013

gpg error on apt-get update ?

apt-get update

gpg –keyserver subkeys.pgp.net –recv YOUR_KEY
gpg –export –armor YOUR_KEY | apt-key add –


Apr 25 2013

apt list Upgradeable packages

apt-get --just-print upgrade


Apr 7 2013

bash: all terminal colors:


for x in 0 1 4 5 7 8 ;do for i in `seq 30 37`; do for a in `seq 40 47`;do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m";done;echo ;done;done;echo "";

looks like this:
bash_colors


Mar 31 2013

tcpdump

tcpdump -n host 192.168.0.142 and not port 22 and not arp and not igmp and host 127.0.0.1

tcpdump commands chain. use  host, port, proto  or “not arp” etc. and “and” as chain

 

-w to write a file

-s 65535 for max possible size.

example to read in realtime packets:

tcpdump -XX not port 22 -s 65535


Jan 6 2013

backup via bash


#!/bin/bash
SERVER="192.168.0.142"
#nice -n 20 dd if=/dev/mmcblk0p1 of=/media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y` bs=1M count=16K
cd /

echo -e "checking if server is mounted... \033[60G [ \033[1;32m`date` \033[0;37m ]"
mount_chk=`cat /proc/mounts | grep cifs| grep $SERVER|cut -f3 -d"/"`

if [ $mount_chk!=$SERVER ]; then
echo "no mount, Please mount manually "
dte="Y";
read -p "shall we mount it? Y/N [Y]" te;
te=${te:-$dte};
if [ $te = "Y" ]; then
echo -e "mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime \033[60G [ \033[1;32mdone \033[0;37m ]"
mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime || (echo "trying to mount... wait 7 sec"; ssh root@192.168.0.142 "/etc/init.d/samba start" );
sleep 6
mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime || (echo "hat net geklappt, exiting...";exit );

else
echo "exiting..."
exit
fi
fi

nice -n 20 echo -e "starting backup... \033[60G [ \033[1;32m`date` \033[0;37m ]"
if [ -f /tmp/file_list ]; then
echo "datei /tmp/file_list existiert... löschen oder benutzen ? ich lösch ma"
dte="Y";
read -p "shall I delete that file? Y/N [Y]" te;
te=${te:-$dte};
if [ $te = "Y" ]; then
rm /tmp/file_list
else
echo "ok, using the existing file then..."
fi
fi

find /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /root /sbin /usr /var > /tmp/file_list

echo -e "file list created, starting cpio... \033[60G [ \033[1;32m`date` \033[0;37m ]"
nice -n 20 cat /tmp/file_list | cpio -o -H newc > /media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y`.cpio.img
#nice -n 20 cat /tmp/file_list | cpio -o -H newc > /media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y`.cpio.gz
#nice -n 20 dd if=/dev/mmcblk0p1 of=/media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y` bs=1M count=16K

echo -e "finish backup... \033[60G [ \033[1;32m`date` \033[0;37m ]"


Aug 5 2012

linux server adm – decrease / monitor hd access

first install
apt-get install inotify-tools
maybe also screen to have inotify running with screen in the background

then monitor what is going on. directories after a @ are ignored.

inotifywait -m -r / @/dev @/media @/mnt @/opt @/proc @/root @/sbin @/sys @/tmp @/usr @/bin @/etc @/lib @/var/run/samba/ @/var/cache/samba/

case “$1” in
start)
log_daemon_msg “Starting Samba daemons”
mount -t tmpfs tmpfs /var/run/samba
mount -t tmpfs tmpfs /var/cache/samba

# Make sure we have our PIDDIR, even if it’s on a tmpfs
install -o root -g root -m 755 -d $PIDDIR

at stop)

..
..
fi
fi

umount /var/run/samba
umount /var/cache/samba


log_end_msg 0

;;
reload)

———-
for me it did not do all the trick. samba was still trying to access:
/var/lib/samba so:
mv /var/lib/samba/ /var/lib/samba_
cp -ar /var/lib/samba_ /tmp/samba_lib
ln -sf /tmp/samba_lib /var/lib/samba

(this is what I am currently testing… but should work.. so unconfirmed yet 🙂


Jun 30 2012

bash: if else with floats in bash , for i s, arrays

arr=(“as” “df” 5 kkk “uz z t”);
for ((i=0; i<10; i++));
do echo ${arr[$i]};
done

OUTPUT:

as
df
5
kkk
uz z t

calc if else with floats
a=1.6;b=1.7;if [[ $a < $b ]];then echo $a smaller than $b;fi numbers: i=0 $((i+2)) >> 2


Jun 9 2012

time lapse with ffmpeg

create single images every 25 pic:
ffmpeg -i $1 -r 1 -f image2 out/%05d.png

assemble back all together:
ffmpeg -i out/%05d.png -sameq $2

and as bash script

#!/bin/bash
#create a dir named out by hand, now to lazy
rm out/*
#every 250 /300 one image (10 sec approx)
ffmpeg -i "$1" -r 0.1 -f image2 out/%05d.png
#compile all together with 30fps
ffmpeg -i out/%05d.png -qscale 0 -r 30 "$1.mov"

#this are some useful commands; concate mov's together
echo "mencoder.exe -oac copy -ovc copy -idx -o outall.mov o2.mov o3.mov"

# ffmpeg -i wetter_dortmund.mov -vcodec libx264 -crf 23 -preset medium -profile:v high -level 41 -pix_fmt yuv420p -maxrate 3020k -b 3020k -bufsize 1835k -y fenter_oktay_dortmund.mkv

echo "ls *.mov | while read line;do echo ./timelapse.sh $line;done > st.sh"


Jun 9 2012

rename 00123.png to 00001.png

a=0;ls | while read line; do a=$((a+1)); mv $line `printf “%05d.png\n” $a`;done