Листинг файла /etc/udev/rules.d/81-local.rules
SUBSYSTEMS=="usb", KERNEL=="sd?1", NAME="JetFlash", RUN+="/usr/bin/usb_backup.sh"
Перезапустить службу 
sudo /etc/init.d/udev restart
Установить пакет libnotify-bin
Листинг файла /usr/local/bin/alt-notify-send
#!/bin/sh
user=`whoami`
pids=`pgrep -u $user gnome-panel`
title=$1
text=$2
timeout=$3
 
if [ -z "$title" ]; then
        echo You need to give me a title >&2
        exit 1
fi
if [ -z "$text" ]; then
        text=$title
fi
if [ -z "$timeout" ]; then
        timeout=60000
fi
 
for pid in $pids; do
        # find DBUS session bus for this session
        DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
                /proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`
        # use it
        DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
        notify-send -u low -t $timeout "$title" "$text"
done
Листинг файла /usr/bin/usb_backup.sh
#!/bin/bash
{
    mount_point=$(grep JetFlash /etc/mtab)
    attempts=1
    while [ -z "$mount_point" ] && [ "$attempts" -le 50 ]; do
            # $mount_point has not been found
            # quit if this fails more than 50 times. 
            # This should not be necessary, but it better to be safe
            # than have the script trapped in this loop forever for
            # some unforeseen reason.
   sleep 1
mount_point=$(grep JetFlash /etc/mtab)
attempts=$(($attempts+1))
   done
if [ -n "$mount_point" ]; then
su kamrenov alt-notify-send "Backup Message" "USB Backup device detected" 0
rsync -a /home/kamrenov/backup /media/disk/
su kamrenov alt-notify-send "Backup Message" "Your USB Backup has completed" 0
   fi
} &
01.07.2009
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий