wichroot.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. echo "======================"
  7. DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
  8. PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
  9. echo "Distro name: $DISTRONAME"
  10. echo "PACKAGEMGR: $PACKAGEMGR"
  11. METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
  12. echo "Metadistro: $METADISTRO"
  13. ROOTDEV=$(sed -n '5p' $WITCH/config.base.txt)
  14. echo "Root filesystem location: $ROOTDEV"
  15. echo "======================"
  16. if [ $DIMG_RUN == "true" ]; then
  17. SYSPATH=$WITCH/sys/$DISTRONAME
  18. else
  19. SYSPATH=/mnt/$DISTRONAME
  20. fi
  21. ################### wichroot likely needs an end bit to de-chroot, to make the rest of the script run. !!!!!!!!!!!!!!!!
  22. 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.
  23. sleep 1
  24. # clear the file
  25. echo > $WITCH/procedure.d/wichroot_script.sh.new
  26. while read line
  27. do
  28. if [[ -n "$line" ]]; then
  29. if [[ "$(echo $line | grep 'DISTRONAME=placeholder')" == "$line" ]]; then
  30. # check if line is DISTRONAME=placeholder --> normal string equality check does not work
  31. line="DISTRONAME=$DISTRONAME"
  32. fi
  33. if [[ "$(echo $line | grep 'PACKAGEMGR=placeholder')" == "$line" ]]; then # etc...
  34. line="PACKAGEMGR=$PACKAGEMGR"
  35. fi
  36. if [[ "$(echo $line | grep 'METADISTRO=placeholder')" == "$line" ]]; then
  37. line="METADISTRO=$METADISTRO"
  38. fi
  39. if [[ "$(echo $line | grep 'ROOTDEV=placeholder')" == "$line" ]]; then
  40. line="ROOTDEV=$ROOTDEV"
  41. fi
  42. fi
  43. echo "$line" >> $WITCH/procedure.d/wichroot_script.sh.new
  44. done < $WITCH/procedure.d/wichroot_script.sh
  45. mv $WITCH/procedure.d/wichroot_script.sh.new $SYSPATH/bin/witchroot
  46. chmod +x $SYSPATH/bin/witchroot
  47. echo "chroot $SYSPATH /bin/bash /bin/witchroot"
  48. sleep 1
  49. chroot $SYSPATH /bin/bash /bin/witchroot
  50. #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.