Rechercher dans ce blog

mercredi 9 décembre 2015

Mac OS X Mail remove auto-completed addresses list

Entries are store in

/user/Library/Applications Support/AddressBook/MailRecents-v4.abcdmr

On peut effacer les entrées aussi via l'interface

mail/window/previous receipts


UPSTART job control UBUNTU / LINUX

from http://upstart.ubuntu.com/cookbook/

A job does not necessarily need a stop on stanza. If it lacks one, any running instances can still be stopped by an Administrator running either of:

    initctl stop
    stop



4.7.1   Display Runlevel

To display your current and previous runlevels separated by a space character, run the /sbin/runlevel command. Note that if this command is unable to determine the system runlevel, it may display simply "unknown":

$ runlevel
N 2

The output above shows that:

    there was no previous runlevel (the system was booted and went straight to the current runlevel).
    the current runlevel is "2".


4.7.2   Change Runlevel Immediately

To change runlevel immediately, use one of the commands below:

    reboot(8)
    shutdown(8)
    telinit(8)




6.33   start on

This stanza defines the set of Events that will cause the Job to be automatically started.

Syntax:

start on EVENT [[KEY=]VALUE]... [and|or...]

Each event EVENT is given by its name. Multiple events are permitted using the operators "and" and "or" and complex expressions may be performed with parentheses (within which line breaks are permitted).

You may also match on the environment variables contained within the event by specifying the KEY and expected VALUE. If you know the order in which the variables are given to the event you may omit the KEY.

VALUE may contain wildcard matches and globs as permitted by fnmatch(3) and may expand the value of any variable defined with the env stanza.

Negation is permitted by using "!=" between the KEY and VALUE.

Note that if the job is already running and is not an instance job, if the start on condition becomes true (again), no further action will be taken.

Note that the start on stanza expects a token to follow on the same line. Thus:

# ERROR: invalid
start on
  foo or bar

# OK
start on foo or bar

If no environment variables are specified via KEY to restrict the match, the condition will match all instances of the specified event.

See Really understanding start on and stop on for further details.
6.33.1   Normal start

If you are just writing an upstart job that needs to start the service after the basic facilities are up, either of these will work:

start on (local-filesystems and net-device-up IFACE!=lo)

or:

start on runlevel [2345]

The difference in whether to use the more generic 'runlevel' or the more explicit local-filesystems(7) and net-device-up events should be guided by your job's behaviour. If your service will come up without a valid network interface (for instance, it binds to 0.0.0.0, or uses setsockopt(2) SO_FREEBIND), then the runlevel event is preferable, as your service will start a bit earlier and start in parallel with other services.

However if your service requires that a non-loopback interface is configured for some reason (i.e., it will not start without broadcasting capabilities), then explicitly saying "once a non loopback device has come up" can help.

In addition, services may be aggregated around an abstract job, such as network-services:

start on started network-services

The network-services job is a generic job that most network services should follow in releases where it is available. [19] This allows the system administrator and/or the distribution maintainers to change the general startup of services that don't need any special case start on criteria.

We use the started(7) event so that anything that must be started before all network services can do "start on starting network-services".
6.33.2   Start depends on another service

start on started other-service

6.33.3   Start must precede another service

start on starting other-service

Example: your web app needs memcached to be started before apache:

start on starting apache2
stop on stopped apache2
respawn

exec /usr/sbin/memcached

6.34   stop on

This stanza defines the set of Events that will cause the Job to be automatically stopped if it is already running.

Syntax:

stop on EVENT [[KEY=]VALUE]... [and|or...]

Like the stop on stanza, start on expects a token to follow on the same line:

# ERROR: invalid
stop on
  foo or bar

# OK
stop on foo or bar

See start on for further syntax details.
6.34.1   Normal shutdown

stop on runlevel [016]

Or if a generic job is available such as network-services [19]

stop on stopping network-services

6.34.2   Stop before depended-upon service

stop on stopping other-service

Note that this also will stop when other-service is restarted, so you will generally want to couple this with the start on condition:

start on started other-service

6.34.3   Stop after dependent service

stop on stopped other-service




6.28   respawn

Note

If you are creating a new Job Configuration File, do not specify the respawn stanza until you are fully satisfied you have specified the expect stanza correctly. If you do, you will find the behaviour potentially very confusing.

Without this stanza, a job that exits quietly transitions into the stop/waiting state, no matter how it exited.

With this stanza, whenever the main script/exec exits, without the goal of the job having been changed to stop, the job will be started again. This includes running pre-start, post-start and post-stop. Note that pre-stop will not be run.

There are a number of reasons why you may or may not want to use this. For most traditional network services this makes good sense. If the tracked process exits for some reason that wasn't the administrator's intent, you probably want to start it back up again.

Likewise, for tasks, (see below), respawning means that you want that task to be retried until it exits with zero (0) as its exit code.

