Update dist_Builder.sh

Improved setup detection plus error handling of different directory structures.
This commit is contained in:
Maxim 2017-03-20 20:23:02 -05:00 committed by GitHub
parent 032d7f347b
commit 642cbb9caf
1 changed files with 52 additions and 36 deletions

View File

@ -1,26 +1,4 @@
#!/bin/bash #!/bin/bash
#---------------- Copyright notices and creator info-----------------------------#
#
# By Maxim F. Stewart Contact: [maximstewart1@gmail.com]
#
# Copyright 2013 Maxim F. Stewart
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
#
#
#--------------------------------------------------------------------------------#
. CONFIG . CONFIG
rootNisoChk() { rootNisoChk() {
@ -49,7 +27,7 @@ genIso=$(which genisoimage) ## Iso maker
echo "" echo ""
echo "Going to run :" echo "Going to run :"
echo " apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y" echo " apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y"
sleep 3 sleep 4
apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y
getIso getIso
else else
@ -107,11 +85,51 @@ getIso() {
} }
main() { main() {
if ! [ -f *.iso ]; then if [ ! -f *.iso ] && [ ! -d squashfs-root ]; then
echo "Sorry, there is no iso to work with in the current directory." clear
exit 1 echo "Sorry, there is no iso or squashfs-root dir to work with in the current directory."
fi echo "Going back to download ans Ubuntu Mini Iso..."
sleep 4
getIso
elif [ -f *.iso ] && [ -d squashfs-root ]; then
clear
echo "Both an iso and squashfs-root are present..."
echo "Which do you wish to use?"
read -p "1.) `echo *.iso`
2.) Use former session: squashfs-root
3.) Exit
--> : " ANSR
while [[ $ANSR != "1" ]] && [[ $ANSR != "2" ]] && \
[[ $ANSR != "3" ]]
do
read -p "1.) `echo *.iso`
2.) Use former session: squashfs-root
3.) Exit
--> : " ANSR
done
if [[ $ANSR == "1" ]]; then
bash cleanup.sh
mountAndCopy
elif [[ $ANSR == "2" ]]; then
chrootr
elif [[ $ANSR == "3" ]]; then
exit
fi
elif [ -d squashfs-root ]; then
clear
echo "Squashfs-root directory found. Chrooting to directory."
sleep 4
chrootr
elif [ -f *.iso ]; then
clear
echo "Iso found. Mounting and copying to proper file structure. Then chrooting in...\n"
sleep 4
mountAndCopy
fi
}
mountAndCopy() {
## Prep dirs ## Prep dirs
mkdir iso/ mnt/ mkdir iso/ mnt/
@ -126,15 +144,13 @@ main() {
## Cleanup some prep items ## Cleanup some prep items
umount mnt/ && rmdir mnt/ umount mnt/ && rmdir mnt/
rm *.iso
chrootr
}
chrootr() {
## Copy over build files 'n scripts ## Copy over build files 'n scripts
cp AUTO_INSTALL.sh squashfs-root/ cp AUTO_INSTALL.sh squashfs-root/
cp -r COPY_OVER_TO_CHROOT/ squashfs-root/ cp -r COPY_OVER_TO_CHROOT/ squashfs-root/
}
chrootr() {
## Set Xephyr and set chrooting mounts ## Set Xephyr and set chrooting mounts
Xephyr -resizeable -screen "${RES}" "${ID}" & Xephyr -resizeable -screen "${RES}" "${ID}" &