# HG changeset patch # User Christophe Lincoln # Date 1390941505 -3600 # Node ID 7e9fc9556afe4523ecf4fae163a4265377792d5e # Parent 27c18235251c8c4cea064037fea5e32da498aaad Add 2 small scripts to handle quota and signup diff -r 27c18235251c -r 7e9fc9556afe tools/quota.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/quota.sh Tue Jan 28 21:38:25 2014 +0100 @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Monitor SliSH home with inotifywait, alert user and delete last file. +# +. /lib/libtaz.sh + +[ "$root" ] || root="/home/slish/chroot" +home="${root}/home" +people="$(dirname $root)/people" +logs="$(dirname $root)/logs" +activity="$logs/activity.log" + +#trap "killall inotifywait" EXIT +debug "Monitoring: $home" + +inotifywait -m -r \ + -e modify -e create ${home} 2>/dev/null | while read path event file +do + user=$(echo $path | sed s"#${home}/##" | cut -d "/" -f 1) + size=$(du -sm ${home} | awk '{print $1}') + tty="$(who | grep ^${user} | awk '{print $2}')" + . ${people}/${user}/account.conf + QUOTA="20" + if [ "$size" -gt "$QUOTA" ]; then + activity="$logs/alert.log" + debug "Quota exceeded for: $user" + log "Quota exceeded for: $user" + echo "$(colorize 31 ALERT:) quota exceeded" > /dev/${tty} + debug "Removing: ${path}${file}" + rm -rf ${path}${file} + fi +done diff -r 27c18235251c -r 7e9fc9556afe tools/signup.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/signup.sh Tue Jan 28 21:38:25 2014 +0100 @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Monitor the signup-queue directory and auto adduser +# +. /lib/libtaz.sh + +[ "$root" ] || root="/home/slish/chroot" +cache="$(dirname $root)/cache" +queue="${cache}/signup-queue" + +inotifywait -m -e create ${queue} 2>/dev/null | while read line +do + sleep 4 && slish adduser --queued +done