forked from axic/ruby-quota
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
54 lines (47 loc) · 1.01 KB
/
test.rb
File metadata and controls
54 lines (47 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- ruby -*-
# this script is intended to be run by root on the solaris.
require 'quota'
require 'etc'
# edit for your OS
case `uname -s`
when /^Linux/
$DEV = "/dev/sdb"
$QUOTAS = "/home/stcatz/sdb/aquota.user"
when /^SunOS/
$DEV = "/quotas"
$QUOTAS = "/quotas"
when /BSD/
$DEV = "/mnt/test"
$QUOTAS = "/mnt/test/quota.user"
end
p Quota::VERSION
print("user id: ")
uid = gets.chop
if( uid =~ /\d+/ )
$USER = Etc.getpwuid(uid).name
$UID = uid.to_i
else
$USER = uid
$UID = Etc.getpwnam(uid).uid
end
print("uid = #{$USER}(#{$UID})\n")
begin
Quota.quotaon($DEV, $QUOTAS)
rescue Errno::EBUSY
Quota.quotaoff($DEV)
Quota.quotaon($DEV, $QUOTAS)
end
begin
dq = Quota.getquota($DEV, $UID)
rescue Errno::ESRCH
dq = Quota::DiskQuota.new
end
print("quota = #{dq.inspect}\n")
print("softlimit: ")
softlimit = gets.to_i
dq.bsoftlimit = softlimit # 1block = 1024byte (SunOS 5.6, edquota(1M))
Quota.setquota($DEV, $UID, dq)
p $DEV
p $UID
other = Quota.getquota($DEV, $UID)
print("quota = #{dq.inspect}\n")