alterator-quota-1.5/000075500000000000000000000000001134226453100145025ustar00rootroot00000000000000alterator-quota-1.5/Makefile000064400000000000000000000002771134226453100161500ustar00rootroot00000000000000NAME=quota PO_SHELL_TRLIST=bin/* all: clean: install: install-module install-data include /usr/share/alterator/build/module.mak install-data: install -d $(bindir) cp -a bin/* $(bindir) alterator-quota-1.5/applications/000075500000000000000000000000001134226453100171705ustar00rootroot00000000000000alterator-quota-1.5/applications/quota.desktop000064400000000000000000000003411134226453100217120ustar00rootroot00000000000000[Desktop Entry] Type=Application Categories=X-Alterator-Users Terminal=false Icon=quota X-Alterator-URI=/quota X-Alterator-Help=quota Name=Disk quotas Name[ru]=Использование диска Name[pt_BR]=Cotas de disco alterator-quota-1.5/backend3/000075500000000000000000000000001134226453100161545ustar00rootroot00000000000000alterator-quota-1.5/backend3/quota000075500000000000000000000022501134226453100172320ustar00rootroot00000000000000#!/bin/sh alterator_api_version=1 . alterator-sh-functions . alterator-net-functions write_string_params(){ while read key val; do write_string_param "${key%:}" "${val}" done } fs="" uid="" on_message() { case "$in_action" in list) case "$in__objects" in fs) alterator-quota listfs | write_enum ;; users) alterator-quota list | write_enum ;; esac ;; read) in_fs="${in_fs:-$fs}" in_uid="${in_uid:-$uid}" [ -n "$in_fs" -a -n "$in_uid" ] || return [ "$in_fs" != "#f" -a "$in_uid" != "#f" ] || return set_locale local ans="$( ( alterator-quota read -f "$in_fs" -u "$in_uid" |\ write_string_params ) 2>&1)" ans="${ans#alterator-quota: }" ans="${ans#Error: }" [ -z "$ans" ] || write_error "$ans" ;; write) uid="$in_uid" fs="$in_fs" set_locale local ans="$(alterator-quota write -f "$in_fs" -u "$in_uid" \ -q"${in_b_soft:-0},${in_b_hard:-0},${in_i_soft:-0},${in_i_hard:-0}" 2>&1)" ans="${ans#alterator-quota: }" ans="${ans#Error: }" [ -z "$ans" ] || write_error "$ans" ;; esac } message_loop alterator-quota-1.5/bin/000075500000000000000000000000001134226453100152525ustar00rootroot00000000000000alterator-quota-1.5/bin/alterator-quota000075500000000000000000000073311134226453100203300ustar00rootroot00000000000000#!/bin/bash -efu LANGUAGE="${LANGUAGE:-C}" ALTERATOR_QUOTA_CONF="${ALTERATOR_QUOTA_CONF:-/etc/alterator/quota.conf}" show_help(){ cat < [] Actions: help -- print this help list -- list users (" " pairs) listfs -- fist filesystems (" " pairs) read -- read settings for a given UID write -- write settings for a given UID Options: -f -- specify filesystem (mandatory in read and write actions) -u -- specify user id (mandatory in read and write actions) -a -- show all users in list action; by default only users with UIDs in the range [UID_MIN..UID_MAX] (see /etc/login.defs) are shown -q ",,," -- specify quota settings for write action; default value is "0,0,0,0" Examples: $0 listfs $0 list -f $0 read -f /dev/sda1 -u 500 $0 write -f / -u 500 -q 100,100,20,20 EOF } #' -- for xgettext, not mc! . shell-getopt . shell-error on_list(){ local num o1 o2 getent passwd | tr ':' '\t' | while read name o1 num o3; do if [ -z "${all:-}" ]; then [ "$(($num>=$UID_MIN))" = "1" -a\ "$(($num<=$UID_MAX))" = "1" ] || continue fi echo $num $name done } on_listfs(){ local dev s d x1 x2 x3 quota -v 2>/dev/null | sed -n -e '/Filesystem/,${/Filesystem/!p}' | while read dev x1; do mount | while read s x2 d x3; do [ "$s" = "$dev" ] || continue echo "$s $d" done done } on_read(){ local fs1 sep b_used b_soft b_hard i_used i_soft i_hard x EDITOR=cat edquota $uid -f $fs | tail -n1 | ( read fs1 b_used b_soft b_hard i_used i_soft i_hard x echo "uid: $uid" echo "fs: $fs" echo "b_used: ${b_used:-0}" echo "b_soft: ${b_soft:-0}" echo "b_hard: ${b_hard:-0}" echo "b_grace: ${b_grace:-0}" echo "i_used: ${i_used:-0}" echo "i_soft: ${i_soft:-0}" echo "i_hard: ${i_hard:-0}" echo "i_grace: ${i_grace:-0}" ) || fatal "Error: can't get quota" } on_write(){ local b_soft b_hard i_soft i_hard echo -n "$quota" | tr -s ',; \n' ' ' | ( grep '^[0-9]\+ [0-9]\+ [0-9]\+ [0-9]\+$' || fatal "Error: bad quota setting: $quota" ) | ( read b_soft b_hard i_soft i_hard setquota "$uid" "$b_soft" "$b_hard" "$i_soft" "$i_hard" "$fs" || fatal "Error: can't set quota" ) } action="${1:-help}" shift ||: all= # get min and max gids from /etc/login.defs eval "$(sed -n \ -e 's/^[[:space:]]*UID_MAX[[:space:]]*/UID_MAX=/p'\ -e 's/^[[:space:]]*UID_MIN[[:space:]]*/UID_MIN=/p'\ /etc/login.defs)" # parse options case "$action" in list) while getopts "af:s" "$@"; do case $OPTOPT in f) fs="$OPTARG" ;; a) all=1 ;; esac done ;; read) while getopts "f:u:" "$@"; do case $OPTOPT in u) uid="$OPTARG" ;; f) fs="$OPTARG" ;; esac done ;; write) while getopts "f:u:q:" "$@"; do case $OPTOPT in u) uid="$OPTARG" ;; f) fs="$OPTARG" ;; q) quota="$OPTARG" ;; esac done ;; *) ;; esac if [ "$action" = read -o "$action" = write ]; then [ -n "${fs:-}" ] || fatal "Error: filesystem does not set" fi if [ "$action" = read -o "$action" = write ]; then [ -n "${uid:-}" ] || fatal "Error: uid does not set" fi if [ "$action" = write ]; then [ -n "${quota:-}" ] || fatal "Error: quota settings are empty" fi verbose "executing $action action" case $action in list) on_list ;; listfs) on_listfs ;; read) on_read ;; write) on_write ;; *) show_help ;; esac alterator-quota-1.5/ui/000075500000000000000000000000001134226453100151175ustar00rootroot00000000000000alterator-quota-1.5/ui/quota/000075500000000000000000000000001134226453100162505ustar00rootroot00000000000000alterator-quota-1.5/ui/quota/ajax.scm000064400000000000000000000021521134226453100176770ustar00rootroot00000000000000(define-module (ui quota ajax) :use-module (alterator ajax) :use-module (alterator algo) :use-module (alterator woo) :export (init)) (define (ui-list) (let ((fs-list (woo-list "/quota/fs")) (uid-list (woo-list "/quota/users" ))) (form-update-enum "fs" fs-list) (form-update-enum "uid" uid-list) (if (pair? fs-list) (form-update-value "fs" (woo-get-option (car fs-list) 'name))) (if (pair? uid-list) (form-update-value "uid" (woo-get-option (car uid-list) 'name))) (ui-read))) (define (ui-read) (catch/message (lambda() (let ((fs (form-value "fs")) (uid (form-value "uid"))) (and (string? fs) (string? uid) (form-update-value-list (woo-read-first "/quota" 'fs fs 'uid uid))))))) (define (ui-write) (catch/message (lambda() (apply woo-write "/quota" 'language (form-value "language") (form-value-list)) (ui-read)))) (define (init) (ui-list) (form-bind "fs" "change" ui-read) (form-bind "uid" "change" ui-read) (form-bind "apply_button" "click" ui-write) (form-bind "reset_button" "click" ui-read)) alterator-quota-1.5/ui/quota/index.html000064400000000000000000000044341134226453100202520ustar00rootroot00000000000000
Filesystem:
User:
Used disk space: kb
Soft limit: kb
Hard limit: kb
Inodes used:
Soft limit:
Hard limit:
 
 
alterator-quota-1.5/ui/quota/index.scm000064400000000000000000000045721134226453100200730ustar00rootroot00000000000000(document:surround "/std/frame") (define (on-change-fs) (let ( (flist (woo-list "/quota/fs")) ) (if (string= (form-value "fs") "") (form-update-value "fs" (woo-get-option (cond-car flist) 'name))) (let* ( (fs (form-value "fs")) (uid (form-value "uid")) (ulist (woo-list "/quota/users" 'fs fs)) ) (form-update-enum "uid" ulist) (form-update-value "uid" (if (string= uid "") (woo-get-option (cond-car ulist) 'name) uid)) ) (on-change-user) )) (define (on-change-user) (catch/message (lambda() (let ((fs (form-value "fs")) (uid (form-value "uid")) ) (let ((data (woo-read-first "/quota" 'fs fs 'uid uid))) (form-update-value "b_used" (woo-get-option data 'b_used)) (form-update-value "b_soft" (woo-get-option data 'b_soft)) (form-update-value "b_hard" (woo-get-option data 'b_hard)) (form-update-value "i_used" (woo-get-option data 'i_used)) (form-update-value "i_soft" (woo-get-option data 'i_soft)) (form-update-value "i_hard" (woo-get-option data 'i_hard)) ))))) (define (on-apply) (catch/message (lambda() (apply woo-write "/quota" (form-value-list)) ))) ;; (gridbox columns "1;39;60" margin 20 (label text (_ "Filesystem:")) (combobox name "fs" enumref "/quota/fs" (when changed (on-change-fs))) (spacer) (label name "uid" text (_ "User:") align "right;top") (listbox name "uid" enumref "/quota/users" (when changed (on-change-user))) (gridbox columns "1;90;10" margin 20 (label name "b_used" text (_ "Used disk space:") align "right") (edit name "b_used" activity #f) (label name "b_used" text (_ "kb")) (label name "b_soft" text (_ "Soft limit:") align "right") (edit name "b_soft") (label name "b_soft" text (_ "kb")) (label name "b_hard" text (_ "Hard limit:") align "right") (edit name "b_hard") (label name "b_hard" text (_ "kb")) (label name "i_used" text (_ "Inodes used:") align "right") (edit name "i_used" activity #f) (spacer) (label name "i_soft" text (_ "Soft limit:") align "right") (edit name "i_soft") (spacer) (label name "i_hard" text (_ "Hard limit:") align "right") (edit name "i_hard") (spacer) (spacer) (button text (_ "Apply") (when clicked (on-apply))) (button text (_ "Reset") (when clicked (on-change-user))) ) ) (document:root (when loaded (on-change-fs) ))