Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37743998
en ru br
ALT Linux repositórios
S:1.6.3-alt1
5.0: 1.3-alt1

Group :: Sistema/Configurações/Rede
RPM: alterator-quota

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

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 <<EOF
Helper script for alterator-quota module.

Usage: $0 <action> [<options>]

Actions:

help -- print this help
list -- list users ("<UID> <name>" pairs)
listfs -- fist filesystems ("<device> <mountpoints>" pairs)
read -- read settings for a given UID
write -- write settings for a given UID

Options:

-f <filesystem> -- specify filesystem (mandatory in read and write actions)
-u <UID> -- 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 "<block_soft>,<block_hard>,<inode_soft>,<inode_hard>"
-- 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<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
</head>
<body>
<form method="POST">
<table>
<tr>
<td>
<table>
<tr>
<td style="text-align:right;padding-right:3px"><span translate="_">Filesystem:</span></td>
<td style="padding-right:10px"><select name="fs" style="width:98%"/></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="right" rowspan="8" style="text-align:right;padding-right:3px;vertical-align:top"><span translate="_">User:</span></td>
<td rowspan="8" style="padding-right:10px"><select size="8" name="uid" style="width:98%"/></td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td style="text-align:right;padding-right:3px"><u><span translate="_">Used disk space:</span></u></td>
<td><b><span class="alterator-label" name="b_used"/></b>
<span translate="_">kb</span></td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><span translate="_">Soft limit:</span></td>
<td><input type="text" class="text" size="10" name="b_soft"/>
<span translate="_">kb</span></td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><span translate="_">Hard limit:</span></td>
<td><input type="text" class="text" size="10" name="b_hard"/>
<span translate="_">kb</span></td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><u><span translate="_">Inodes used:</span></u></td>
<td><b><span class="alterator-label" name="i_used"/></b></td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><span translate="_">Soft limit:</span></td>
<td><input type="text" class="text" size="10" name="i_soft"/></td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><span translate="_">Hard limit:</span></td>
<td><input type="text" class="text" size="10" name="i_hard"/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="text-align:right;padding-right:3px"><input type="button" class="btn" name="apply_button" value="Apply"/>
<input type="button" class="btn" name="reset_button" value="Reset"/>
</td>
<td>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
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) ))
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009