wichroot.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ############
  2. ############
  3. # wichroot
  4. # Needs some changes. METADISTRO has been included for usage.
  5. # Oh, and refactor it to make it easier to unify. Only some sections require change.
  6. #MIX ... this is where the addaption from gentoo to poly-distro develops
  7. #as in prechroot, twil be fun "if"ing up this to accomodate the unique chrootnesses.
  8. echo "======================"
  9. DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
  10. PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
  11. echo "Distro name: $DISTRONAME"
  12. echo "PACKAGEMGR: $PACKAGEMGR"
  13. METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
  14. echo "Metadistro: $METADISTRO"
  15. ROOTDEV=$(sed -n '5p' $WITCH/config.base.txt)
  16. echo "Root filesystem location: $ROOTDEV"
  17. echo "======================"
  18. if [ $DIMG_RUN == "true" ]; then
  19. SYSPATH=$WITCH/sys/$DISTRONAME
  20. else
  21. SYSPATH=/mnt/$DISTRONAME
  22. fi
  23. ################### wichroot likely needs an end bit to de-chroot, to make the rest of the script run. !!!!!!!!!!!!!!!!
  24. echo "ENTER THE CHROOT" # http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ <- will tell you how... at least the basics of it. this still likely means packaging up the rest of the installer for the chrooted half, into a cat-eof'd && chmod+x'd script just prior to the chroot, and then running that.
  25. sleep 1
  26. # clear the file
  27. echo > $WITCH/procedure.d/wichroot_script.sh.new
  28. while read line
  29. do
  30. if [[ -n "$line" ]]; then
  31. if [[ "$(echo $line | grep 'DISTRONAME=placeholder')" == "$line" ]]; then
  32. # check if line is DISTRONAME=placeholder --> normal string equality check does not work
  33. line="DISTRONAME=$DISTRONAME"
  34. fi
  35. if [[ "$(echo $line | grep 'PACKAGEMGR=placeholder')" == "$line" ]]; then # etc...
  36. line="PACKAGEMGR=$PACKAGEMGR"
  37. fi
  38. if [[ "$(echo $line | grep 'METADISTRO=placeholder')" == "$line" ]]; then
  39. line="METADISTRO=$METADISTRO"
  40. fi
  41. if [[ "$(echo $line | grep 'ROOTDEV=placeholder')" == "$line" ]]; then
  42. line="ROOTDEV=$ROOTDEV"
  43. fi
  44. fi
  45. echo "$line" >> $WITCH/procedure.d/wichroot_script.sh.new
  46. done < $WITCH/procedure.d/wichroot_script.sh
  47. mv $WITCH/procedure.d/wichroot_script.sh.new $SYSPATH/bin/witchroot
  48. chmod +x $SYSPATH/bin/witchroot
  49. echo "chroot $SYSPATH /bin/bash /bin/witchroot"
  50. sleep 1
  51. chroot $SYSPATH /bin/bash /bin/witchroot
  52. #or rather... need to get it so that the stuff in the CHEOFings, that gets put in witchroot script, gets initiated once you've chrooted... but then, how do you tell it to execute that... .... ah. the issue remains. prolly better do as i said at the start of this chrootings, and get the gist of the basics from: http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ and stop freaking out over it.