forked from redhat-consulting/ose-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoo-cleanup-apps
executable file
·31 lines (27 loc) · 1.11 KB
/
oo-cleanup-apps
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
#!/bin/bash
SOFT_LIMIT=10
HARD_LIMIT=15
SOFT_LIMIT_MESSAGE="
Attention %s: you currently have %s apps in ePaas. Once this grows to ${HARD_LIMIT}, you will no longer be permitted to create apps. Please cleanup old versions to prevent any further action."
HARD_LIMIT_MESSAGE="
Attention %s: you have reached your application limit of ${HARD_LIMIT} apps in ePaas. You wil no longer be able to create new applications. To remedy this, please remove some of your old applications, then email ${ADMIN_EMAIL} to request reinstatement."
#Functions
num_of_apps() {
local single_user_data=$1
echo "$user" | awk '{print $3}'
}
user_data="$(/root/oo-list --users)"
echo "$user_data" | while read -r user; do
username=$(echo "$user" | awk '{print $1}')
appcount=$(num_of_apps $user)
#echo "User $username has $appcount apps"
if [ $appcount -gt ${HARD_LIMIT} ]; then
# Set Max Gears to 0
oo-admin-ctl-user -l $username --setmaxgears 0
# Send Email
printf "$HARD_LIMIT_MESSAGE" "$username"
elif [ $appcount -gt ${SOFT_LIMIT} ]; then
# Send Email
printf "$SOFT_LIMIT_MESSAGE" "$username" "$appcount"
fi
done