One situation where it may seem like respawn should be avoided, is when a daemon does not respond well to SIGTERM for stopping it. You may believe that you need to send the service its shutdown command without Upstart being involved, and therefore, you don't want to use respawn because Upstart will keep trying to start your service back up when you told it to shutdown.

However, the appropriate way to handle that situation is a pre-stop which runs this shutdown command. Since the job's goal will already be 'stop' when a pre-stop is run, you can shutdown the process through any means, and the process won't be re-spawned (even with the respawn stanza).

Note that if a job is respawned, the variable "$PROCESS" will be set to the name of the job process that failed (for example "pre-start" or "main"). See stopped(7) for further details.

Further note that if the job does not specify the respawn limit stanza as well as the respawn stanza, the job will have the default respawn limit applied (see respawn limit).
6.29   respawn limit

Yes, this is different to a plain respawn: specifying respawn limit does not imply respawn.

Syntax:

respawn limit COUNT INTERVAL | unlimited

Example:

# respawn the job up to 10 times within a 5 second period.
# If the job exceeds these values, it will be stopped and
# marked as failed.
respawn
respawn limit 10 5

# respawn the job indefinitely
respawn limit unlimited

Respawning is subject to a limit. If the job is respawned more than COUNT times in INTERVAL seconds, it will be considered to be having deeper problems and will be stopped. Default COUNT is 10. Default INTERVAL is 5 seconds.

To have the job respawn indefinitely, specify an argument of "unlimited". However, care should be taken using this option: does your service really stop that frequently? Should it?

Specifying either COUNT or INTERVAL as 0 (zero) implies unlimited.

Note that respawn only applies to automatic respawns and not the restart(8) command.

If the job has been respawned up to its respawn limit, the variable "$PROCESS" will be set to "respawn" to denote that the respawn limit was reached. See stopped(7) for further details.

UFW enable no logging UBUNTU / LINUX

vi /lib/ufw/ufw-init-functions


Coller ça:

 if [ ! -z "$LOGLEVEL" ]; then
            /usr/sbin/ufw logging $LOGLEVEL || true
        fi

juste avant ça dans la fonction ufw_start()

 if [ ! -z "$IPT_SYSCTL" ] && [ -s "$IPT_SYSCTL" ]; then
            sysctl -e -q -p $IPT_SYSCTL || true
        fi

        if [ "$error" = "yes" ]; then
            /bin/echo -e "$out"
            return 1
        fi


/etc/ufw# vi ufw.conf

# Please use the 'ufw' command to set the loglevel. Eg: 'ufw logging medium'.
# See 'man ufw' for details.
LOGLEVEL=off

Change DISK UUID LINUX / UBUNTU

tune2fs /dev/sdb1 -U 310fd3b1-bc68-45cf-b04b-c9498ae59e27






Problème sur disque monté

when I tried to change my root filesystem's uuid on new 14.04 ubuntu, tune2fs reported back: I can't do that to mounted file systems.

There's a flag that needs to be disabled, to allow mounted-uuid changes with the new tune2fs. this is what my process looked like:

root@ubuntu1404:~# blkid
/dev/sda1: UUID="2ec827b0-72be-4c73-b58a-102a37aa24a3" TYPE="ext4"
root@ubuntu1404:~# uuid="deafcafe-abba-daba-deca-fc0ffee05065"
root@ubuntu1404:~# root_disk=$(df /|grep /|cut -d' ' -f1)
root@ubuntu1404:~# echo $root_disk
/dev/sda1
root@ubuntu1404:~# tune2fs -U $uuid $root_disk
tune2fs 1.42.9 (4-Feb-2014)
The UUID may only be changed when the filesystem is unmounted.
root@ubuntu1404:~# tune2fs -O ^uninit_bg $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# tune2fs -U $uuid $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# tune2fs -O +uninit_bg $root_disk
tune2fs 1.42.9 (4-Feb-2014)
root@ubuntu1404:~# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       7.3G  3.9G  3.0G  58% /
root@ubuntu1404:~# blkid
/dev/sda1: UUID="deafcafe-abba-daba-deca-fc0ffee05065" TYPE="ext4"
root@ubuntu1404:~#

Générer une image ISO de DVD à partir d'un dossier VIDEO_TS en CLI / UBUNTU

Utiliser la commande :

genisoimage -dvd-video -o dvd.iso DIRECTORY/

Le dossier VIDEO_TS doit être un sous-dossier de DIRECTORY

La commande genisoimage semble installée d'origine sur ubuntu 14.04 (en tout cas je ne me souviens pas de l'avoir installée).


mercredi 27 mai 2015

GRUB 2 REPAIR & RESCUE

from : https://www.linux.com/learn/tutorials/776643-how-to-rescue-a-non-booting-grub-2-on-linux/ 
 
 
grub> set pager=1
 
