a n,h@s~dZddlZddlZddlZddlZejddddlmZddl m Z dZ e ddd Z d d Zd d ZedkrzedS)z!Wrapper around pkgacct for tier2cNz/opt/support/lib)cpuser_safe_arg)cpuwatch_execvg?userc Cstd}t|jd}t|jd}zttj|dd}Wn6tjyx}zt |dWYd}~n d}~00|t d}|||krdSt d|dt d t d t d |d t d |d t ddS)z6Ensure the account is not too large to pkgacct in fullz/homei@rz - try /scripts/fixquotasNdzCannot package z without --skiphomedirz&The account would place the disk at < z% freezAccount size: z GBzDisk free space: ) psutil disk_usageintZfreetotalradsZQuotaCtlZgetquotaZQuotasDisabledsysexitDISK_PERCENT_LIMITprint)rr Zgb_freeZgb_totalZacct_gbexcZ disk_neededr./opt/tier2c/safe_pkgacct.pycheck_acct_sizes &  rcCs:tjdd}|jdddd|jddtd d |}|S) zParse commandline argumentszmWrapper around CPanel pkgacct. It is recommended to run this in screen due to the amount of time it may take.) description --skiphomedir store_truez7Do not include the home directory in the CPanel package)actionhelprZUSERz#user to create a CPanel package for)metavartyper)argparseArgumentParser add_argumentr parse_args)parserargsrrrr#s rcCsFt}|jst|jddg}|jr.|d||jt|dS)z-main: parse args, determine size, run pkgacctrz!/usr/local/cpanel/scripts/pkgacctrN)rZ skiphomedirrrappendr)r!cmdrrrmain8s   r$__main__)__doc__rr rr pathinsertZ arg_typesrZrun_cmdrrstrrrr$__name__rrrrs