BASH   58

Sado sh

Guest on 24th July 2022 03:41:16 PM

  1. #!/usr/bin/ksh
  2. usage() {
  3.         print -u2 '
  4. Usage: %s [-t dir]
  5.  
  6. Collects "du -sk *" infos from /var/sadm and /var/sadm/pkg in all zones.
  7.  
  8.  t dir .. directory where data files should be stored. Default: /tmp
  9.  
  10. Example: $0 -t /var/tmp
  11.         gawk -f du.awk sadm.* > sadm.cmp.txt
  12.         gawk -f du.awk pkg.* > pkg.cmp.txt
  13. '
  14. }
  15.  
  16. TMPD="/tmp"
  17. while getopts "t:h" option ; do
  18.         case "$option" in
  19.                 "h") usage; exit 0;;
  20.                 "t")    if [ -d $OPTARG ]; then
  21.                                 TMPD=$OPTARG
  22.                         else
  23.                                 print -u2 "$OPTARG is not a directory - exiting"
  24.                                 exit 1
  25.                         fi
  26.                         ;;
  27.         esac
  28. done
  29.  
  30. if [ `/usr/ucb/whoami` != "root" ];then
  31.         print -u2 "Wanna be root!"
  32.         exit 2
  33. fi
  34. IFS=':'
  35. zoneadm list -pi | while read ID ZN ST ZP BLA ; do
  36.         if [ "$ZN" = "global" ]; then
  37.                 ROOT=""
  38.         else
  39.                 ROOT="root/"
  40.         fi
  41.         cd ${ZP}/${ROOT}/var/sadm
  42.         echo "Checking ${ZN}:/var/sadm ..."
  43.         du -sk * >${TMPD}/sadm.${ZN}.du
  44.         cd pkg
  45.         echo "Checking ${ZN}:/var/sadm/pkg ..."
  46.         du -sk * >${TMPD}/pkg.${ZN}.du
  47. done

Raw Paste


Login or Register to edit or fork this paste. It's free.