-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisablebackup.sh
60 lines (46 loc) · 1.43 KB
/
disablebackup.sh
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
55
56
57
58
59
60
#!/bin/bash
MAXINODES=100000
MAXSIZE=5242880
disablebackup () {
# Check if new backup is active.
if [ `/usr/sbin/whmapi1 accountsummary user="$1" | grep -Po "(?<= backup: )([0-1])"` -eq 1 ]
then
/usr/sbin/whmapi1 toggle_user_backup_state user="$1" legacy=0
fi
# Check if legacy backup is active.
if [ `/usr/sbin/whmapi1 accountsummary user="$1" | grep -Po "(?<= legacy_backup: )([0-1])"` -eq 1 ]
then
/usr/sbin/whmapi1 toggle_user_backup_state user="$1" legacy=1
fi
}
enablebackup () {
# Check if new backup is active.
if [ `/usr/sbin/whmapi1 accountsummary user="$1" | grep -Po "(?<= backup: )([0-1])"` -eq 0 ]
then
/usr/sbin/whmapi1 toggle_user_backup_state user="$1" legacy=0
fi
# Check if legacy backup is active.
if [ `/usr/sbin/whmapi1 accountsummary user="$1" | grep -Po "(?<= legacy_backup: )([0-1])"` -eq 0 ]
then
/usr/sbin/whmapi1 toggle_user_backup_state user="$1" legacy=1
fi
}
users=$(cat /etc/trueuserowners | grep -v ^# | cut -d: -f1)
for user in $users
do
enablebackup $user
done
for i in $(repquota /home | tail -n +6 |grep ^[a-Z] | awk '{ print $1 "|" $3 "|" $6 }')
do
user=$(cut -d "|" -f 1 <<< $i)
dused=$(cut -d "|" -f 2 <<< $i)
inode=$(cut -d "|" -f 3 <<< $i)
if [ $inode == "none" ]
then
inode=0
fi
if [ ${inode} -gt ${MAXINODES} -o ${dused} -gt ${MAXSIZE} ]
then
disablebackup $user
fi
done