savesession-dvd 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2006 www.puppylinux.com
  3. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. #BK updated may 2007 for 2.16.
  5. #BK updated v2.22, sync with rc.shutdown multisession bugfix.
  6. #v3.01: BK 11 oct 2007, removed multisavefunc() to /etc/rc.d/functions4puppy.
  7. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  8. #v555 pup files renamed to woofr555.sfs, woofsave.2fs.
  9. #w482 use xorriso instead of cdrtools/cdrkit if installed.
  10. #120323 partial replace 'xmessage' with 'pupmessage'.
  11. #/etc/rc.d/rc.shutdown saves session at shutdown, savesession-dvd is called
  12. #from desktop icon to do an immediate save to multisession-cd.
  13. #w482 use xorriso if it is installed (see also functions4puppy)...
  14. CDRECORD='cdrecord'
  15. MKISOFS='mkisofs'
  16. if [ "`which xorriso`" != "" ];then
  17. CDRECORD='xorrecord'
  18. MKISOFS='xorrisofs' #growisofs reads this variable.
  19. fi
  20. export CDRECORD MKISOFS
  21. #variables created at bootup by /initrd/usr/sbin/init...
  22. . /etc/rc.d/PUPSTATE #v2.02
  23. . /etc/DISTRO_SPECS #v412
  24. ORIGPUPMODE=$PUPMODE #v2.22
  25. . /etc/rc.d/functions4puppy #v3.01 has multisavefunc.
  26. CONSRUN="$1" #will execute multisavefunc from a rxvt console.
  27. #...this script calls itself a second time, as multisavefunc uses dialog,
  28. # and runs without X.
  29. #also test if X not running...
  30. [ "`pidof X | grep '[0-9]'`" = "" ] && CONSRUN="yes"
  31. if [ ! "$PUPSAVE" = "" ];then
  32. SAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`" #f.s. and partition where ${DISTRO_FILE_PREFIX}save.2fs is located.
  33. SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`" # "
  34. SAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  35. else
  36. exit #v2.22
  37. fi
  38. CDR="/dev/$SAVEPART"
  39. if [ ! "$CONSRUN" = "" ];then
  40. multisavefunc
  41. exit
  42. fi
  43. if [ "$PUPMODE" != "77" ];then
  44. pupmessage -bg "red" -center -title "SaveSession-DVD" "Sorry, this is not a multisession live-CD/DVD"
  45. exit
  46. fi
  47. if [ "$CDR" = "" ];then
  48. pupmessage -bg "red" -center -title "SaveSession-DVD" "Sorry, this is not a multisession live-CD/DVD"
  49. exit
  50. fi
  51. #before can save a session back to DVD, have to be sure that DVD is unmounted...
  52. if [ "`mount | grep "$CDR"`" != "" ];then
  53. sync
  54. echo "Unmounting $CDR..."
  55. fuser -k -m $CDR
  56. sync
  57. umount $CDR
  58. if [ ! $? -eq 0 ];then
  59. pupmessage -bg "red" -center -title "SaveSession: ERROR" "Sorry, $CDR is currently mounted and cannot be automatically
  60. unmounted. You will need to unmount it manually.
  61. Click OK button to quit..."
  62. exit
  63. fi
  64. fi
  65. xmessage -bg "#ffc0c0" -center -title "SaveSession" -buttons "SAVE:10,CANCEL:11" "This program takes a snapshot of changed and new files and
  66. saves them to CD/DVD. For the multisession-CD/DVD, this happens
  67. at shutdown, however, if you are working on critical files and
  68. do not want to lose your work in case of a power-outage or
  69. system crash (latter very unlikely), this program is a solution
  70. -- just run it whenever you want to backup.
  71. WARNING: CDs have much less space than DVDs, and there is more
  72. wasted space in each saved session, meaning that a CD will fill
  73. up fast. Therefore, for CDs use this Save script infrequently.
  74. Click SAVE button to save session..."
  75. [ ! $? -eq 10 ] && exit
  76. #recursive execution...
  77. exec rxvt -e /usr/sbin/savesession-dvd yes
  78. ###END###