slish rev 12
Add 2 small scripts to handle quota and signup
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Jan 28 21:38:25 2014 +0100 (2014-01-28) |
parents | 27c18235251c |
children | 15715ea79088 |
files | tools/quota.sh tools/signup.sh |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/quota.sh Tue Jan 28 21:38:25 2014 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Monitor SliSH home with inotifywait, alert user and delete last file. 1.7 +# 1.8 +. /lib/libtaz.sh 1.9 + 1.10 +[ "$root" ] || root="/home/slish/chroot" 1.11 +home="${root}/home" 1.12 +people="$(dirname $root)/people" 1.13 +logs="$(dirname $root)/logs" 1.14 +activity="$logs/activity.log" 1.15 + 1.16 +#trap "killall inotifywait" EXIT 1.17 +debug "Monitoring: $home" 1.18 + 1.19 +inotifywait -m -r \ 1.20 + -e modify -e create ${home} 2>/dev/null | while read path event file 1.21 +do 1.22 + user=$(echo $path | sed s"#${home}/##" | cut -d "/" -f 1) 1.23 + size=$(du -sm ${home} | awk '{print $1}') 1.24 + tty="$(who | grep ^${user} | awk '{print $2}')" 1.25 + . ${people}/${user}/account.conf 1.26 + QUOTA="20" 1.27 + if [ "$size" -gt "$QUOTA" ]; then 1.28 + activity="$logs/alert.log" 1.29 + debug "Quota exceeded for: $user" 1.30 + log "Quota exceeded for: $user" 1.31 + echo "$(colorize 31 ALERT:) quota exceeded" > /dev/${tty} 1.32 + debug "Removing: ${path}${file}" 1.33 + rm -rf ${path}${file} 1.34 + fi 1.35 +done
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tools/signup.sh Tue Jan 28 21:38:25 2014 +0100 2.3 @@ -0,0 +1,14 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# Monitor the signup-queue directory and auto adduser 2.7 +# 2.8 +. /lib/libtaz.sh 2.9 + 2.10 +[ "$root" ] || root="/home/slish/chroot" 2.11 +cache="$(dirname $root)/cache" 2.12 +queue="${cache}/signup-queue" 2.13 + 2.14 +inotifywait -m -e create ${queue} 2>/dev/null | while read line 2.15 +do 2.16 + sleep 4 && slish adduser --queued 2.17 +done