mercredi 2 mars 2016

Motion (Raspbian Jessie) + envoi de méls

Pour cette installation j'ai utilisé une caméra Webcam USB logitech pro 3000 qui est reconnue dès l'insertion et qui fonctionne grace au module "pwc" (/dev/video0 par défaut). Il est possible d'utiliser la caméra spécialement développée pour le Raspberry Pi, mais ce n'est pas traité dans ce mémo.

Installation du paquet motion et des paquets pour envoi de mél :
# apt-get install motion ssmtp heirloom-mailx

Configuration de ssmtp (avec gmail) :
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
FromLineOverride=YES
AuthUser=_vous_@gmail.com
AuthPass=xxxxxxxxxxxx

Note : La variable "AuthPass" est à configurer sur votre gmail (trousseau de mot de passe d'application)

Configuration de /etc/motion/motion.conf (avec commentaire) :

[Start file]
daemon on
process_id_file /var/run/motion/motion.pid
setup_mode off
; logfile /tmp/motion.log #*** A ACTIVER SI BESOIN
log_level 6
log_type all
videodevice /dev/video0
v4l2_palette 17
input -1
norm 0
frequency 0
rotate 0
width 320 
height 240
framerate 2
minimum_frame_time 0
netcam_keepalive off
netcam_tolerant_check off
auto_brightness off
brightness 0
contrast 0
saturation 0
hue 0
roundrobin_frames 1
roundrobin_skip 1
switchfilter off
threshold 2000 #*** IMPORTANT
threshold_tune off
noise_level 32
noise_tune on
despeckle_filter EedDl
smart_mask_speed 0
lightswitch 0
minimum_motion_frames 1
pre_capture 0
post_capture 0
event_gap 60 #***
max_movie_time 0
emulate_motion off
output_pictures on #***
quality 75
picture_type jpeg
ffmpeg_output_movies off #*** default=on
ffmpeg_output_debug_movies off
ffmpeg_timelapse 0
ffmpeg_timelapse_mode daily
ffmpeg_bps 500000
ffmpeg_variable_bitrate 0
ffmpeg_video_codec mpeg4
ffmpeg_deinterlace off
sdl_threadnr 0
use_extpipe off
snapshot_interval 0
locate_motion_mode off
locate_motion_style box
text_right %Y-%m-%d\n%T-%q
; text_left CAMERA %t
text_changes off
text_event %Y%m%d%H%M%S
text_double off
target_dir /var/lib/motion #*** LES IMG SONT ENREGISTRES ICI
snapshot_filename %v-%Y%m%d%H%M%S-snapshot
picture_filename %v-%Y%m%d%H%M%S-%q
movie_filename %v-%Y%m%d%H%M%S
timelapse_filename %Y%m%d-timelapse
ipv6_enabled off
stream_port 8081
stream_quality 50
stream_motion off #*** default=on
stream_maxrate 1
stream_localhost off
stream_limit 0
stream_auth_method 0
; stream_authentication username:password
webcontrol_port 0
webcontrol_localhost on
webcontrol_html_output on
; webcontrol_authentication username:password
track_type 0
track_auto off
track_iomojo_id 0
track_step_angle_x 10
track_step_angle_y 10
track_move_wait 10
track_speed 255
track_stepsize 40
quiet on
; on_event_end value echo 'Image capturée en pièce jointe' | mailx -s 'Image capturée en pièce jointe suite à la précédente détection' -a %f _vous_@gmail.com
on_picture_save value echo 'Image capturée en pièce jointe' | mailx -s 'Image capturée en pièce jointe suite à la précédente détection' -a %f _vous_@gmail.com
[End file]

Note : Les lignes marquées de "#***" sont à définir en fonction de la caméra utilisée

Ne pas oublier de modifier sur une Debian /etc/default/motion, pour que le démon démarre correctement.

Pour finir il suffit de redémarrer le service motion :
# service motion restart

mardi 21 avril 2015

NAS sous Debian

# Install Raspi/NAS
# Source : http://benoit.vianin.com/249-un-nas-avec-un-raspberry-pi

# MAJ
apt-get update
apt-get upgrade
apt-get install openssh-server

# Install Samba V3

apt-get install samba samba-common-bin

[global]
security=user
guest ok=no
encrypt passwords=true

[maison]
path=/srv/maison
force create mode=0770
force directory mode=0770
write list=@maison

mkdir /srv/maison
addgroup maison
chown root.maison /srv/maison
chmod 770 /srv/maison

/etc/init.d/smb restart

adduser --disabled-login --no-create-home --ingroup maison utilisateur1
smbpasswd -a utilisateur1

Connexion a un partage depuis un client Windows :
net use h: \\192.168.1.75\maison

# Install Smartmontools (monitoring SMART des disques USB)
voir --> http://www.smartmontools.org/wiki/USB

jeudi 4 juillet 2013

Nom de domaine Gandi avec Hébergement mutualisé OVH

Ajouter le nom de domaine sur le manager OVH :

- administration
- récapitulatif
- nouveau domaine
- indiquez votre nom de domaine ensuite veuillez choisir "Ajouter aux DNS ( avancée)"
- sélectionner "hébergement mutualisé" "mondomaine.fr" et "redirection (aucune protection)

Il faudra par la suite aller sur la section Domaine & DNS, option Zone DNS, et vérifier les premiers champs de la liste (dnsXX.ovh.net et nsXX.ovh.net) puis les indiquer auprès de votre registrar. (ici Gandi)

RQ : Il faut compter 24 heures pour la validation et la propagation des DNS.

mercredi 12 juin 2013

Debian sur Alix

Installer une debian Squeeze sur un boitier Alix :

Partitioning and formatting the flash card
Create a single partition on the flash card and put an ext2 filesystem on it. Don’t forget to erase any existing partitions first. Afterwards, mount the newly create filesystem. Note that we are using an Ext2 filesystem. Using a journaled filesystem such as Ext3 is not a good idea, as this creates extra wear on your flash card.

fdisk /dev/sdb
mkfs.ext2 /dev/sdb1
mkdir /mnt/cf
mount /dev/sdb1 /mnt/cf

Loading a basic debian system on the CF

debootstrap --arch i386 squeeze /mnt/cf http://ftp.debian.org/debian

Mount special filesystems and chroot

mount -t proc none /mnt/cf/proc
mount -t sysfs none /mnt/cf/sys
mount -o bind /dev /mnt/cf/dev/
LC_ALL=C chroot /mnt/cf /bin/bash
mount devpts /dev/pts -t devpts

Filesystems
In order to minimize wear on the flash card, noatime was added to the mount options. This prevents the filesystem from updating access times. The tmpfs memory filesystem was used for some of the folders, basically for the same reason (minimize wear). The CF will be /dev/sda once installed in the Alix. Edit the file /etc/fstab :

proc /proc proc noatime,defaults 0 0
/dev/sda1 / ext2 noatime,defaults 0 1
tmpfs /tmp tmpfs noatime,defaults 0 0
tmpfs /var/tmp tmpfs noatime,defaults 0 0
tmpfs /var/run tmpfs noatime,defaults 0 0
tmpfs /var/log tmpfs noatime,defaults 0 0
tmpfs /var/lock tmpfs noatime,defaults 0 0

Network configuration
Edit the file /etc/network/interfaces. The example below will configure one of the network interfaces with IP address 192.168.1.250. Feel free to edit these values for your specific situation.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
   address 192.168.1.250
   netmask 255.255.255.0

Serial console
Disable TTYs and put a getty on the serial console. Edit the file /etc/inittab :

#1:2345:respawn:/sbin/getty 38400 tty1
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

T0:23:respawn:/sbin/getty -L ttyS0 19200 vt100

Grub: preparations
Install the grub package on the CF and create the file menu.lst, which will be used later on. Don’t configure grub at this stage.

apt-get install grub
cp /usr/lib/grub/i386-pc/* /boot/grub

Create /boot/grub/menu.lst (flash card will be sda on Alix):

default 0
timeout 5

serial --unit=0 --speed=19200 --word=8 --parity=no --stop=1
terminal --timeout=5 serial console

title Debian
root (hd0,0)
kernel /vmlinuz root=/dev/sda1 ro console=ttyS0,19200n8
initrd /boot/initrd.img

Install the kernel
We will install a 486 kernel, as this seems to be the best option for the CPU present in the Alix. More information about this can be found via the links at the bottom of this post.

apt-get install linux-image-486

Final customizations
Change the root password:

passwd root

Install the SSH server daemon. You can skip this skip if console access via serial connection is sufficient.

apt-get install openssh-server

Disable udev network interface rules:

rm /etc/udev/rules.d/70-persistent-net.rules
chmod 444 /lib/udev/write_net_rules

Configure the locale to en_US.UTF-8:

apt-get install locales
dpkg-reconfigure locales

Create the file setlocale.sh in /etc/profile.d, with the following contents:

#!/bin/bash
export LC_ALL=en_US.UTF-8

Final steps before booting the Alix

umount /dev/pts

Exit the chroot & umount special filesystems:

exit
umount /mnt/cf/proc
umount /mnt/cf/sys
umount /mnt/cf/dev/

Install grub in the MBR & umount the flash card:

grub-install --no-floppy --root-directory=/mnt/cf /dev/sdb
umount /mnt/cf

Login with the root user and the password you picked in one of the previous steps. Next, edit the file /etc/default/grub :

GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,19200n8"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1"

Now run:

update-grub

It's done !

-- Voir aussi --

lundi 29 avril 2013

mercredi 13 février 2013

Imagemagick tips

Créer un thumbnail :

#!/bin/bash
FILES="$@"
for i in $FILES
do echo "Processing image $i ..."
/usr/bin/convert -thumbnail 200 $i thumb.$i done

-- Voir aussi --

mercredi 16 janvier 2013

CPU speed tweak (debian)

Pour gérer la féquence du CPU :
# apt-get install cpufrequtils
# vi /etc/default/cpufrequtils

et ajouter :

# valid values: userspace conservative powersave ondemand performance
# get them from cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
GOVERNOR="performance"

Pour conserver la fréquence au boot :
# apt-get install sysfsutils
# vi /etc/sysfs.conf

et ajouter :

mode devices/system/cpu/cpufreq/performance = 644
devices/system/cpu/cpufreq/conservative/freq_step = 10
devices/system/cpu/cpufreq/conservative/up_threshold = 45
devices/system/cpu/cpufreq/conservative/ignore_nice_load = 1
devices/system/cpu/cpufreq/conservative/sampling_down_factor = 10


Pour gérer la fréquence depuis le bureau (xfce) :
# apt-get install indicator-cpufreq

Puis redémarrer le gestionnaire de fenêtre

-- Voir aussi --