#!/bin/sh #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #System: Ubuntu/Debian GNU/Linux # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. monitor_diskspace() { location="$1" minspace="$2" if [ ! -n "$location" ] then echo "location not set" fi if [ ! -n "$minspace" ] then echo "minspace not set" fi status="start" while [ "true" = "true" ] do diskspace=$(df --portability "$location" | awk 'END {print $4}') if [ ! "$diskspace" -gt "$minspace" ] && [ "$status" = "start" ] then echo "minimal disk space limit reached, executing stop command" human=$(df --human-readable --portability "$location" | awk 'END {print $4}') zenity --warning --text="minimal disk space limit reached, diskspace: $human" status="stop" fi if [ "$diskspace" -gt "$minspace" ] && [ "$status" = "stop" ] then echo "minimal disk space limit restored, executing start command" human=$(df --human-readable --portability "$location" | awk 'END {print $4}') zenity --warning --text="minimal disk space limit restored, diskspace: $human" status="start" fi sleep 120 done } location="$HOME" minspace="100000" # arround 100MB monitor_diskspace "$location" "$minspace" exit