chroot logic update
This commit is contained in:
parent
6071fba20e
commit
80c26f4d92
|
@ -1,16 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
. CONFIG_SCRIPTS.sh
|
||||||
# ---- Setup Aliases ---- #
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias echo="echo -e"
|
|
||||||
|
|
||||||
|
|
||||||
# ---- Setup Variables ---- #
|
# ---- Setup Variables ---- #
|
||||||
|
|
||||||
SCRIPT_PATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )";
|
|
||||||
CHROOT_PTH="./work/chroot"
|
|
||||||
|
|
||||||
# Resolution of Xephyr... ex: 1920x1080 or 1600x900, etc
|
# Resolution of Xephyr... ex: 1920x1080 or 1600x900, etc
|
||||||
RESOLUTION="1920x1080"
|
RESOLUTION="1920x1080"
|
||||||
|
|
||||||
|
@ -41,7 +35,9 @@ OS_NAME=""
|
||||||
LIVE_USER=""
|
LIVE_USER=""
|
||||||
|
|
||||||
|
|
||||||
# ---- Call CONFIG Methods Here As Needed ---- #
|
|
||||||
|
|
||||||
|
# ---- Call CONFIG_SCRIPTS Methods Here As Needed ---- #
|
||||||
set_system_release;
|
set_system_release;
|
||||||
cd "${SCRIPT_PATH}";
|
cd "${SCRIPT_PATH}";
|
||||||
echo "Base Dir: " $(pwd) "\n";
|
echo "Base Dir: " $(pwd) "\n";
|
||||||
|
@ -53,32 +49,7 @@ mkdir -p image/{casper,isolinux,install}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ---- DO NOT CHANGE OR REMOVE UNLESS YOU KNOW WHAT YOU ARE DOING ---- #
|
# ---- DO NOT CHANGE OR REMOVE UNLESS YOU KNOW WHAT YOU ARE DOING ---- #
|
||||||
|
|
||||||
# Clean manifest-desktop file of unneeded parts
|
# Clean manifest-desktop file of unneeded parts
|
||||||
REMOVE='ubiquity ubiquity-frontend-gtk ubiquity-frontend-kde casper lupin-casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4'
|
REMOVE='ubiquity ubiquity-frontend-gtk ubiquity-frontend-kde casper lupin-casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4'
|
||||||
|
|
||||||
|
|
||||||
# The system release version working from
|
|
||||||
function set_system_release() {
|
|
||||||
IN=$(cat /etc/os-release | grep "VERSION_CODENAME")
|
|
||||||
ARRY=(${IN//=/ })
|
|
||||||
SYSTEM_RELEASE="${ARRY[1]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirm_dialouge() {
|
|
||||||
echo $1
|
|
||||||
read -p "(yY/Nn) --> " ANSR
|
|
||||||
while [[ $ANSR != "y" ]] && [[ $ANSR != "Y" ]] && \
|
|
||||||
[[ $ANSR != "n" ]] && [[ $ANSR != "N" ]]
|
|
||||||
do
|
|
||||||
read -p "(yY/Nn) --> " ANSR
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $ANSR == "n" ]] || [[ $ANSR == "N" ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set -o xtrace ## To debug scripts
|
||||||
|
# set -o errexit ## To exit on error
|
||||||
|
# set -o errunset ## To exit if a variable is referenced but not set
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---- DO NOT CHANGE OR REMOVE UNLESS YOU KNOW WHAT YOU ARE DOING ---- #
|
||||||
|
|
||||||
|
# ---- Setup Aliases ---- #
|
||||||
|
shopt -s expand_aliases
|
||||||
|
alias echo="echo -e"
|
||||||
|
|
||||||
|
SCRIPT_PATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )";
|
||||||
|
CHROOT_PTH="./work/chroot"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---- Methods Used Throughout The Process ---- #
|
||||||
|
# Help get the system release version we're working from
|
||||||
|
function set_system_release() {
|
||||||
|
IN=$(cat /etc/os-release | grep "VERSION_CODENAME")
|
||||||
|
ARRY=(${IN//=/ })
|
||||||
|
SYSTEM_RELEASE="${ARRY[1]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Generic confirm 'dialouge'
|
||||||
|
function confirm_dialouge() {
|
||||||
|
echo $1
|
||||||
|
read -p "(yY/Nn) --> " ANSR
|
||||||
|
while [[ $ANSR != "y" ]] && [[ $ANSR != "Y" ]] && \
|
||||||
|
[[ $ANSR != "n" ]] && [[ $ANSR != "N" ]]
|
||||||
|
do
|
||||||
|
read -p "(yY/Nn) --> " ANSR
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $ANSR == "n" ]] || [[ $ANSR == "N" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---- Messages Used Throughout The Process ---- #
|
||||||
|
|
||||||
|
function chroot_big_dump_mesage() {
|
||||||
|
echo "Run each time you chroot:"
|
||||||
|
echo "\texport HOME=/root"
|
||||||
|
echo "\texport LC_ALL=C"
|
||||||
|
echo "\nRun once in chroot:"
|
||||||
|
echo "\tapt-get update"
|
||||||
|
echo "\tapt-get install --yes dbus"
|
||||||
|
echo "\tapt-get --yes upgrade"
|
||||||
|
echo "\tdbus-uuidgen > /var/lib/dbus/machine-id"
|
||||||
|
echo "\tdpkg-divert --local --rename --add /sbin/initctl"
|
||||||
|
|
||||||
|
echo "\nThere is a current (for Karmic, ..., Precise) issue with services running in a chroot:"
|
||||||
|
echo "\thttps://bugs.launchpad.net/ubuntu/+source/upstart/+bug/430224."
|
||||||
|
echo "\nA workaround is to link /sbin/initctl to /bin/true:"
|
||||||
|
echo "\tln -s /bin/true /sbin/initctl"
|
||||||
|
|
||||||
|
echo "\nInstall packages needed for Live System (I think 'ubuntu-standard' package is optional.):"
|
||||||
|
echo "\tapt-get install --yes casper lupin-casper"
|
||||||
|
echo "\tapt-get install --yes discover laptop-detect os-prober"
|
||||||
|
echo "\tapt-get install --yes linux-generic"
|
||||||
|
}
|
|
@ -9,42 +9,31 @@
|
||||||
|
|
||||||
# Debootstrap process
|
# Debootstrap process
|
||||||
function main() {
|
function main() {
|
||||||
ansr=$(confirm_dialouge "Launch Xephyr preview window?\n Resolution: ${RES} Window ID: ${ID}")
|
confirm_dialouge "Launch Xephyr preview window?\n Resolution: ${RESOLUTION} Window ID: ${ID}"
|
||||||
if [[ $ansr -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
Xephyr -resizeable -screen "${RES}" "${ID}" &
|
Xephyr -resizeable -screen "${RES}" "${ID}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo mount --bind /dev "${CHROOT_PTH}"/dev
|
clear
|
||||||
|
# Mount stuff
|
||||||
|
sudo mount -o /dev "${CHROOT_PTH}"/dev/
|
||||||
|
sudo mount -t proc proc proc/
|
||||||
|
sudo mount -t sysfs sys sys/
|
||||||
|
|
||||||
|
# setup some configs stuff for internetz
|
||||||
sudo cp /etc/hosts "${CHROOT_PTH}"/etc/hosts
|
sudo cp /etc/hosts "${CHROOT_PTH}"/etc/hosts
|
||||||
sudo cp /etc/resolv.conf "${CHROOT_PTH}"/etc/resolv.conf
|
sudo cp /etc/resolv.conf "${CHROOT_PTH}"/etc/resolv.conf
|
||||||
|
sudo chown $USER "${CHROOT_PTH}"/etc/apt/sources.list
|
||||||
sudo sed s/$SYSTEM_RELEASE/$RELEASE/ < /etc/apt/sources.list > "${CHROOT_PTH}"/etc/apt/sources.list
|
sudo sed s/$SYSTEM_RELEASE/$RELEASE/ < /etc/apt/sources.list > "${CHROOT_PTH}"/etc/apt/sources.list
|
||||||
|
sudo chown root "${CHROOT_PTH}"/etc/apt/sources.list
|
||||||
|
|
||||||
|
# Enter chroot mode
|
||||||
|
chroot_big_dump_mesage
|
||||||
sudo chroot "${CHROOT_PTH}"
|
sudo chroot "${CHROOT_PTH}"
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
sudo umount "${CHROOT_PTH}"/dev
|
sudo umount -lf "${CHROOT_PTH}"/dev/
|
||||||
|
sudo umount -lf "${CHROOT_PTH}"/proc/
|
||||||
|
sudo umount -lf "${CHROOT_PTH}"/sys/
|
||||||
# ---- OLD SETUP ---- #
|
|
||||||
# ## Set Xephyr and set chrooting mounts
|
|
||||||
# Xephyr -resizeable -screen "${RES}" "${ID}" &
|
|
||||||
# cd squashfs-root/
|
|
||||||
# mount -t proc proc proc/
|
|
||||||
# mount -t sysfs sys sys/
|
|
||||||
# mount -o bind /dev dev/
|
|
||||||
# cp /etc/resolv.conf etc/
|
|
||||||
#
|
|
||||||
# ## Enter env with chroot
|
|
||||||
# chroot . bash
|
|
||||||
#
|
|
||||||
# ## Unmount binds
|
|
||||||
# umount -lf dev/
|
|
||||||
# umount -lf proc/
|
|
||||||
# umount -lf sys/
|
|
||||||
# cd ..
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
main $@;
|
main $@;
|
||||||
|
|
Loading…
Reference in New Issue