Guest User

refractasnapshot (Dec, 2019 release)

a guest
Nov 21st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.49 KB | None | 0 0
  1. excerpts extracted from
  2. refractasnapshot-base_10.2.10_all.deb (published Dec 2019)
  3. ____________________________________________________________
  4.  
  5. BOOT METHODS ((( page3 of the F1 liveboot menu )))
  6.  
  7. Methods list here must correspond to entries in your boot menu.
  8.  
  9. live
  10. Start the live system -- this is the default CD-ROM method.
  11. nox
  12. Boot to runlevel 3 (command-line-only in Refracta and some others)
  13. nomodeset
  14. This is useful for some sytems with nvidia graphics cards.
  15. toram
  16. Copy whole read-only media to RAM before mounting root filesystem.
  17. noprobe
  18. Failsafe boot method. (noapic noapm nodma nomce nolapic nosmp vga=normal)
  19. memtest
  20. Start memtest to scan your RAM for errors.
  21.  
  22. To use one of these boot methods, type it at the prompt, optionally
  23. followed by any boot parameters. For example:
  24. boot: live persistence acpi=off
  25.  
  26. You may:
  27. - press F1 to return to the help index
  28. - type menu and press ENTER to go back to the boot screen
  29. - press ENTER to boot
  30.  
  31. ____________________________________________________________
  32.  
  33.  
  34.  
  35. content of
  36. snapshot_excludes.list.defaults
  37.  
  38. # rsync excludes file for refractasnapshot and refractasnapshot-gui
  39. # version 9.3.4
  40.  
  41. # Exclude some system files. These are required, and you probably shouldn't change them.
  42. - /dev/*
  43. - /cdrom/*
  44. - /media/*
  45. - /swapfile
  46. - /mnt/*
  47. - /sys/*
  48. - /proc/*
  49. - /tmp/*
  50. - /live
  51. - /persistence.conf
  52. - /boot/grub/grub.cfg
  53. - /boot/grub/menu.lst
  54. - /boot/grub/device.map
  55. - /boot/*.bak
  56. - /boot/*.old-dkms
  57. - /etc/udev/rules.d/70-persistent-cd.rules
  58. - /etc/udev/rules.d/70-persistent-net.rules
  59. - /etc/fstab
  60. - /etc/fstab.d/*
  61. - /etc/mtab
  62. - /etc/blkid.tab
  63. - /etc/blkid.tab.old
  64. - /etc/apt/sources.list~
  65. - /etc/crypttab
  66. - /etc/initramfs-tools/conf.d/resume # see remove-cryptroot and nocrypt.sh
  67. - /etc/initramfs-tools/conf.d/cryptroot # see remove-cryptroot and nocrypt.sh
  68. - /etc/popularity-contest.conf
  69. - /home/snapshot
  70.  
  71. # Added for newer version of live-config/live-boot in wheezy
  72. # These are only relevant here if you create a snapshot while
  73. # you're running a live-CD or live-usb.
  74. - /lib/live/overlay
  75. - /lib/live/image
  76. - /lib/live/rootfs
  77. - /lib/live/mount
  78. - /run/*
  79.  
  80. # Added for symlink /lib
  81. - /usr/lib/live/overlay
  82. - /usr/lib/live/image
  83. - /usr/lib/live/rootfs
  84. - /usr/lib/live/mount
  85.  
  86. ## Entries below are optional. They are included either for privacy
  87. ## or to reduce the size of the snapshot. If you have any large
  88. ## files or directories, you should exclude them from being copied
  89. ## by adding them to this list.
  90. ##
  91. ## Entries beginning with /home/*/ will affect all users.
  92.  
  93.  
  94. # Uncomment this to exclude everything in /var/log/
  95. #- /var/log/*
  96.  
  97. # As of version 9.2.0, current log files are truncated,
  98. # and archived log files are excluded.
  99. #
  100. # The next three lines exclude everything in /var/log
  101. # except /var/log/clamav/ (or anything else beginning with "c") and
  102. # /var/log/gdm (or anything beginning with "g").
  103. # If clamav log files are excluded, freshclam will give errors at boot.
  104. #- /var/log/[a-b,A-Z]*
  105. #- /var/log/[d-f]*
  106. #- /var/log/[h-z]*
  107. #- /var/log/*gz
  108.  
  109. - /var/cache/apt/archives/*.deb
  110. - /var/cache/apt/pkgcache.bin
  111. - /var/cache/apt/srcpkgcache.bin
  112. - /var/cache/apt/apt-file/*
  113. - /var/cache/debconf/*~old
  114. - /var/lib/apt/lists/*
  115. - /var/lib/apt/*~
  116. - /var/lib/apt/cdroms.list
  117. - /var/lib/aptitude/*.old
  118. - /var/lib/dhcp/*
  119. - /var/lib/dpkg/*~old
  120. - /var/spool/mail/*
  121. - /var/mail/*
  122. - /var/backups/*.gz
  123. #- /var/backups/*.bak
  124. - /var/lib/dbus/machine-id
  125. - /var/lib/live/config/*
  126.  
  127. - /usr/share/icons/*/icon-theme.cache
  128.  
  129. - /root/.aptitude
  130. - /root/.bash_history
  131. - /root/.disk-manager.conf
  132. - /root/.fstab.log
  133. - /root/.lesshst
  134. - /root/*/.log
  135. - /root/.local/share/*
  136. - /root/.nano_history
  137. - /root/.synaptic
  138. - /root/.VirtualBox
  139. - /root/.ICEauthority
  140. - /root/.Xauthority
  141.  
  142.  
  143. - /root/.ssh
  144.  
  145. - /home/*/.Trash*
  146. - /home/*/.local/share/Trash/*
  147. - /home/*/.mozilla/*/Cache/*
  148. - /home/*/.mozilla/*/urlclassifier3.sqlite
  149. - /home/*/.mozilla/*/places.sqlite
  150. - /home/*/.mozilla/*/cookies.sqlite
  151. - /home/*/.mozilla/*/signons.sqlite
  152. - /home/*/.mozilla/*/formhistory.sqlite
  153. - /home/*/.mozilla/*/downloads.sqlite
  154. - /home/*/.adobe
  155. - /home/*/.aptitude
  156. - /home/*/.bash_history
  157. - /home/*/.cache
  158. - /home/*/.dbus
  159. - /home/*/.gksu*
  160. - /home/*/.gvfs
  161. - /home/*/.lesshst
  162. - /home/*/.log
  163. - /home/*/.macromedia
  164. - /home/*/.nano_history
  165. - /home/*/.pulse*
  166. - /home/*/.recently-used
  167. - /home/*/.recently-used.xbel
  168. - /home/*/.local/share/recently-used.xbel
  169. - /home/*/.thumbnails/large/*
  170. - /home/*/.thumbnails/normal/*
  171. - /home/*/.thumbnails/fail/*
  172. - /home/*/.vbox*
  173. - /home/*/.VirtualBox
  174. - /home/*/VirtualBox\ VMs
  175. #- /home/*/.wine
  176. - /home/*/.xsession-errors*
  177. - /home/*/.ICEauthority
  178. - /home/*/.Xauthority
  179.  
  180. # You might want to comment these out if you're making a snapshot for
  181. # your own personal use, not to be shared with others.
  182. - /home/*/.gnupg
  183. - /home/*/.ssh
  184. - /home/*/.xchat2
  185. - /home/*/.config/hexchat
  186.  
  187. # Exclude ssh_host_keys. New ones will be generated upon live boot.
  188. # This fixes a security hole in all versions before 9.0.9-3.
  189. # If you really want to clone your existing ssh host keys
  190. # in your snapshot, comment out these two lines.
  191. - /etc/ssh/ssh_host_*_key*
  192. - /etc/ssh/ssh_host_key*
  193.  
  194. # Examples of things to exclude in order to keep the image small:
  195. #- /home/fred/Downloads/*
  196. #- /home/*/Music/*
  197. #- /home/user/Pictures/*
  198. #- /home/*/Videos/*
  199.  
  200.  
  201. # To exclude all hidden files and directories in your home, uncomment
  202. # the next line. You will lose custom desktop configs if you do.
  203. #- /home/*/.[a-z,A-Z,0-9]*
  204.  
  205. ____________________________________________
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. content of installed file /usr/bin/refractasnapshot
  213.  
  214. #!/usr/bin/env bash
  215. version="refractasnapshot-10.2.10 (20191218)"
  216. TEXTDOMAIN=refractasnapshot-base
  217. TEXTDOMAINDIR=/usr/share/locale/
  218.  
  219. # Copyright: [email protected] 2011-2019
  220. # based on refractasnapshot-8.0.4 by Dean Linkous with ideas
  221. # borrowed from dzsnapshot-gui.sh by David Hare, which was based on an
  222. # earlier version of this script.
  223. # UEFI code adapted from similar scripts by Colin Watson and Patrick J. Volkerding
  224. #
  225. # License: GPL-3
  226. # This is free software with NO WARRANTY. Use at your own risk!
  227. #
  228. # DESCRIPTION
  229. # This script makes a copy of your system with rsync and then creates
  230. # an iso file to be used as a live-cd. There are options in the config
  231. # file to change the location of the copy and the location of the final
  232. # iso file, in case there's not enough room on the system drive. Read
  233. # the config file for more options. (/etc/refractasnapshot.conf)
  234. #
  235. #
  236. #
  237. # If you want to change any defaults, change them in the configfile.
  238. # Default is /etc/refractasnapshot.conf
  239. # If you want to use a different config file for testing,
  240. # either change this variable here or use the -c, --config option on
  241. # the command-line. (Command-line option will supercede this setting.)
  242. # Normally, users should not edit anything in this script.
  243. #
  244. configfile="/etc/refractasnapshot.conf"
  245.  
  246.  
  247. show_help () {
  248. printf "$help_text"
  249. exit 0
  250. }
  251.  
  252.  
  253. help_text=$"
  254. Usage: $0 [option]
  255.  
  256. Run with no options to create .iso file for a live, bootable CD
  257. or DVD copy of the running system.
  258.  
  259. valid options:
  260. -h, --help show this help text
  261. -v, --version display the version information
  262. -d. --debug debug mode
  263. -c, --config specify a different config file
  264. (file name must be next argument)
  265.  
  266. example:
  267. refractasnapshot -n -c myconfigs
  268.  
  269. *** See $configfile for information about settings.
  270.  
  271. "
  272. while [[ $1 == -* ]]; do
  273. case "$1" in
  274. -h|--help)
  275. show_help ;;
  276.  
  277. -v|--version)
  278. printf "\n$version\n\n"
  279. exit 0 ;;
  280.  
  281. -c|--config)
  282. shift
  283. configfile="$1"
  284. printf "\n config file is $configfile\n\n"
  285. shift
  286. ;;
  287.  
  288. -d|--debug)
  289. DEBUG="yes"
  290. shift ;;
  291.  
  292. *)
  293. printf "\t invalid option: $1 \n\n"
  294. printf "\t Try: $0 -h for full help. \n\n"
  295. exit 1 ;;
  296. esac
  297. done
  298.  
  299. # Check that user is root
  300. [[ $(id -u) -eq 0 ]] || { echo -e "\n\t You need to be root!\n" ; exit 1 ; }
  301.  
  302. [[ -e "$configfile" ]] || { echo "Configuration file, $configfile is missing." ; exit 1 ; }
  303.  
  304. # Fix root's path (for Buster/Beowulf and later)
  305. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  306.  
  307. source "$configfile"
  308.  
  309. # Record errors in a logfile.
  310. exec 2>"$error_log"
  311.  
  312. if [[ $DEBUG = "yes" ]] ; then
  313. set -x
  314. fi
  315.  
  316. echo "configfile is $configfile"
  317. echo "make_efi is $make_efi"
  318.  
  319. # Check for grub-efi
  320. check_grub () {
  321. if [[ $make_efi = "yes" ]] ; then
  322. if ! (dpkg -l | grep "^ii" | grep "grub-efi-amd64" |grep -v "bin"); then
  323. echo $"grub-efi-amd64 is not installed"
  324. grub_message=$"Warning: grub-efi-amd64 is not installed. The snapshot may not be compatible with UEFI.
  325. To disable this warning, set make_efi=no in $configfile or set force_efi=yes for special use.
  326. "
  327. if [[ $force_efi = "yes" ]] ; then
  328. make_efi="yes"
  329. else
  330. make_efi="no"
  331. fi
  332. echo "force_efi is $force_efi"
  333. echo "make_efi is $make_efi"
  334. fi
  335. if [[ ! -e /var/lib/dpkg/info/dosfstools.list ]] ; then
  336. echo $"dosfstools is not installed"
  337. dosfstools_message=$"Warning: dosfstools is not installed. Your snapshot will not boot in uefi mode."
  338. force_efi="no"
  339. make_efi="no"
  340. echo "force_efi is $force_efi"
  341. echo "make_efi is $make_efi"
  342. fi
  343. fi
  344. }
  345.  
  346.  
  347. show_snapshot_help () {
  348. zless "$snapshot_help"
  349. choose_task
  350. }
  351.  
  352.  
  353. find_text_editor () {
  354. # Default text editor is nano. Make sure it exists if user intends to ### This needs attention!!! <<<<<<<<<
  355. # edit files before squashing the filesystem.
  356. #if [[ $edit_boot_menu = "yes" ]] ; then
  357. [[ -e $text_editor ]] || { echo -e $"\n Error! The text editor is set to ${text_editor},
  358. but it is not installed. Edit $configfile
  359. and set the text_editor variable to the editor of your choice.
  360. (examples: /usr/bin/vim, /usr/bin/joe)\n" ; exit 1 ; }
  361. #fi
  362. }
  363.  
  364.  
  365. unpatch_init () {
  366. # Check for previous patch
  367. if $(grep -q nuke "$target_file") ; then
  368. echo $"
  369. It looks like $target_file was previously patched by an
  370. earlier version of refractasnapshot. This patch is no longer needed.
  371. You can comment out the added lines as shown below (or remove the
  372. commented lines) and then run 'update-initramfs -u'.
  373.  
  374. If you don't want to do that, dont worry;
  375. it won't hurt anything if you leave it the way it is.
  376.  
  377. Do not change or remove the lines that begin with \"mount\"
  378.  
  379. mount -n -o move /sys ${rootmnt}/sys
  380. #nuke /sys
  381. #ln -s ${rootmnt}/sys /sys
  382. mount -n -o move /proc ${rootmnt}/proc
  383. #nuke /proc
  384. #ln -s ${rootmnt}/proc /proc
  385. "
  386.  
  387. while true ; do
  388. echo $"Open $target_file in an editor? (y/N)"
  389. read ans
  390. case $ans in
  391. [Yy]*) "$text_editor" "$target_file"
  392. update-initramfs -u
  393. break ;;
  394. *) break ;;
  395. esac
  396. done
  397.  
  398. echo -e $"\n Wait for the disk report to complete...\n\n"
  399.  
  400. fi
  401. }
  402.  
  403.  
  404. check_copies () {
  405. # Function to check for old snapshots and filesystem copy and their total size
  406. if [[ -d $snapshot_dir ]]; then
  407. if ls "$snapshot_dir"/*.iso > /dev/null ; then
  408. snapshot_count=$(ls "$snapshot_dir"/*.iso | wc -l)
  409. else
  410. snapshot_count="0"
  411. fi
  412. snapshot_size=$(du -sh "$snapshot_dir" | awk '{print $1}')
  413. if [[ -z $snapshot_size ]]; then
  414. snapshot_size="0 bytes"
  415. fi
  416. else
  417. snapshot_count="0"
  418. snapshot_size="0 bytes"
  419. fi
  420.  
  421. # Check for saved copy of the system
  422. if [[ -d "$work_dir"/myfs ]]; then
  423. saved_size=$(du -sh "$work_dir"/myfs | awk '{ print $1 }')
  424. saved_copy=$(echo $"* You have a saved copy of the system using $saved_size of space
  425. located at $work_dir/myfs.")
  426. fi
  427.  
  428. # Create a message to say whether the filesystem copy will be saved or not.
  429. if [[ $save_work = "yes" ]]; then
  430. save_message=$(echo $"* The temporary copy of the filesystem will be saved
  431. at $work_dir/myfs.")
  432. else
  433. save_message=$(echo $"* The temporary copy of the filesystem will be created
  434. at $work_dir/myfs and removed when this program finishes.")
  435. fi
  436. }
  437.  
  438.  
  439. check_directories () {
  440. # Create snapshot_dir and work_dir if necessary
  441.  
  442. # Don't use /media/* for $snapshot_dir or $work_dir unless it is a mounted filesystem
  443. snapdir_is_remote=$(echo ${snapshot_dir} | awk -F / '{ print "/" $2 "/" $3 }' | grep /media/)
  444. workdir_is_remote=$(echo ${work_dir} | awk -F / '{ print "/" $2 "/" $3 }' | grep /media/)
  445.  
  446. if [ -n "$snapdir_is_remote" ] && cat /proc/mounts | grep -q ${snapdir_is_remote}; then
  447. echo "$snapshot_dir is mounted"
  448. elif [ -n "$snapdir_is_remote" ] ; then
  449. echo $" Error.. The selected snapshot directory cannot be accessed. Do you need to mount it?"
  450. exit 1
  451. fi
  452.  
  453. if [ -n "$workdir_is_remote" ] && cat /proc/mounts | grep -q ${workdir_is_remote}; then
  454. echo "$work_dir is mounted"
  455. elif [ -n "$workdir_is_remote" ] ; then
  456. echo $" Error.. The selected work directory cannot be accessed. Do you need to mount it?"
  457. exit 1
  458. fi
  459.  
  460.  
  461. # Check that snapshot_dir exists
  462. if ! [[ -d $snapshot_dir ]]; then
  463. mkdir -p "$snapshot_dir"
  464. chmod 777 "$snapshot_dir"
  465. fi
  466.  
  467. # Check that work directories exist or create them
  468. if [[ $save_work = "no" ]]; then
  469. if [[ -d $work_dir ]]; then
  470. rm -rf "$work_dir"
  471. fi
  472. mkdir -p "$work_dir"/iso
  473. mkdir -p "$work_dir"/myfs
  474. elif [[ $save_work = "yes" ]]; then
  475. if ! [[ -d $work_dir ]]; then
  476. mkdir -p "$work_dir"/iso
  477. mkdir -p "$work_dir"/myfs
  478. fi
  479. fi
  480. }
  481.  
  482.  
  483. check_space () {
  484. # Check disk space on mounted /, /home, /media, /mnt, /tmp
  485. disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }')
  486. }
  487.  
  488.  
  489. # Check initrd for cryptroot, resume, cryptsetup.
  490. check_initrd () {
  491. if lsinitramfs "$initrd_image" | grep -q conf.d/cryptroot ; then
  492. remove_cryptroot="yes"
  493. cryptroot_message="The snapshot initrd will be modified to allow booting the unencrypted snapshot."
  494. elif lsinitramfs "$initrd_image" | grep -q cryptroot/crypttab ; then
  495. remove_cryptroot="yes"
  496. cryptroot_message="The snapshot initrd will be modified to allow booting the unencrypted snapshot."
  497. fi
  498. if lsinitramfs "$initrd_image" | egrep -q 'conf.d/resume|conf.d/zz-resume-auto' ; then
  499. remove_resume="yes"
  500. swap_message="The snapshot initrd will be modified to allow booting without the host's swap partition."
  501. fi
  502. if [ "$initrd_crypt" = yes ] ; then
  503. if lsinitramfs "$initrd_image" | grep -q cryptsetup ; then
  504. crypt_message="The host initrd already allows live-usb encrypted persistence. No change is needed."
  505. initrd_crypt="no"
  506. else
  507. crypt_message="The host initrd will be modified to allow live-usb encrypted persistence.
  508. A backup copy will be made at ${initrd_image}_pre-snapshot. (Does not apply to any re-run tasks.)"
  509. fi
  510. fi
  511. }
  512.  
  513.  
  514. extract_initrd () {
  515. mkdir /tmp/extracted
  516. pushd /tmp/extracted
  517.  
  518. COMPRESSION=$(file -L "$initrd_image" | egrep -o 'gzip compressed|XZ compressed|cpio archive')
  519.  
  520. if [ "$COMPRESSION" = "gzip compressed" ]; then
  521. echo "Archive is gzip compressed..."
  522. zcat "$initrd_image" | cpio -i
  523.  
  524. elif [ "$COMPRESSION" = "XZ compressed" ]; then
  525. echo "Archive is XZ compressed..."
  526. xzcat "$initrd_image" | cpio -d -i -m
  527.  
  528. elif [ "$COMPRESSION" = "cpio archive" ]; then
  529. echo "Archive is cpio archive..."
  530. (cpio -i ; zcat | cpio -i) < "$initrd_image"
  531. exit_code="$?"
  532. if [ "$exit_code" -ne 0 ] ; then
  533. (cpio -i ; xzcat | cpio -i) < "$initrd_image"
  534. exit_code="$?"
  535. if [ "$exit_code" -ne 0 ] ; then
  536. echo "Decompression error" && exit 1
  537. else
  538. COMPRESSION="XZ compressed"
  539. fi
  540. else
  541. COMPRESSION="gzip compressed"
  542. fi
  543.  
  544. echo "COMPRESSION is $COMPRESSION"
  545.  
  546. else
  547. echo "Decompession error..." && exit 1
  548. fi
  549.  
  550. popd
  551. echo "Initrd is extracted"
  552. }
  553.  
  554. edit_initrd () {
  555. pushd /tmp/extracted
  556.  
  557. if [ -f conf/conf.d/cryptroot ] ; then
  558. echo "Removing cryptroot"
  559. rm -f conf/conf.d/cryptroot
  560. elif [ -f cryptroot/crypttab ] ; then
  561. echo "Removing crypttab"
  562. rm -f cryptroot/crypttab
  563. fi
  564.  
  565. if [ -f conf/conf.d/resume ] ; then
  566. echo "Removing resume"
  567. rm -f conf/conf.d/resume
  568. rm -f "$work_dir"/myfs/etc/initramfs-tools/conf.d/resume
  569. elif [ -f conf/conf.d/zz-resume-auto ] ; then
  570. echo "Removing resume"
  571. rm -f conf/conf.d/zz-resume-auto
  572. rm -f "$work_dir"/myfs/etc/initramfs-tools/conf.d/resume
  573. fi
  574. popd
  575. }
  576.  
  577. rebuild_initrd () {
  578. pushd /tmp/extracted
  579.  
  580. if [ "$COMPRESSION" = "gzip compressed" ] ; then
  581. find . -print0 | cpio -0 -H newc -o | gzip -c > ${work_dir}/iso/live/${initrd_image##*/}
  582. elif [ "$COMPRESSION" = "XZ compressed" ] ; then
  583. find . | cpio -o -H newc | xz --check=crc32 --x86 --lzma2=dict=512KiB > ${work_dir}/iso/live/${initrd_image##*/}
  584. else
  585. echo "Compression error..."
  586. exit 1
  587. fi
  588.  
  589. popd
  590. rm -rf /tmp/extracted
  591. }
  592.  
  593.  
  594. clean_initrd () {
  595. extract_initrd
  596. edit_initrd
  597. rebuild_initrd
  598. }
  599.  
  600.  
  601. report_space () {
  602. # Show current settings and disk space
  603.  
  604. if [[ -f "/usr/bin/less" ]] ; then
  605. pager="/usr/bin/less"
  606. else
  607. pager="/bin/more"
  608. fi
  609.  
  610. echo $"
  611. You will need plenty of free space. It is recommended that free space
  612. (Avail) in the partition that holds the work directory (probably \"/\")
  613. should be two times the total installed system size (Used). You can
  614. deduct the space taken up by previous snapshots and any saved copies of
  615. the system from the Used amount.
  616.  
  617. ${grub_message}
  618. ${dosfstools_message}
  619.  
  620. * You have $snapshot_count snapshots taking up $snapshot_size of disk space.
  621. $saved_copy
  622. $save_message
  623. * The snapshot directory is currently set to $snapshot_dir
  624. $tmp_warning
  625.  
  626. You can change these and other settings by editing
  627. $configfile.
  628.  
  629. Turn off NUM LOCK for some laptops.
  630.  
  631. ${crypt_message}
  632. ${cryptroot_message}
  633. ${swap_message}
  634.  
  635. Current disk usage:
  636. (For complete listing, exit and run 'df -h')
  637.  
  638. $disk_space
  639.  
  640. To proceed, press q.
  641. To exit, press q and then press ctrl-c
  642. " | "$pager"
  643. }
  644.  
  645. choose_task () {
  646. if [[ $make_efi = "yes" ]] ; then
  647. uefi_message=$"uefi enabled"
  648. else
  649. uefi_message=$"uefi disabled"
  650. fi
  651.  
  652. while true; do
  653. echo $"
  654. Choose a task.
  655.  
  656. 1. Create a snapshot ($uefi_message)
  657. 2. Re-squash and make iso (no-copy)
  658. 3. Re-make efi files and iso (no-copy, no-squash)
  659. 4. Re-run xorriso only. (make iso, no-copy, no-squash)
  660. 5. Help
  661. 6. Exit
  662. "
  663. read ans
  664. case $ans in
  665. 1) # Create snapshot
  666.  
  667. echo $"This may take a moment while the program checks for free space. "
  668. check_copies
  669. check_directories
  670. check_space
  671. check_initrd
  672. report_space
  673.  
  674. set_distro_name
  675. housekeeping
  676.  
  677. if [[ $initrd_crypt = "yes" ]] ; then
  678. prepare_initrd_crypt
  679. fi
  680.  
  681. # The real work starts here 01
  682. cd "$work_dir"
  683. copy_isolinux
  684. copy_kernel
  685. copy_filesystem
  686. if [ "$remove_cryptroot" = yes ] || [ "$remove_resume" = yes ] ; then
  687. clean_initrd
  688. fi
  689. edit_system
  690. get_filename
  691.  
  692. if [[ $make_efi = "yes" ]] ; then
  693. mkefi
  694. fi
  695.  
  696. add_extras
  697. set_boot_options
  698.  
  699. if [[ $edit_boot_menu = "yes" ]] ; then
  700. edit_boot_menus
  701. fi
  702.  
  703. squash_filesystem
  704. make_iso_fs
  705. cleanup
  706. final_message
  707.  
  708. exit 0 ;;
  709.  
  710. 2) # Re-squash
  711. if [[ $make_efi = "yes" ]] ; then
  712. uefi_opt="-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot"
  713. fi
  714. # The real work starts here 02
  715. cd "$work_dir"
  716. get_filename
  717. squash_filesystem
  718. make_iso_fs
  719. final_message
  720. exit 0 ;;
  721.  
  722. 3) # Re-make efi
  723. # The real work starts here 03
  724. [[ $make_efi = "yes" ]] || exit 1
  725. cd "$work_dir"
  726. get_filename
  727. set_distro_name
  728. mkefi
  729. set_boot_options
  730. find_editor
  731. edit_boot_menus
  732. make_iso_fs
  733. final_message
  734. exit 0 ;;
  735.  
  736. 4) # Re-make iso
  737. # The real work starts here 04
  738. if [[ $make_efi = "yes" ]] ; then
  739. uefi_opt="-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot"
  740. fi
  741. cd "$work_dir"
  742. get_filename
  743. make_iso_fs
  744. final_message
  745. exit 0 ;;
  746.  
  747. 5) show_snapshot_help ;;
  748.  
  749. [6qQxX]) exit 0 ;;
  750.  
  751. esac
  752. done
  753. }
  754.  
  755.  
  756. set_distro_name () {
  757. if [[ $iso_dir = "/usr/lib/refractasnapshot/iso" ]] && [[ $boot_menu = "live.cfg" ]] ; then
  758. DISTRO=$(lsb_release -i -s 2>/dev/null)
  759.  
  760. if $(grep -q Refracta /etc/issue) ; then
  761. DISTRO="Refracta"
  762. fi
  763.  
  764. while true ; do
  765. echo $"
  766. This is the distribution name that will appear in the boot menu for the
  767. live image. You can change it to something else, or you can blank this,
  768. and the the menu entries will just say \"GNU/Linux <kernel-version>\"
  769. "
  770. # # Redirect stderr from the error log to the screen,
  771. # # so we can see the prompts from read.
  772. exec 2>&1
  773. read -p $" Enter, erase or change distro name: " -i "$DISTRO" -e answer
  774. # # Resume logging errors.
  775. exec 2>>"$error_log"
  776. break
  777. done
  778.  
  779. if [[ -z "$answer" ]] ; then
  780. DISTRO="GNU/Linux `uname -r`"
  781. else
  782. DISTRO="$answer"
  783. fi
  784. fi
  785. }
  786.  
  787.  
  788. housekeeping () {
  789. # Test for systemd, util-linux version and patch intramfs-tools/init.
  790. if [[ $patch_init_nosystemd = "yes" ]] ; then
  791. utillinux_version=$(dpkg -l util-linux | awk '/util-linux/ { print $3 }' | cut -d. -f2)
  792. target_file="/usr/share/initramfs-tools/init"
  793. # patch_file="/usr/lib/refractasnapshot/init_for_util-lin.patch"
  794.  
  795. if [[ ! -h /sbin/init ]] ; then
  796. if [[ $utillinux_version -ge 25 ]] ; then
  797. unpatch_init
  798. fi
  799. fi
  800. fi
  801.  
  802. # Use the login name set in the config file. If not set, use the primary
  803. # user's name. If the name is not "user" then add boot option. ALso use
  804. # the same username for cleaning geany history.
  805.  
  806. if [[ -n "$username" ]] ; then
  807. username_opt="username=$username"
  808. else
  809. username=$(awk -F":" '/1000:1000/ { print $1 }' /etc/passwd)
  810. if [[ $username != user ]] ; then
  811. username_opt="username=$username"
  812. fi
  813. fi
  814.  
  815. # Check that kernel and initrd exist
  816. [[ -e "$kernel_image" ]] || kernel_message=" Warning: Kernel image is missing. "
  817. [[ -e "$initrd_image" ]] || initrd_message=" Warning: initrd image is missing. "
  818. if [[ -n "$kernel_message" ]] || [[ -n "$initrd_message" ]] ; then
  819. echo $"
  820. $kernel_message
  821. $initrd_message
  822.  
  823. Make sure the kernel_image and/or initrd_image
  824. set in the config file are correct, and check
  825. that the boot menu is also correct.
  826. "
  827. exit 1
  828. fi
  829.  
  830. # update the mlocate database
  831. if [[ $update_mlocate = "yes" ]]; then
  832. echo -e $"\nRunning updatedb...\n"
  833. updatedb
  834. fi
  835. }
  836.  
  837.  
  838. prepare_initrd_crypt () {
  839. # Prepare initrd to use encryption
  840. # This is only going to work if the latest kernel version is running.
  841. # (i.e. the one linked from /initrd.img)
  842. # Add '-k all' or specify the initrd to use???
  843.  
  844. cp "$initrd_image" "${initrd_image}_pre-snapshot"
  845. sed -i 's/.*CRYPTSETUP=.*/CRYPTSETUP=y/' /etc/cryptsetup-initramfs/conf-hook
  846.  
  847. if [[ -f /usr/sbin/update-initramfs.orig.initramfs-tools ]] ; then
  848. /usr/sbin/update-initramfs.orig.initramfs-tools -u
  849. else
  850. /usr/sbin/update-initramfs -u
  851. fi
  852. }
  853.  
  854.  
  855. copy_isolinux () {
  856. if [[ -f /usr/lib/ISOLINUX/isolinux.bin ]] ; then
  857. isolinuxbin="/usr/lib/ISOLINUX/isolinux.bin"
  858. elif [[ -f /usr/lib/syslinux/isolinux.bin ]] ; then
  859. isolinuxbin="/usr/lib/syslinux/isolinux.bin"
  860. else
  861. echo $"You need to install the isolinux package."
  862. exit 1
  863. fi
  864.  
  865. # @@@@ Warning: This will replace these files in custom iso_dir @@@@@
  866. if [[ -f /usr/lib/syslinux/modules/bios/vesamenu.c32 ]] ; then
  867. vesamenu="/usr/lib/syslinux/modules/bios/vesamenu.c32"
  868. rsync -a /usr/lib/syslinux/modules/bios/chain.c32 "$iso_dir"/isolinux/
  869. rsync -a /usr/lib/syslinux/modules/bios/ldlinux.c32 "$iso_dir"/isolinux/
  870. rsync -a /usr/lib/syslinux/modules/bios/libcom32.c32 "$iso_dir"/isolinux/
  871. rsync -a /usr/lib/syslinux/modules/bios/libutil.c32 "$iso_dir"/isolinux/
  872. else
  873. vesamenu="/usr/lib/syslinux/vesamenu.c32"
  874. fi
  875. rsync -a "$isolinuxbin" "$iso_dir"/isolinux/
  876. rsync -a "$vesamenu" "$iso_dir"/isolinux/
  877.  
  878. # Add Refracta-specific boot help files
  879. if [[ $refracta_boot_help = "yes" ]] ; then
  880. cp -a /usr/lib/refractasnapshot/boot_help/* "$iso_dir"/isolinux/
  881. fi
  882. }
  883.  
  884. # Let iso/, vmlinuz and initrd.img get copied, even if work_dir was saved,
  885. # in case they have changed.
  886.  
  887. copy_kernel () {
  888. rsync -a "$iso_dir"/ "$work_dir"/iso/
  889. cp "$kernel_image" "$work_dir"/iso/live/
  890. cp "$initrd_image" "$work_dir"/iso/live/
  891. }
  892.  
  893.  
  894. copy_filesystem () {
  895. if [[ $limit_cpu = "yes" ]] ; then
  896. [[ $(type -p cpulimit) ]] || \
  897. while true ; do
  898. echo -n $"
  899. The cpulimit program is not installed. Your CPU will not be limited.
  900. Would you like to continue anyway? (y/N)
  901. "
  902. read ans
  903. case $ans in
  904. [Yy]*) break ;;
  905. *) exit 0 ;;
  906. esac
  907. done
  908. cpulimit -e rsync -l "$limit" &
  909. pid="$!"
  910. fi
  911. rsync -av / myfs/ ${rsync_option1} ${rsync_option2} ${rsync_option3} \
  912. --exclude="$work_dir" --exclude="$snapshot_dir" --exclude="$efi_work" --exclude-from="$snapshot_excludes"
  913. if [[ -n "$pid" ]] ; then
  914. kill "$pid"
  915. fi
  916. }
  917.  
  918.  
  919. edit_system () {
  920. # Truncate logs, remove archived logs.
  921. find myfs/var/log -name "*gz" -print0 | xargs -0r rm -f
  922. find myfs/var/log/ -type f -exec truncate -s 0 {} \;
  923.  
  924. # Allow all fixed drives to be mounted with pmount
  925. if [[ $pmount_fixed = "yes" ]] ; then
  926. if [[ -f "$work_dir"/myfs/etc/pmount.allow ]]; then
  927. sed -i 's:#/dev/sd\[a-z\]:/dev/sd\[a-z\]:' "$work_dir"/myfs/etc/pmount.allow
  928. fi
  929. fi
  930.  
  931. # Clear list of recently used files in geany for primary user.
  932. if [[ $clear_geany = "yes" ]] ; then
  933. sed -i 's/recent_files=.*;/recent_files=/' "$work_dir"/myfs/home/"$username"/.config/geany/geany.conf
  934. fi
  935.  
  936. # Enable or disable password login through ssh for users (not root)
  937. # Remove obsolete live-config file
  938. if [[ -e "$work_dir"/myfs/lib/live/config/1161-openssh-server ]] ; then
  939. rm -f "$work_dir"/myfs/lib/live/config/1161-openssh-server
  940. fi
  941.  
  942. sed -i 's/PermitRootLogin yes/PermitRootLogin prohibit-password/' "$work_dir"/myfs/etc/ssh/sshd_config
  943.  
  944. if [[ $ssh_pass = "yes" ]] ; then
  945. sed -i 's|.*PasswordAuthentication.*no|PasswordAuthentication yes|' "$work_dir"/myfs/etc/ssh/sshd_config
  946. # sed -i 's|#.*PasswordAuthentication.*yes|PasswordAuthentication yes|' "$work_dir"/myfs/etc/ssh/sshd_config
  947. elif [[ $ssh_pass = "no" ]] ; then
  948. sed -i 's|.*PasswordAuthentication.*yes|PasswordAuthentication no|' "$work_dir"/myfs/etc/ssh/sshd_config
  949. fi
  950.  
  951. # /etc/fstab should exist, even if it's empty,
  952. # to prevent error messages at boot
  953. touch "$work_dir"/myfs/etc/fstab
  954.  
  955. # Blank out systemd machine id. If it does not exist, systemd-journald
  956. # will fail, but if it exists and is empty, systemd will automatically
  957. # set up a new unique ID.
  958.  
  959. if [ -e "$work_dir"/myfs/etc/machine-id ]
  960. then
  961. rm -f "$work_dir"/myfs/etc/machine-id
  962. : > "$work_dir"/myfs/etc/machine-id
  963. fi
  964.  
  965. # add some basic files to /dev
  966. mknod -m 622 "$work_dir"/myfs/dev/console c 5 1
  967. mknod -m 666 "$work_dir"/myfs/dev/null c 1 3
  968. mknod -m 666 "$work_dir"/myfs/dev/zero c 1 5
  969. mknod -m 666 "$work_dir"/myfs/dev/ptmx c 5 2
  970. mknod -m 666 "$work_dir"/myfs/dev/tty c 5 0
  971. mknod -m 444 "$work_dir"/myfs/dev/random c 1 8
  972. mknod -m 444 "$work_dir"/myfs/dev/urandom c 1 9
  973. chown -v root:tty "$work_dir"/myfs/dev/{console,ptmx,tty}
  974.  
  975. ln -sv /proc/self/fd "$work_dir"/myfs/dev/fd
  976. ln -sv /proc/self/fd/0 "$work_dir"/myfs/dev/stdin
  977. ln -sv /proc/self/fd/1 "$work_dir"/myfs/dev/stdout
  978. ln -sv /proc/self/fd/2 "$work_dir"/myfs/dev/stderr
  979. ln -sv /proc/kcore "$work_dir"/myfs/dev/core
  980. mkdir -v "$work_dir"/myfs/dev/shm
  981. mkdir -v "$work_dir"/myfs/dev/pts
  982. chmod 1777 "$work_dir"/myfs/dev/shm
  983.  
  984. # Clear configs from /etc/network/interfaces, wicd and NetworkManager
  985. # and netman, so they aren't stealthily included in the snapshot.
  986. if [[ -z $netconfig_opt ]] ; then
  987. echo "# The loopback network interface
  988. auto lo
  989. iface lo inet loopback
  990. " > "$work_dir"/myfs/etc/network/interfaces
  991. rm -f "$work_dir"/myfs/var/lib/wicd/configurations/*
  992. rm -f "$work_dir"/myfs/etc/wicd/wireless-settings.conf
  993. rm -f "$work_dir"/myfs/etc/NetworkManager/system-connections/*
  994. rm -f "$work_dir"/myfs/etc/network/wifi/*
  995. fi
  996. }
  997.  
  998.  
  999. get_filename () {
  1000. # Need to define $filename here (moved up from genisoimage)
  1001. # and use it as directory name to identify the build on the cdrom.
  1002. # and put package list inside that directory
  1003. if [[ $stamp = "datetime" ]]; then
  1004. # use this variable so iso and sha256 have same time stamp
  1005. filename="$snapshot_basename"-$(date +%Y%m%d_%H%M).iso
  1006. else
  1007. n=1
  1008. while [[ -f "$snapshot_dir"/snapshot$n.iso ]]; do
  1009. ((n++))
  1010. done
  1011. filename="$snapshot_basename"$n.iso
  1012. fi
  1013. }
  1014.  
  1015.  
  1016. # create /boot and /efi for uefi.
  1017. mkefi () {
  1018. uefi_opt="-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot"
  1019.  
  1020. #################################
  1021. tempdir="$(mktemp -d /tmp/work_temp.XXXX)"
  1022.  
  1023. # for initial grub.cfg
  1024. mkdir -p "$tempdir"/boot/grub
  1025.  
  1026.  
  1027. cat >"$tempdir"/boot/grub/grub.cfg <<EOF
  1028. search --file --set=root /isolinux/isolinux.cfg
  1029. set prefix=(\$root)/boot/grub
  1030. source \$prefix/x86_64-efi/grub.cfg
  1031. EOF
  1032. #################################
  1033. if ! [ -d "$efi_work" ] ; then
  1034. mkdir "$efi_work"
  1035. fi
  1036.  
  1037. pushd "$efi_work"
  1038.  
  1039. # start with empty directories.
  1040.  
  1041. if [ -d "boot" ] ; then
  1042. rm -rf boot
  1043. fi
  1044.  
  1045. if [ -d "efi" ] ; then
  1046. rm -rf efi
  1047. fi
  1048.  
  1049. mkdir -p boot/grub/x86_64-efi
  1050. mkdir -p efi/boot
  1051.  
  1052. # copy splash
  1053. cp "$iso_dir"/isolinux/splash.png boot/grub/splash.png
  1054.  
  1055. # second grub.cfg file
  1056. for i in $(ls /usr/lib/grub/x86_64-efi|grep part_|grep \.mod|sed 's/.mod//'); do echo "insmod $i" >> boot/grub/x86_64-efi/grub.cfg; done
  1057. # Additional modules so we don't boot in blind mode. I don't know which ones are really needed.
  1058. for i in efi_gop efi_uga ieee1275_fb vbe vga video_bochs video_cirrus jpeg png gfxterm ; do echo "insmod $i" >> boot/grub/x86_64-efi/grub.cfg ; done
  1059.  
  1060. echo "source /boot/grub/grub.cfg" >> boot/grub/x86_64-efi/grub.cfg
  1061. pushd "$tempdir"
  1062. # make a tarred "memdisk" to embed in the grub image
  1063. tar -cvf memdisk boot
  1064.  
  1065. # make the grub image
  1066. grub-mkimage -O "x86_64-efi" -m "memdisk" -o "bootx64.efi" -p '(memdisk)/boot/grub' search iso9660 configfile normal memdisk tar cat part_msdos part_gpt fat ext2 ntfs ntfscomp hfsplus chain boot linux
  1067. popd
  1068.  
  1069. # copy the grub image to efi/boot (to go later in the device's root)
  1070. cp "$tempdir"/bootx64.efi efi/boot
  1071.  
  1072. #######################
  1073.  
  1074. ## Do the boot image "boot/grub/efiboot.img"
  1075.  
  1076. dd if=/dev/zero of=boot/grub/efiboot.img bs=1K count=1440
  1077. /sbin/mkdosfs -F 12 boot/grub/efiboot.img
  1078.  
  1079. mkdir img-mnt
  1080. mount -o loop boot/grub/efiboot.img img-mnt
  1081. mkdir -p img-mnt/efi/boot
  1082. cp "$tempdir"/bootx64.efi img-mnt/efi/boot/
  1083.  
  1084. #######################
  1085.  
  1086. # copy modules and font
  1087. cp /usr/lib/grub/x86_64-efi/* boot/grub/x86_64-efi/
  1088.  
  1089. # if this doesn't work try another font from the same place (grub's default, unicode.pf2, is much larger)
  1090. # Either of these will work, and they look the same to me. Unicode seems to work with qemu. -fsr
  1091. # cp /usr/share/grub/ascii.pf2 boot/grub/font.pf2
  1092. cp /usr/share/grub/unicode.pf2 boot/grub/font.pf2
  1093.  
  1094. # doesn't need to be root-owned
  1095. chown -R 1000:1000 $(pwd) 2>/dev/null
  1096.  
  1097. # Cleanup efi temps
  1098. umount img-mnt
  1099. rmdir img-mnt
  1100. rm -rf "$tempdir"
  1101.  
  1102. popd
  1103.  
  1104. # Copy efi files to iso
  1105. rsync -avx "$efi_work"/boot "$work_dir"/iso/
  1106. rsync -avx "$efi_work"/efi "$work_dir"/iso/
  1107.  
  1108. # Do the main grub.cfg (which gets loaded last):
  1109. cp "$grub_template" "$work_dir"/iso/boot/grub/grub.cfg
  1110. }
  1111.  
  1112.  
  1113. add_extras () {
  1114. # Prepend the dir name with a constant,
  1115. # so you can find and delete the old ones
  1116. # that might have different snapshot basenames.
  1117. dir_prefix="pkglist"
  1118.  
  1119. for dir in "$work_dir"/iso/"$dir_prefix"* ; do
  1120. rm -r "$dir"
  1121. done
  1122. mkdir -p "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"
  1123. dpkg -l | egrep "ii|hi" | awk '{ print $2 }' > "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"/package_list
  1124.  
  1125. # Add the Release Notes to the iso
  1126. if [[ -f /usr/share/doc/_Release_Notes/Release_Notes ]] ; then
  1127. rsync -a /usr/share/doc/_Release_Notes/Release_Notes "$work_dir"/iso/
  1128. fi
  1129. }
  1130.  
  1131.  
  1132. set_boot_options () {
  1133. # Create the boot menu unless iso_dir is not default.
  1134. if [ "$iso_dir" = "/usr/lib/refractasnapshot/iso" ] ; then
  1135. sed -i "s:\${DISTRO}:$DISTRO:g" "$work_dir"/iso/isolinux/"$boot_menu"
  1136. sed -i "s:\${netconfig_opt}:$netconfig_opt:g" "$work_dir"/iso/isolinux/"$boot_menu"
  1137. sed -i "s:\${ifnames_opt}:$ifnames_opt:g" "$work_dir"/iso/isolinux/"$boot_menu"
  1138. sed -i "s:\${username_opt}:$username_opt:g" "$work_dir"/iso/isolinux/"$boot_menu"
  1139. fi
  1140.  
  1141. if [[ $make_efi = "yes" ]] ; then
  1142. sed -i "s:\${DISTRO}:$DISTRO:g" "$work_dir"/iso/boot/grub/grub.cfg
  1143. sed -i "s:\${netconfig_opt}:$netconfig_opt:g" "$work_dir"/iso/boot/grub/grub.cfg
  1144. sed -i "s:\${username_opt}:$username_opt:g" "$work_dir"/iso/boot/grub/grub.cfg
  1145. sed -i "s:\${ifnames_opt}:$ifnames_opt:g" "$work_dir"/iso/boot/grub/grub.cfg
  1146. fi
  1147. }
  1148.  
  1149.  
  1150. edit_boot_menus () {
  1151. if [[ $edit_boot_menu = "yes" ]]; then
  1152. echo $"
  1153. You may now go to another virtual console to edit any files in the work
  1154. directory, or hit ENTER and edit the boot menu.
  1155. "
  1156. read -p " "
  1157. "$text_editor" "$work_dir"/iso/isolinux/"$boot_menu"
  1158. if [[ $make_efi = "yes" ]] ; then
  1159. "$text_editor" "$work_dir"/iso/boot/grub/grub.cfg
  1160. fi
  1161. fi
  1162. }
  1163.  
  1164.  
  1165. squash_filesystem () {
  1166. echo "Squashing the filesystem..."
  1167. if [[ $limit_cpu = "yes" ]] ; then
  1168. [[ $(type -p cpulimit) ]] || \
  1169. while true ; do
  1170. echo -n $"
  1171. The cpulimit program is not installed. Your CPU will not be limited.
  1172. Would you like to continue anyway? (y/N)
  1173. "
  1174. read ans
  1175. case $ans in
  1176. [Yy]*) break ;;
  1177. *) exit 0 ;;
  1178. esac
  1179. done
  1180. cpulimit -e mksquashfs -l "$limit" &
  1181. pid="$!"
  1182. fi
  1183. mksquashfs myfs/ iso/live/filesystem.squashfs ${mksq_opt} -noappend
  1184. if [[ -n "$pid" ]] ; then
  1185. kill "$pid"
  1186. fi
  1187.  
  1188. # This code is redundant, because $work_dir gets removed later, but
  1189. # it might help by making more space on the hard drive for the iso.
  1190. if [[ $save_work = "no" ]]; then
  1191. rm -rf myfs
  1192. fi
  1193. }
  1194.  
  1195.  
  1196. make_iso_fs () {
  1197. # create the iso file, make it isohybrid
  1198. # create sha256sum file for the iso
  1199. echo $"Creating CD/DVD image file..."
  1200.  
  1201. # If isohdpfx.bin gets moved again, maybe use: isohdpfx=$(find /usr/lib/ -name isohdpfx.bin)
  1202. if [[ $make_isohybrid = "yes" ]]; then
  1203. if [[ -f /usr/lib/syslinux/mbr/isohdpfx.bin ]] ; then
  1204. isohybrid_opt="-isohybrid-mbr /usr/lib/syslinux/mbr/isohdpfx.bin"
  1205. elif [[ -f /usr/lib/syslinux/isohdpfx.bin ]] ; then
  1206. isohybrid_opt="-isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin"
  1207. elif [[ -f /usr/lib/ISOLINUX/isohdpfx.bin ]] ; then
  1208. isohybrid_opt="-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin"
  1209. else
  1210. echo $"Can't create isohybrid. File: isohdpfx.bin not found. The resulting image will be a standard iso file."
  1211. fi
  1212. fi
  1213.  
  1214. [[ -n "$volid" ]] || volid="liveiso"
  1215. xorriso -as mkisofs -r -J -joliet-long -l -iso-level 3 ${isohybrid_opt} \
  1216. -partition_offset 16 -V "$volid" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
  1217. -boot-load-size 4 -boot-info-table ${uefi_opt} -o "$snapshot_dir"/"$filename" iso/
  1218.  
  1219. if [[ $make_sha256sum = "yes" ]]; then
  1220. cd "$snapshot_dir"
  1221. sha256sum "$filename" > "$filename".sha256
  1222. cd "$work_dir"
  1223. fi
  1224. }
  1225.  
  1226.  
  1227. cleanup () {
  1228. if [[ $save_work = "no" ]]; then
  1229. echo $"Cleaning..."
  1230. cd /
  1231. rm -rf "$work_dir"
  1232. #else
  1233. # rm "$work_dir"/iso/live/filesystem.squashfs
  1234. fi
  1235. }
  1236.  
  1237. final_message () {
  1238. echo -e $"\n\tAll finished!\n"
  1239. }
  1240.  
  1241. ######################################
  1242.  
  1243. check_grub
  1244. choose_task
  1245.  
  1246. _____________________________________________
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253. /etc/refractasnapshot.com
  1254. (default, as-shipped)
  1255.  
  1256. # This file contains some configuration variables for Refracta Snapshot
  1257. # (version 10.2.x GUI and CLI versions). If you want to change
  1258. # the defaults, this is the place to do it.
  1259. #
  1260. # Put this file in /etc or edit the configfile variable found at the
  1261. # top of refractasnapshot to reflect its true location. If the
  1262. # script can't find this config file, it'll use the default values.
  1263. # Copyright 2011-2018 [email protected]
  1264.  
  1265.  
  1266.  
  1267. # Some laptops overheat when running rsync or mksquashfs. If limit_cpu
  1268. # is "yes", cpu activity will be limited on those two commands.
  1269. # limit is percentage of cpu allowed for command, up to 100% per core.
  1270.  
  1271. limit_cpu="no"
  1272. limit="50"
  1273.  
  1274.  
  1275. # Default location for error log is /var/log/refractasnashot.log
  1276.  
  1277. error_log="/var/log/refractasnapshot.log"
  1278.  
  1279.  
  1280. # You can change the location of $work_dir (location of system copy) and
  1281. # $snapshot_dir (location of final iso file) in case you don't have enough
  1282. # space on the system. (Defaults are "/home/work" and "/home/snapshot")
  1283. #
  1284. # Hints:
  1285. # Be sure to use separate directories for these two variables. If you
  1286. # use the same location for both (e.g. /media/disk) and if $save_work
  1287. # is set to "no", your CD image will get deleted when the program
  1288. # finishes. Instead, use something like /media/disk/snapshot and
  1289. # /media/disk/work, or even /media/disk/snapshot/work.
  1290. # These directories will be created by the script, and they are
  1291. # already set to be excluded from the rsync copy of the system (so you
  1292. # don't end up with an extra copy of your system or old snapshots in the
  1293. # final CD image.)
  1294. # Any filesystems mounted in /mnt or /media will be excluded from the
  1295. # system copy. Filesystems mounted elsewhere will be included and will
  1296. # increase the size of the final CD image. To avoid that, you can either
  1297. # unmount those filesystems before running refractasnapshot, or you can
  1298. # add them to the excludes file. (See snapshot_excludes below.)
  1299.  
  1300. snapshot_dir="/home/snapshot"
  1301. work_dir="/home/work"
  1302. efi_work="${work_dir}/efi-files"
  1303.  
  1304.  
  1305. # Set to yes to create boot files for uefi.
  1306.  
  1307. make_efi="yes"
  1308.  
  1309.  
  1310. # Set to force xorriso to use $uefi_opt (for testing only)
  1311.  
  1312. force_efi="no"
  1313.  
  1314.  
  1315. # Change $save_work to "yes" if you want the temporary copy of your
  1316. # filesystem to be saved. This will make subsequent snapshot creation
  1317. # go faster.
  1318. # (Default is "no")
  1319.  
  1320. save_work="no"
  1321.  
  1322.  
  1323. # rsync delete options (or any others you want to add)
  1324. # This is only for copy_filesystem() and only if $save_work is "yes"
  1325. # Use only one option per variable!
  1326. # Default options are --delete-before and --delete-excluded
  1327. # Full command in the script is:
  1328. # rsync -av / myfs/ ${rsync_option1} ${rsync_option12} ${rsync_option3} \
  1329. # --exclude="$work_dir" --exclude="$snapshot_dir" --exclude="$efi_work" --exclude-from="$snapshot_excludes"
  1330.  
  1331. rsync_option1="--delete-before"
  1332. rsync_option2=" --delete-excluded"
  1333. rsync_option3=""
  1334.  
  1335. # You can change the default rsync excludes file here if you know what
  1336. # you're doing. Be sure to use the full path to the file.
  1337. #
  1338. # It's also possible to edit the excludes file by choosing "Setup"
  1339. # during the execution of the script.
  1340. #
  1341. # Default is "/usr/lib/refractasnapshot/snapshot_exclude.list"
  1342.  
  1343. snapshot_excludes="/usr/lib/refractasnapshot/snapshot_exclude.list"
  1344.  
  1345.  
  1346. # Change this if you want the live system to use other than the default
  1347. # kernel and initrd. You may need to edit the isolinux boot menu to
  1348. # match the filenames. (Also see custom boot menu section below.)
  1349. # Example: for kernel_image="/boot/vmlinuz-3.16.0-4-amd64" then the kernel
  1350. # line in the boot menu would contain:
  1351. # kernel /live/vmlinuz-3.16.0-4-amd64
  1352. #
  1353. # (Defaults are /vmlinuz and /initrd.img)
  1354.  
  1355. kernel_image="/vmlinuz"
  1356. initrd_image="/initrd.img"
  1357.  
  1358.  
  1359. # Multiple snapshots (iso files) are named with the date and time of
  1360. # creation. If you prefer to have them numbered sequentially, comment
  1361. # out the next line. Default is to keep the line uncommented.
  1362.  
  1363. stamp="datetime"
  1364.  
  1365.  
  1366. # The name of the snapshot file will be snapshot-{date or number}.iso.
  1367. # If you'd like to replace "snapshot" with something more memorable,
  1368. # change it here. (example: snapshot_basename="refracta-nox-wheezy")
  1369. # volid is the volume label on the finished (burned) CD, DVD or USB.
  1370.  
  1371. snapshot_basename="snapshot"
  1372. volid="liveiso"
  1373.  
  1374.  
  1375. # Change to "no" if you don't want the sha256sum file created with the iso.
  1376. # (Default is "yes")
  1377.  
  1378. make_sha256sum="yes"
  1379.  
  1380.  
  1381. # Change to "no" if you want a plain iso image instead of isohybrid.
  1382. # (Default is "yes")
  1383.  
  1384. make_isohybrid="yes"
  1385.  
  1386.  
  1387. # Uncomment one of the lines below to use xz compression for smaller iso.
  1388.  
  1389. # small and slow
  1390. #mksq_opt="-comp xz"
  1391.  
  1392. # smaller and slower:
  1393. #mksq_opt="-comp xz -Xbcj x86"
  1394.  
  1395. ####################################
  1396. # Turn stuff on and off section
  1397.  
  1398. # Allow users to mount all fixed drives with pmount for live iso.
  1399. # Refractainstaller removes this upon installation.
  1400. # (Default is "yes")
  1401.  
  1402. pmount_fixed="yes"
  1403.  
  1404.  
  1405. # update the mlocate database before copying filesystem.
  1406.  
  1407. update_mlocate="yes"
  1408.  
  1409.  
  1410. # Clear list of recently used files in geany for primary user.
  1411. # Default is "yes"
  1412.  
  1413. clear_geany="yes"
  1414.  
  1415.  
  1416. # Allow password login to ssh for users (not root).
  1417. # If ssh_pass="yes", then PasswordAuthentication will be set to "yes"
  1418. # If ssh_pass="no", then PasswordAuthentication will be set to "no"
  1419. # In either of the above cases, if PermitRootLogin was set to "yes",
  1420. # it will be changed to "prohibit-password" (meaning with auth keys only)
  1421. # If ssh_pass is null or set to anything other than "yes" or "no", then
  1422. # /etc/ssh/sshd_config will not be altered.
  1423.  
  1424. ssh_pass="yes"
  1425.  
  1426. ########################################################
  1427. # Custom boot menu and help files section.
  1428.  
  1429. # If you're running refractasnapshot on some linux distribution other
  1430. # than Refracta, You might also want to edit or remove some of the help
  1431. # files in the isolinux directory. (f1.txt, f2.txt...)
  1432. # If you want those changes to persist between runs, you should create
  1433. # a custom iso/isolinux directory, and set iso_dir (below) to point
  1434. # to that directory.
  1435.  
  1436.  
  1437.  
  1438. # If the primary user's name is not "user", then live-boot needs to see
  1439. # the user's name in the boot command. In that case, the script will
  1440. # automatically add the correct option. If you set a user name here, it
  1441. # will override that process. Use this if you want to log into the live
  1442. # media as someone other than the primary user (i.e. any user whose
  1443. # uid:gid are not 1000:1000.)
  1444. # Under most circumstances, leave this blank or commented out.
  1445.  
  1446. #username=""
  1447.  
  1448.  
  1449. # Change to "yes" if you want to be able to view or edit the boot menu
  1450. # or any other config files before the final image is made.
  1451. # Note2: For SolusOS and possibly others, boot entries should contain
  1452. # "union=unionfs" in place of "union=aufs".
  1453. # Note3: For anything later than jessie, union=aufs should be removed
  1454. # or possibly replaced with union=overlay
  1455.  
  1456. edit_boot_menu="no"
  1457.  
  1458.  
  1459.  
  1460. # EDITOR SETTINGS
  1461. # This gets used if you set edit_boot_menu="yes" or if you run setup
  1462. # and choose to edit the config file or the excludes file.
  1463. # Use an absolute path here.
  1464. # (example: text_editor="/usr/bin/nano)"
  1465.  
  1466. # Command-line editor (for refractasnapshot)
  1467. text_editor="$(type -p nano)"
  1468.  
  1469. # Graphical editor (for refractasnapshot-gui)
  1470. # Program tests for geany, gedit, kate, kwrite, leafpad, medit, mousepad, pluma
  1471. # You can specify an editor here if needed.
  1472. # other_editor_option is used to force a new instance of the editor.
  1473.  
  1474. other_editor=""
  1475. other_editor_option=""
  1476.  
  1477.  
  1478.  
  1479. # You can change iso_dir if you want to use customized files for the
  1480. # boot menu and boot help pages on the live-cd.
  1481. # Note:
  1482. # If you're using custom versions (different from what's installed
  1483. # on your system) of isolinux.bin and vesamenu.c32, you'll need to edit
  1484. # or comment out the rsync commands in the script that copy these two
  1485. # files from your system to the work directory. To find the lines, see
  1486. # /usr/bin/refractasnapshot or /usr/bin/refractsnapshot-gui for the
  1487. # copy_isolinux function, around line 520 or 630, respectively.
  1488. # (Default is "/usr/lib/refractasnapshot/iso")
  1489. # DO NOT USE A TRAILING SLASH HERE!!!"
  1490.  
  1491. iso_dir="/usr/lib/refractasnapshot/iso"
  1492.  
  1493.  
  1494. # Change this if you're using customized boot menu files, AND your
  1495. # menu file is other than the default, live.cfg, AND you set
  1496. # $edit_boot_menu to "yes".
  1497.  
  1498. boot_menu="live.cfg"
  1499.  
  1500. # grub_template gets used for uefi live boot menu.
  1501.  
  1502. grub_template="/usr/lib/refractasnapshot/grub.cfg.template"
  1503.  
  1504.  
  1505. # Uncomment this to add boot help files specific to the Refracta distribution.
  1506. # Otherwise, generic help files, mostly empty, will be used. If you want
  1507. # to use your own customized files, see iso_dir settings above.
  1508.  
  1509. #refracta_boot_help="yes"
  1510.  
  1511.  
  1512. # Prepare the initrd to support encrypted volumes. Uncomment this
  1513. # if you plan to use the snapshot on a live usb with an encrypted
  1514. # persistent volume. This will edit /etc/cryptsetup-initramfs/conf-hook
  1515. # to set CRYPTSETUP=y
  1516.  
  1517. #initrd_crypt="yes"
  1518.  
  1519.  
  1520. # Uncomment to include your network configuration in the snapshot.
  1521. # This will preserve your /etc/network/interfaces and any saved wireless
  1522. # configurations. This works for NetworkManager, simple-netaid/netman
  1523. # and wicd.
  1524. # It will also add "ip=frommedia" to the boot command, so that the saved
  1525. # configuration will be used.
  1526. # Default is commented; interfaces file in $work_dir/myfs gets replaced
  1527. # and only contains the loopback interface.
  1528. #
  1529. # NOTE!!! If you're using some other network manager, and you don't want
  1530. # your configs to be copied, you need to add the appropriate files to
  1531. # the excludes list. (Tell me what those files are, and I'll fix
  1532. # refractasnapshot to handle it.)
  1533.  
  1534. #netconfig_opt="ip=frommedia"
  1535.  
  1536.  
  1537. # Uncomment to use old or new style interface names.
  1538. # Use net.ifnames=0 to force old interface names with udev. (eth0)
  1539. # Use net.ifnames=1 to force new interface names with eudev. (enp0s1)
  1540.  
  1541. #ifnames_opt="net.ifnames=0"
  1542.  
  1543.  
  1544. # Snapshot Help text
  1545.  
  1546. snapshot_help="/usr/share/doc/refractasnapshot-base/readme.refractasnapshot.txt.gz"
  1547.  
  1548.  
  1549. # DEPRECATED:
  1550. # This patch is no longer needed. Instead, the script will create some
  1551. # files in /dev to help with booting. If you leave this variable set
  1552. # to "yes" the script will check for previous application of the patch
  1553. # and give you the chance to edit the file manually. If you don't remove
  1554. # the lines that were added by the patch, nothing bad will happen.
  1555. #
  1556. #
  1557. # Debian Jessie systems without systemd and with util-linux-2.25 will
  1558. # create an unbootable iso. The workaround is to add a few lines to
  1559. # /usr/share/initramfs-tools/init and then rebuild the initrd.
  1560. # If this option is set to "yes" then the script will check for systemd
  1561. # and for the version of util-linux. If needed, the script will apply
  1562. # the patch and rebuild the initrd.
  1563. #
  1564. # Warning: If you also need to run the nocrypt.sh script because you're
  1565. # creating a snapshot from a system INSTALLED ON AN ENCRYPTED PARTITION,
  1566. # you need to run nocrypt.sh after letting this patch run. (Hint: you
  1567. # can abort the snapshot run at the Disk Space Report, run nocrypt,
  1568. # then make your snapshot.)
  1569. #
  1570. # Default is "no" or commented out.
  1571.  
  1572. #patch_init_nosystemd="yes"
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583. _____________________________________________
  1584.  
  1585. within the debfile, the to-be-installed copy of
  1586. /usr/share/doc/refractasnapshot-base/README (is from v10.0, so not entirely up-to-date).
  1587. Below, I'm pasting the content of
  1588. /usr/share/doc/refractasnapshot-base/readme.refractasnapshot.txt.gz
  1589.  
  1590. v. 10.2.0+
  1591. Refracta Snapshot creates a bootable live-CD image which is a copy of
  1592. your running system. Any changes you make to the running system,
  1593. including desktop preferences, configuration changes, or added software
  1594. will be copied to the snapshot and will be present when you run that
  1595. snapshot as a live system.
  1596.  
  1597. See the config file, /etc/refractasnapshot.conf for setting options.
  1598. The config file is the most up-to-date and detailed documentation.
  1599.  
  1600. See the excludes file, /usr/lib/refractasnapshot/snapshot_exclude.list
  1601. to examine which files and directories will not be copied to the
  1602. snapshot. Edit the file as needed, either by adding items or commenting
  1603. out listed items that you want copied.
  1604.  
  1605. As of version 9.0.8, you can edit the config and excludes files from
  1606. within the gui program by choosing "Setup".
  1607.  
  1608. To run the script:
  1609.  
  1610. refractasnapshot
  1611. or
  1612. refractasnapshot-gui
  1613.  
  1614. or use the full path if needed:
  1615. /usr/bin/refractasnapshot(-gui)
  1616.  
  1617.  
  1618. COMMAND LINE OPTIONS
  1619.  
  1620. -h, --help show help
  1621. -v, --version display the version information
  1622. -c, --config specify a different config file
  1623. (file name must be next argument)
  1624. -d, --debug run in debug mode (set -x)
  1625.  
  1626.  
  1627. TROUBLESHOOTING
  1628.  
  1629. Run refractasnapshot or refractasnapshot-gui with the '-d' option and
  1630. save /var/log/refractasnapshot.log for analysis.
  1631.  
  1632.  
  1633. NOCOPY OPTION
  1634.  
  1635. The nocopy option has been replaced with an options menu in the script.
  1636. 1. Create a snapshot
  1637. - This runs the full process to create a snapshot, consisting of
  1638. rsync copy to create the live filesystem
  1639. copy isolinux boot files
  1640. create efi boot files
  1641. squash the live filesystem
  1642. put it all into a bootable iso file.
  1643. 2. Re-squash and make iso (no-copy)
  1644. - For manual changes to the live filesystem in $work_dir/myfs.
  1645. 3. Re-make efi files and iso (no-copy, no-squash)
  1646. - Maybe for hacking on the mkefi function in the script.
  1647. 4. Re-run xorriso only (make iso, no-copy, no-squash)
  1648. - For manual changes to any files in the root of the live media,
  1649. such as boot menus or boot help files in $work_dir/iso.
  1650.  
  1651. The nocopy options will prevent rsync from updating the saved copy of the
  1652. filesystem. Any system changes or updates that occurred after the copy
  1653. was made will not be included in the final image.
  1654.  
  1655. The nocopy options are for special purposes (for example, you made changes
  1656. to the saved copy of the filesystem after a previous snapshot, and you
  1657. don't want those changes overwritten by the running system.)
  1658. However, you must have save_work=yes and have a previously saved copy of
  1659. the filesystem for nocopy to work.
  1660.  
  1661.  
  1662. CREATING A SNAPSHOT FROM AN ENCRYPTED SYSTEM OR SWAP PARTITION
  1663.  
  1664. If your host system is encrypted or has a swap partition, the script
  1665. will edit the snapshot's initrd to remove conf/conf.d/cryptroot and/or
  1666. conf/conf.d/resume so that the snapshot iso will boot successfully.
  1667.  
  1668. This will NOT affect the initrd on the host system.
  1669.  
  1670.  
  1671. CREATING A SNAPSHOT TO BE USED WITH ENCRYPTED PERSISTENCE
  1672.  
  1673. If you want to create an iso that will be used to make a live-usb with
  1674. an encrypted volume for persistence, you need to rebuild the initrd to
  1675. include cryptsetup if it's missing. This is now automatic.
  1676.  
  1677. - Uncomment the line in /etc/refractasnapshot.conf that contains:
  1678. initrd_crypt="yes"
  1679.  
  1680. The script will check for cryptsetup in the initrd, and if necessary
  1681. will edit /etc/cryptsetup-initramfs/conf-hook to set CRYPTSETUP=y.
  1682.  
  1683. This DOES change the host's initrd. To revert the change in the host,
  1684. comment out the line and run 'update-initramfs -u'.
  1685.  
  1686. Assumptions: The kernel you're running is the one that you will use in
  1687. the snapshot. (i.e. /initrd.img)
  1688.  
  1689.  
  1690. NETWORK CONFIGURATIONS
  1691.  
  1692. If you want custom network configurations to be copied into the snapshot,
  1693. uncomment the line in the config file that has:
  1694. netconfig_opt="ip=frommedia"
  1695.  
  1696. This will preserve your /etc/network/interfaces and any saved wireless
  1697. configurations. This works for NetworkManager, simple-netaid/netman
  1698. and wicd. It will also add "ip=frommedia" to the boot command, so that
  1699. the saved configuration will be used in the live system.
  1700.  
  1701. If you leave the line commented, the default behavior is to
  1702. replace the interfaces file with one that only has the loopback interface
  1703. configured and to delete any saved wireless configurations.
  1704. (This only affects the filesystem copy in $work_dir/myfs.)
  1705.  
  1706. NOTE!!! If you're using some other network manager, and you don't want
  1707. your configs to be copied, you need to add the appropriate files to
  1708. the excludes list. (Tell me what those files are, and I'll fix
  1709. refractasnapshot to handle it.)
  1710.  
  1711.  
  1712. NETWORK INTERFACE NAMES
  1713.  
  1714. To control whether the snapshot uses old network interface names like
  1715. eth0 or new names like enp0s1, uncomment and set ifnames_opt in the
  1716. config file.
  1717.  
  1718. Use net.ifnames=0 to force old interface names with udev. (eth0)
  1719. Use net.ifnames=1 to force new interface names with eudev. (enp0s1)
  1720.  
  1721. ______________________________________________
  1722.  
  1723.  
Advertisement
Add Comment
Please, Sign In to add comment