#!/bin/bash

. /etc/profile >/dev/null
. /etc/tos/scripts/scripts

while [ 1 ]; do
    script_get_lock >/dev/null
    [ $? -eq 0 ] && break
done

action=$1
if [ "$action" = "insert" ]; then
    usb_init_position $2
elif [ "$action" = "remove" -o "$action" = "saferemove" -o "$action" = "delete" ]; then
    usb_disk_remove $2
fi
(/etc/udev/scripts/usb_disk_auto $@ >/dev/null &)

sleep 2
script_put_lock
exit 0
