#!/bin/bash # dont forget to check to see if there's more than 1 arg to process if [[ $1 == "" ]] || [[ $2 == "" ]] ; then echo " Usage: $0 USER dfs# where: [USER] is the user you want the quota info about [dfs#] is dfs1 or dfs2 (you can also ask for both as 'dfs1 dfs2' - note the quotes) If you're root, you can CHANGE the quotas for the user on either of the dfs filesystems but only one at a time, by following the interactive commands that follow the information dump. NOTE: In the output format of the quota, if the 'Hard Limit' is zero/0, the quota is UNLIMITED, not zero. This is confusing, but is part of the BeeGFS utility, not this script. " exit fi # some colors yellow='\033[1;33m' white='\033[1;37m' lightpurple='\033[1;35m' whiteonpurple='\033[1;45m' revert='\033[0m' # No Color if [[ ! $2 =~ dfs[12] ]]; then printf "\n${whiteonpurple} The second argument has to be 'dfs1' or 'dsf2' ${revert}\n " exit fi user=$1 DFS=$2 #"dfs1 dfs2" # dfs3 # spew all the /dfs quotas on all filesystems # this is of course specific to BeeGFS filesystems. Others will need mods fsgroups=`id $user | cut -f4 -d=| sed -e 's/[0-9]*(//g'| sed -e 's/[),]/ /g'`; for FS in $DFS; do echo; echo; printf "${yellow}===== [USER quota: $user on ${FS}] ${revert}"; echo; USERQUOTACMD="beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --getquota --uid $user" $USERQUOTACMD echo; echo; printf "${lightpurple}==== [Group Quotas on ${FS}] ${revert}"; echo; echo for OO in $fsgroups; do printf "${lightpurple}==== Group quota [$OO] ${revert} \n" BCTL="beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --getquota --gid $OO" SS=`$BCTL`; if [[ ! $SS =~ "0 Byte| 0 Byte" ]]; then #if [[ ! "0 Byte| 0.00 Byte" =~ $SS ]]; then echo "$SS" else echo "No data as USER [$user], group [$OO] on [$FS]" fi echo ""; done done if [[ ! $USER == "root" ]] ; then echo "You're not root so you can't change quotas yourself, but you can ask one of the sysadmins to do it for you."; exit; else echo -n " Do you want to change the quotas for the user or groups? [Ny] > " read ANS; #fi if [[ $ANS =~ [Nn] ]] || [[ $ANS == "" ]] ; then echo "OK, bye.." exit else # yes, I want to change the quotas echo -n " Change for which FS (dfs1 or dfs2) > " read FS while [[ ! ${FS} =~ dfs[12] ]] ; do echo -n " That's neither dfs1 nor dfs2; try again > " read FS done echo -n " Change for (U)ser [$user], (G)roup, or (Q)uit? [ugQ] > " read UGQ if [[ $UGQ =~ [Qq] ]] ; then exit; fi fi if [[ $UGQ =~ [Uu] ]]; then echo "Reminder.." $USERQUOTACMD echo -n " Set TB to? [#TB](no default) > " read NEWTB; while [[ xx${NEWTB} == "xx" ]] || [[ ! $NEWTB =~ ^[0-9]+$ ]] ; do echo -n " That's not a number; enter an integer number of TBs > " read NEWTB done echo -n " Set # inodes to? [integer](no default) > " read INODES while [[ xx$INODES == "xx" ]] || [[ ! $INODES =~ ^[0-9]+$ ]] ; do echo -n " That's not a number; enter an integer number of inodes > " read INODES done # now set the quota for the user echo "The command set to be executed is: beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --setquota --uid $user --sizelimit=${NEWTB}T --inodelimit=${INODES} " beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --setquota --uid $user --sizelimit=${NEWTB}T --inodelimit=${INODES} echo; echo; echo "Here's the updated data:" $USERQUOTACMD fi if [[ $UGQ =~ [Gg] ]]; then echo -n " Which of these groups do you want to change? [${fsgroups}] (no default) > " read GG while [[ ! $fsgroups =~ $GG ]]; do echo -n " $GG does not appear to be in the original group list; please try again. > " read GG done echo "Reminder.." ## echo "beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --getquota --gid $GG" beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --getquota --gid $GG echo -n " Set TB to? [#TB](no default) > " read NEWTB; while [[ xx$NEWTB == "xx" ]] || [[ ! $NEWTB =~ ^[0-9]+$ ]]; do echo -n " That's not a number; enter an integer number of TBs > " read NEWTB done echo -n " Set # inodes to? [integer](no default) > " read INODES while [[ xx$INODES == "xx" ]] || [[ ! $INODES =~ ^[0-9]+$ ]] ; do echo -n " That's not a number; enter an integer number of inodes > " read INODES done # now set the quota for the user ## echo " ## beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --setquota --gid $GG --sizelimit=${NEWTB}T --inodelimit=${INODES} ## " beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --setquota --gid $GG --sizelimit=${NEWTB}T --inodelimit=${INODES} echo; echo; echo "Here's the updated output for that group:" beegfs-ctl --cfgFile=/etc/beegfs/${FS}.d/beegfs-client.conf --getquota --gid $GG fi fi