partview 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/ash
  2. #Barry Kauler 2012
  3. #GPL v3 (/usr/share/doc/legal)
  4. #120202 internationalized. add udf f.s.
  5. #120723 reduce mmcblk0p1 to mm0p1.
  6. #131130 zigbert: gui (gtkdialog) improvements.
  7. export TEXTDOMAIN=partview
  8. export OUTPUT_CHARSET=UTF-8
  9. /usr/lib/gtkdialog/box_splash -close never -fontsize large -text "$(gettext 'Please wait, probing drives...')" &
  10. yPID=$!
  11. #added stuff 01micko 2010-12-02
  12. . /etc/DISTRO_SPECS
  13. KERNEL=`uname -r`
  14. PUPVER=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}
  15. PARTSLIST="`probepart -k 2> /dev/null | grep '^/dev/' | grep -E 'udf|iso9660|ext2|ext3|ext4|f2fs|reiserfs|msdos|vfat|ntfs|minix' | cut -f 1-3 -d '|' | tr '\n' ' '`"
  16. COUNT=0
  17. S='<window title="Partview" icon-name="gtk-harddisk">
  18. <vbox space-expand="true" space-fill="true">
  19. '"`/usr/lib/gtkdialog/xml_info fixed "partition.svg" 60 "<b>Puppy Linux</b>" "$(gettext 'Version'): $PUPVER" "$(gettext 'Kernel'): $KERNEL"`"'
  20. <vbox space-expand="true" space-fill="true">
  21. <vbox scrollable="true" border-width="10">'
  22. for APART in $PARTSLIST
  23. do
  24. MNTSTATUS='(currently mounted)'
  25. ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  26. ASIZE=`echo -n "$APART" | cut -f 3 -d '|'`
  27. if [ -e /proc/ide ];then #v431 old kernel without libata drivers.
  28. ATIPE=`echo -n "$APART" | cut -f 2 -d '|'`
  29. case $ATIPE in
  30. iso*)
  31. ASIZE=4300000
  32. [ "`dvd+rw-mediainfo /dev/${ATAG} 2>&1 | grep 'non-DVD'`" != "" ] && ASIZE=700000
  33. ;;
  34. esac
  35. else
  36. case $ATAG in
  37. sr*)
  38. ASIZE=4300000
  39. [ "`dvd+rw-mediainfo /dev/${ATAG} 2>&1 | grep 'non-DVD'`" != "" ] && ASIZE=700000
  40. ;;
  41. esac
  42. fi
  43. AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
  44. AFPATTERN="^/dev/$ATAG "
  45. AUSED=`df -k | grep "$AFPATTERN" | head -n 1 | tr -s " " | cut -f 3 -d " "`
  46. if [ ! "$AUSED" ];then
  47. MNTSTATUS='(not mounted)'
  48. mkdir -p /mnt/$ATAG
  49. mount -t $AFS /dev/$ATAG /mnt/$ATAG > /dev/null 2>&1
  50. if [ $? -eq 0 ];then
  51. AUSED=`df -k | grep "$AFPATTERN" | head -n 1 | tr -s " " | cut -f 3 -d " "`
  52. umount /dev/$ATAG
  53. else
  54. continue
  55. fi
  56. fi
  57. AFREE=`expr $ASIZE - $AUSED`
  58. #process size...
  59. if [ $AFREE -gt 1048576 ];then #1024*1024
  60. ONEFREE="`dc $AFREE 1048576 \/ p`"
  61. ONEFREE="`printf "%.1f" $ONEFREE`G"
  62. else
  63. if [ $AFREE -gt 99 ];then
  64. ONEFREE="`expr $AFREE \/ 1024`M"
  65. else
  66. ONEFREE="`dc $AFREE 1024 \/ p`"
  67. ONEFREE="`printf "%.1f" $ONEFREE`M"
  68. fi
  69. fi
  70. if [ $ASIZE -gt 1048576 ];then #1024*1024
  71. ONESIZE="`dc $ASIZE 1048576 \/ p`"
  72. ONESIZE="`printf "%.1f" $ONESIZE`G"
  73. else
  74. if [ $ASIZE -gt 99 ];then
  75. ONESIZE="`expr $ASIZE \/ 1024`M"
  76. else
  77. ONESIZE="`dc $ASIZE 1024 \/ p`"
  78. ONESIZE="`printf "%.1f" $ONESIZE`M"
  79. fi
  80. fi
  81. . /usr/lib/gtkdialog/svg_bar 250 "$(($AUSED*250/$ASIZE))" "${ONESIZE} / ${ONEFREE} $(gettext 'free')" > /tmp/partview_${COUNT}.svg
  82. zATAG="`echo -n "$ATAG" | sed -e 's%mmcblk%mm%'`" #120723 reduce mmcblk0p1 to mm0p1
  83. S=$S'<hbox>
  84. <text><label>'${zATAG}'</label></text>
  85. <pixmap><input file>/tmp/partview_'${COUNT}'.svg</input></pixmap>
  86. </hbox>'
  87. COUNT=$(($COUNT+1))
  88. done
  89. export PartView=$S'</vbox></vbox>
  90. <hbox space-expand="false" space-fill="false">
  91. <button space-expand="false" space-fill="false">
  92. <label>'$(gettext "Ok")'</label>
  93. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  94. <action>exit:OK</action>
  95. </button>
  96. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  97. </hbox>
  98. </vbox>
  99. </window>'
  100. kill $yPID
  101. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  102. gtkdialog -p PartView --geometry=400x360
  103. ###END###