resizepfile.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/bin/sh
  2. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  3. #make the pup_save.2fs file bigger.
  4. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  5. #v555 pup files renamed to woofr555.sfs, woofsave.2fs.
  6. #100913 simplified filenames, minor update of comments.
  7. #120202 rodin.s: internationalized.
  8. #120323 partial replace 'xmessage' with 'pupmessage'.
  9. #130715 some translation fixes.
  10. #131223 gtkdialog
  11. #131226 rodin.s: updating i18n
  12. export TEXTDOMAIN=resizepfile.sh
  13. export TEXTDOMAINDIR=/usr/share/locale
  14. export OUTPUT_CHARSET=UTF-8
  15. . gettext.sh
  16. #variables created at bootup by /initrd/usr/sbin/init...
  17. . /etc/rc.d/PUPSTATE
  18. . /etc/DISTRO_SPECS #v412
  19. SAVELOC=$(echo $PUPSAVE | cut -f3 -d ',')
  20. [ -d /mnt/home$SAVELOC ] && /usr/lib/gtkdialog/box_ok "$(gettext 'Resize personal storage file')" info "<b>$(gettext "Puppy is currently using a savefolder. There is no need to resize it")</b>" " " && exit 0
  21. #find out what modes use a ${DISTRO_FILE_PREFIX}save.2fs file...
  22. CANDOIT="no"
  23. case $PUPMODE in
  24. "12") #${DISTRO_FILE_PREFIX}save.3fs (pup_rw), nothing on pup_ro1, ${DISTRO_PUPPYSFS} (pup_ro2).
  25. PERSISTMNTPT="/initrd/pup_rw"
  26. CANDOIT="yes"
  27. ;;
  28. "13") #tmpfs (pup_rw), ${DISTRO_FILE_PREFIX}save.3fs (pup_ro1), ${DISTRO_PUPPYSFS} (pup_ro2).
  29. PERSISTMNTPT="/initrd/pup_ro1"
  30. CANDOIT="yes"
  31. ;;
  32. esac
  33. if [ "$CANDOIT" != "yes" ];then
  34. /usr/lib/gtkdialog/box_ok "$(gettext 'Resize personal storage file')" error "<b>$(gettext "Sorry, Puppy is not currently using a personal persistent storage file.")</b>" " " "$(eval_gettext "If this is the first time that you booted Puppy, say from a live-CD, you are currently running totally in RAM and you will be asked to create a personal storage file when you end the session (shutdown the PC or reboot). Note, the file will be named \${DISTRO_FILE_PREFIX}save.2fs and will be created in a place that you nominate.")
  35. $(eval_gettext "If you have installed Puppy to hard drive, or installed such that personal storage is an entire partition, then you will not have a \${DISTRO_FILE_PREFIX}save.2fs file either.")"
  36. exit
  37. fi
  38. [ ! "$PUPSAVE" ] && exit #precaution
  39. [ ! "$PUP_HOME" ] && exit #precaution.
  40. SAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
  41. SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
  42. SAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  43. NAMEPFILE="`basename $SAVEFILE`"
  44. HOMELOCATION="/initrd${PUP_HOME}${SAVEFILE}"
  45. SIZEFREE=`df -m | grep "$PERSISTMNTPT" | tr -s " " | cut -f 4 -d " "` #free space in ${DISTRO_FILE_PREFIX}save.3fs
  46. ACTUALSIZK=`ls -sk $HOMELOCATION | tr -s " " | cut -f 1 -d " "` #total size of ${DISTRO_FILE_PREFIX}save.3fs
  47. if [ ! $ACTUALSIZK ];then
  48. ACTUALSIZK=`ls -sk $HOMELOCATION | tr -s " " | cut -f 2 -d " "`
  49. fi
  50. ACTUALSIZE=`expr $ACTUALSIZK \/ 1024`
  51. APATTERN="/dev/${SAVEPART} "
  52. PARTSIZE=`df -m | grep "$APATTERN" | tr -s " " | cut -f 2 -d " "`
  53. PARTFREE=`df -m | grep "$APATTERN" | tr -s " " | cut -f 4 -d " "`
  54. . /usr/lib/gtkdialog/svg_bar 200 "$(((($ACTUALSIZE-$SIZEFREE)*200/$ACTUALSIZE)))" "$ACTUALSIZE Mb / $SIZEFREE Mb $(gettext 'free')" > /tmp/resizepfile_pfile.svg
  55. . /usr/lib/gtkdialog/svg_bar 200 "$(((($PARTSIZE-$PARTFREE)*200/$PARTSIZE)))" "$PARTSIZE Mb / $PARTFREE Mb $(gettext 'free')" > /tmp/resizepfile_partition.svg
  56. x='
  57. <window title="'$(gettext 'Resize Personal Storage File')'" icon-name="gtk-refresh">
  58. <vbox space-expand="true" space-fill="true">
  59. '"$(/usr/lib/gtkdialog/xml_info fixed puppy_increase.svg 60 "$(eval_gettext "<b>Your personal file is \${NAMEPFILE},</b> and this contains user data, configuration files, email, newsgroup cache, history files and installed packages...")" "$(eval_gettext "If you see that you are running low on space in \$NAMEPFILE, you can make it bigger, but of course there must be enough space in \$SAVEPART.")")"'
  60. <vbox space-expand="true" space-fill="true">
  61. <frame>
  62. <text height-request="5"><label>""</label></text>
  63. <vbox space-expand="true" space-fill="true">
  64. <vbox space-expand="false" space-fill="false">
  65. <hbox>
  66. <text xalign="0" use-markup="true"><label>"<b>'$(gettext 'Personal File')'</b>: '$NAMEPFILE'"</label></text>
  67. <text space-expand="true" space-fill="true"><label>""</label></text>
  68. <pixmap><input file>/tmp/resizepfile_pfile.svg</input></pixmap>
  69. </hbox>
  70. <hbox>
  71. <text xalign="0" use-markup="true"><label>"<b>'$(gettext 'Partition')'</b>: '$SAVEPART'"</label></text>
  72. <text space-expand="true" space-fill="true"><label>""</label></text>
  73. <pixmap><input file>/tmp/resizepfile_partition.svg</input></pixmap>
  74. </hbox>
  75. </vbox>
  76. <text height-request="5" space-expand="true" space-fill="true"><label>""</label></text>
  77. <vbox space-expand="false" space-fill="false">
  78. <hbox space-expand="true" space-fill="true">
  79. <text xalign="0" space-expand="true" space-fill="true"><label>'$(eval_gettext "Increase size of \$NAMEPFILE by amount (Mb). You cannot make it smaller.")'</label></text>
  80. <comboboxtext width-request="100" space-expand="false" space-fill="false">
  81. <variable>KILOBIG</variable>
  82. <item>32</item>
  83. <item>64</item>
  84. <item>128</item>
  85. <item>256</item>
  86. <item>512</item>
  87. <item>1024</item>
  88. <item>2048</item>
  89. <item>4096</item>
  90. </comboboxtext>
  91. </hbox>
  92. </vbox>
  93. <text height-request="10"><label>""</label></text>
  94. </vbox>
  95. </frame>
  96. </vbox>
  97. <hbox space-expand="false" space-fill="false">
  98. '"`/usr/lib/gtkdialog/xml_pixmap nb`"'
  99. <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<b>'$(gettext 'Resizing requires a system reboot')'</b>"</label></text>
  100. <button space-expand="false" space-fill="false">
  101. <label>'$(gettext "Cancel")'</label>
  102. '"`/usr/lib/gtkdialog/xml_button-icon cancel`"'
  103. <action type="exit">EXIT_NOW</action>
  104. </button>
  105. <button space-expand="false" space-fill="false">
  106. <label>'$(gettext "Ok")'</label>
  107. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  108. <action type="exit">save</action>
  109. </button>
  110. </hbox>
  111. </vbox>
  112. </window>'
  113. export resize="$x"
  114. . /usr/lib/gtkdialog/xml_info gtk > /dev/null #build bg_pixmap for gtk-theme
  115. eval $(gtkdialog -p resize)
  116. case ${EXIT} in
  117. save)KILOBIG=$(($KILOBIG * 1024))
  118. echo "KILOBIG=$KILOBIG" > /initrd${PUP_HOME}/pupsaveresizenew.txt
  119. echo "PUPSAVEFILEX=$SAVEFILE" >> /initrd${PUP_HOME}/pupsaveresizenew.txt #131231
  120. ;;
  121. *)
  122. exit
  123. ;;
  124. esac
  125. /usr/lib/gtkdialog/box_ok "$(gettext 'Resize personal storage file')" complete "$(eval_gettext "Okay, you have chosen to <b>increase \${NAMEPFILE} by \${KILOBIG} Kbytes</b>, however as the file is currently in use, it will happen at reboot.")" " " "$(gettext 'Technical notes:')" "$(eval_gettext "The required size increase has been written to file pupsaveresizenew.txt, in partition \${SAVEPART} (currently mounted on /mnt/home).")" "$(gettext 'File pupsaveresizenew.txt will be read at bootup and the resize performed then pupsaveresizenew.txt will be deleted.')" "$(eval_gettext "WARNING: If you have multiple \${DISTRO_FILE_PREFIX}save files, be sure to select the same one when you reboot.")" " " "<b>$(gettext 'You can keep using Puppy. The change will only happen at reboot.')</b>"
  126. ###END###
  127. #notes:
  128. # dd if=/dev/zero bs=1k count=$KILOBIG | tee -a $HOMELOCATION > /dev/null