grub> ls
(hd0) (hd0,msdos2) (hd0,msdos1
 
grub> ls (hd0,1)/
lost+found/ bin/ boot/ cdrom/ dev/ etc/ home/  lib/
lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ 
srv/ sys/ tmp/ usr/ var/ vmlinuz vmlinuz.old 
initrd.img initrd.img.old
 
grub> cat (hd0,1)/etc/issue
Ubuntu 14.04 LTS \n \l
 

Booting From grub>

grub> set root=(hd0,1)
grub> linux /vmlinuz root=/dev/sda1
grub> initrd /initrd.img
grub> boot

grub> set root=(hd0,1)
grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub> initrd /boot/initrd.img-3.13.0-29-generic
grub> boot

Pour voir et booter les liens symboliques
 
$ ls -l /
vmlinuz -> boot/vmlinuz-3.13.0-29-generic
initrd.img -> boot/initrd.img-3.13.0-29-generic 


grub> set root=(hd0,1)
grub> linux /vmlinuz root=/dev/sda1
grub> initrd /initrd.img
grub> boot 

Booting From grub-rescue>

If you're in the GRUB rescue shell the commands are different, 
and you have to load the normal.mod andlinux.mod modules: 

insmod normal
insmod linux


mais prefix doit être "set" avant...

grub rescue> set prefix=(hd0,1)/boot/grub
grub rescue> set root=(hd0,1)
grub rescue> insmod normal
grub rescue> normal
grub rescue> insmod linux
grub rescue> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub rescue> initrd /boot/initrd.img-3.13.0-29-generic
grub rescue> boot
 

Making Permanent Repairs


# update-grub
Generating grub configuration file ...
Found background: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found background image: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found linux image: /boot/vmlinuz-3.13.0-29-generic
Found initrd image: /boot/initrd.img-3.13.0-29-generic
Found linux image: /boot/vmlinuz-3.13.0-27-generic
Found initrd image: /boot/initrd.img-3.13.0-27-generic
Found linux image: /boot/vmlinuz-3.13.0-24-generic
Found initrd image: /boot/initrd.img-3.13.0-24-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done 
 
# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.

mardi 21 avril 2015

HP Elitebook 8470p fingerprint reader validity


Procédure pour activer le lecteur d'empreintes digitales sur HP elitebook 8470p sous UBUNTU 14.04


Uninstallation
===========
GNOME users: The package policykit-

1-fingerprint-gui replaces GNOME's standard PolicyKit daemon (contained in package policykit-1-gnome). However, when you decide to uninstall Fingerprint GUI (and hence remove policykit-1-fingerprint-gui), policykit-1-gnome will not get automatically installed back, hence there won't be any PolicyKit daemon in the system, and APT will try to remove all the packages that depend on it. Therefore, if you want to remove Fingerprint GUI, make sure you install policykit-1-gnome back first.
   sudo apt-get install policykit-1-gnome
   sudo apt-get remove fingerprint-gui


Je donne toutes les démarches à faire pour obtenir le fonctionnement, mais on peut simplifier en installant directement installer le pkg et copier le fichier de démarrage et ensuite on peut passer toutes les étapes de la compilation en récupérant la libfprint0 déjà compilée comme le pkg et le script sur mon drive google (https://drive.google.com/fingerprint_reader_files).

uname -a :

Linux uranix 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

lsusb -s 001:003 -v :

Bus 001 Device 003: ID 138a:003d Validity Sensors, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass        17
  bDeviceProtocol       255
  bMaxPacketSize0         8
  idVendor           0x138a Validity Sensors, Inc.
  idProduct          0x003d
  bcdDevice            1.04
  iManufacturer           0
  iProduct                0
  iSerial                 1 0030d8cdc38f
  bNumConfigurations      1






... cut ...








Le plus simple est d'installer :

sudo apt-get install libbsapi policykit-1-fingerprint-gui fingerprint-gui

Cela devrait installer automatiquement : libfprint0

Si nécessaire installer d'abord :

sudo apt-add-repository ppa:fingerprint/fingerprint-gui
sudo apt-get update


Attention : la version 1.07 de fingerprint ne fonctionne pas correctement aussi je maintiens la version 1.07. Comme les packages ne sont pas disponible dans cette version via le ppa je mets les pkg version 1.06 sur le drive google avec les autres fichiers. A suivre lorsqu'il y aura une mise à jour fingerprint...

Dans cet état le fingerprint reader ne fonctionne pas.

Il faut installer une libfprint0 qui le reconnaisse et qui est (si je comprends bien) un wrapper pour le pilote que HP a développé pour la distribution Suse. Je suis ici les indications données sur le blog (merci à lui) mais en les modifiant et les complétant là où c'est nécessaire :

http://blog.pasqualefiorillo.it/post/hp-probook-4540s-validity-sensors-driver-su-linux-mintdebian/


1 - télécharger le pilote :

ftp://ftp.hp.com/pub/softpaq/sp57001-57500/sp57317.tar
 
2 -  tar xvf sp57317.tar

3 - On obtient un paquet .rpm

Validity-Sensor-Setup-4.4-100.00.x86_64.rpm

On le convertit en paquet debian

sudo alien -d Validity-Sensor-Setup-4.4-100.00.x86_64.rpm

4 - On installe le paquet debian

sudo dpkg -i validity-sensor-setup-4.4-100.00.x86_64.deb

5 - On modifie le script de démarrage

/etc/init.d/vcsFPServiceDaemon

en remplaçant son contenu par

#!/bin/sh
### BEGIN INIT INFO
# Provides: Validity Fingerprint Service Daemon
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 5
# Default-Stop: 0 6
# Short-Description: Validity Fingerprint Service Daemon
# Description: Start vcsFPService to provide Validity FP Service
### END INIT INFO
#
# Note on runlevels:
# 0 - halt/poweroff 6 - reboot
# 1 - single user 2 - multiuser without network exported
# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
#

. /lib/lsb/init-functions

vcsFPService_BIN=/usr/bin/vcsFPService
test -x $vcsFPService_BIN || { echo "$vcsFPServiceDaemon is not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }

case "$1" in
start)
echo -n "Starting vcsFPService Daemon \n"
start-stop-daemon --start --background --quiet --exec "$vcsFPService_BIN" > /dev/null 2 >&1

;;
stop)
echo -n "Stopping vcsFPService Daemon \n"

#/sbin/killall -TERM $vcsFPService_BIN
start-stop-daemon --stop --quiet --quiet --oknodo --retry=0/1/KILL/5 --exec "$vcsFPService_BIN" > /dev/null 2 >&1

;;
status)
echo "Checking for vcsFPService Daemon \n"

