diff options
author | drgr33n <root@drgr33n.example.net> | 2009-12-17 03:57:56 +0000 |
---|---|---|
committer | drgr33n <root@drgr33n.example.net> | 2009-12-17 03:57:56 +0000 |
commit | 7881cb4e1b00d5b538c9999ceb1b6790b6e06963 (patch) | |
tree | a4700af5eee778d0d3dd392b398ddce4ab679a62 /blueman_open | |
parent | 0838610086699a16933a6027952830cff0efef33 (diff) | |
download | blueman-open-7881cb4e1b00d5b538c9999ceb1b6790b6e06963.tar.xz |
Added killscript() to fix broken pipe bug when script killed manually.
When the script was killed by ctrl+c the progress function caused
broken pipe to occur.
Added creation of cleanup scripts to unmount devices and clean
folders.
Blueman does not unmount devices when using this bash script.
So now blueman_open creates cleanup scripts in /etc/rc.d/rc0.d
& */rc6.d. These scripts also clean themselves upon running.
Diffstat (limited to 'blueman_open')
-rwxr-xr-x | blueman_open | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/blueman_open b/blueman_open index f51a881..9b08e0e 100755 --- a/blueman_open +++ b/blueman_open @@ -14,6 +14,11 @@ own_name=$(basename $0) basedir=${basedir:-/mnt} dir=${basedir}/$device_addr browser=${browser:-"xdg-open"} +cleanup_script="#!/bin/bash\n +#cleanup bluetooth mount directories on shutdown / restart\n\n\ +fusermount -uz $dir\n +rm -rf $dir\nrm /etc/rc.d/rc0.d/$device_addr-cleanup.sh 1>/dev/null 2>/dev/null\n&\ +rm /etc/rc.d/rc6.d/$device_addr-cleanup.sh 1>/dev/null 2>/dev/null" count=0 @@ -30,6 +35,17 @@ else echo "0" > $p_file fi +# fix broken pipe when unexpected error occurs + +trap killscript INT + +killscript() +{ + echo "Initializing clean shutdown......" + echo "100" > $p_file # kill gtk window + exit 0 # kill script +} + #gtkdialog abstraction gtkbox_interactive() { @@ -114,6 +130,10 @@ mount_device () [ ! -z $DEBUG ] && logger -i -t $own_name "Open $dir with $browser" out=$($browser $dir 2>&1) [ ! -z $DEBUG ] && logger -i -t $own_name "$out" + # setup cleanup script + echo -e $cleanup_script > /etc/rc.d/rc0.d/$device_addr-cleanup.sh + chmod +x /etc/rc.d/rc0.d/$device_addr-cleanup.sh + ln -s /etc/rc.d/rc0.d/$device_addr-cleanup.sh /etc/rc.d/rc6.d/$device_addr-cleanup.sh exit 0 else logger -i -t $own_name "Failed to mount $device_addr to $dir from try $i " |