if pidof -o %PPID $vcsFPService_BIN> /dev/null; then
echo "client is running. \n"
exit 0
else
echo "client is not running. \n"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac

exit 0

6 - On met à jour  les liens de démarrage

sudo update-rc.d vcsFPServiceDaemon defaults

Pour savoir si le service fonctionne ou non :

sudo /etc/init.d/vcsFPServiceDaemon status

7 - Téléchargement de libfprint0

http://suse.mes.edu.cu/SLES_11_SP2/CD2/suse/src/libfprint-0.0.6-18.20.1.src.rpm

 8 - Extraire le contenu du paquet rpm avec le gestionnaire d'archives soit par l'interface graphique soit en utilisant la commande :

file-roller -h libfprint-0.0.6-18.20.1.src.rpm

9 - cd libfprint-0.0.6-18.20.1.src/

Extraire

bzip2 -d libfprint-0.0.6.tar.bz2

Untarer :

tar xf libfprint-0.0.6.tar

10 - Patcher pour ajouter le support pour le fingerprint reader validity 0138:003d

cd libfprint-0.0.6/
patch -p1 <../libfprint-validity.patch


moi@uranix:~/Téléchargements/libfprint-0.0.6-18.20.1.src/libfprint-0.0.6$ patch -p1 <../libfprint-validity.patch
patching file libfprint/Makefile.am
Hunk #1 succeeded at 7 (offset -1 lines).
Hunk #2 succeeded at 64 (offset -9 lines).
patching file libfprint/Makefile.in
patching file libfprint/core.c
patching file libfprint/drivers/validity/vfsDriver.c
patching file libfprint/drivers/validity/vfsDriver.h
patching file libfprint/drivers/validity/vfsWrapper.h
patching file libfprint/fp_internal.h
Hunk #1 succeeded at 122 (offset -3 lines).
Hunk #2 succeeded at 149 (offset -4 lines).
patching file libfprint/imgdev.c


11 - Compiler

./configure
make


12 - Remplacer libfprint0 de ubuntu par celle que l'on vient de compiler.

 cp libfprint/.libs/libfprint.so.0.0.0 /usr/lib

Attention, s'il y a une mise à jour de libfprint0 alors elle sera remplacée de nouveau par la version d'ubuntu.

Donc en faire une copie de sauvegarde dans /usr/local/lib par exemple.

cp libfprint/.libs/libfprint.so.0.0.0 /usr/local/lib

Mais aussi faire un hold sur la lib en faisant :

echo "libfprint0 hold"|dpkg --set-selections

ou

apt-mark hold libfprint0

13 A partir de là, le fingerprint reader doit être reconnu (bien s'assurer que le service vcsFPServiceDaemon est running...

avec fingerprint-gui on peut enregistrer ses empreintes et tester les différents services comme sudo, screenlocker, etc.




Je mets tous les fichiers sur mon drive google.

https://drive.google.com/fingerprint_reader_files