Checked scripts for syntax errors using shellcheck.

This commit is contained in:
Maxim 2018-01-27 00:59:19 -06:00
parent 8a4c5fd6d7
commit 27b9bee38b
1 changed files with 45 additions and 44 deletions

View File

@ -19,14 +19,13 @@ genIso=$(which genisoimage) ## Iso maker
clear clear
if [[ $xyphr == "" ]] || [[ $sysLnx == "" ]] || \ if [[ $xyphr == "" ]] || [[ $sysLnx == "" ]] || \
[[ $squash == "" ]] || [[ $genIso == "" ]]; then [[ $squash == "" ]] || [[ $genIso == "" ]]; then
echo "## Missing some packages ##" echo -e "## Missing some packages ##\n" \
echo "Xephyr :" "${xyphr}" "Xephyr :" "${xyphr}\n" \
echo "Syslinux :" "${sysLnx}" "Syslinux :" "${sysLnx}\n" \
echo "Squashfs-tools :" "${squash}" "Squashfs-tools :" "${squash}\n" \
echo "Genisoimage :" "${genIso}" "Genisoimage :" "${genIso}\n" \
echo "" "Going to run :\n" \
echo "Going to run :" " apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y"
echo " apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y"
sleep 4 sleep 4
apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y apt-get install xserver-xephyr syslinux squashfs-tools genisoimage -y
getIso getIso
@ -66,14 +65,14 @@ getIso() {
" LTS : 16.04\n" \ " LTS : 16.04\n" \
" Non-LTS : 15.10\n" \ " Non-LTS : 15.10\n" \
"Be very sure you are correctly entering the version." "Be very sure you are correctly entering the version."
read -p "Version --> : " VERSION read -p "Version --> : " VERSION
clear clear
echo -e "## Get Architect ##\n" \ echo -e "## Get Architect ##\n" \
"What version would you like?\n" \ "What version would you like?\n" \
" 32bit : i386\n" \ " 32bit : i386\n" \
" 64bit : amd64\n" \ " 64bit : amd64\n" \
"Be very sure you are correctly entering the architect." "Be very sure you are correctly entering the architect."
read -p "Arch --> : " ARCH read -p "Arch --> : " ARCH
wget http://ubuntu-mini-remix.mirror.garr.it/mirrors/ubuntu-mini-remix/"${VERSION}"/ubuntu-mini-remix-"${VERSION}"-"${ARCH}".iso wget http://ubuntu-mini-remix.mirror.garr.it/mirrors/ubuntu-mini-remix/"${VERSION}"/ubuntu-mini-remix-"${VERSION}"-"${ARCH}".iso
else else
wget http://ubuntu-mini-remix.mirror.garr.it/mirrors/ubuntu-mini-remix/"${VERSION}"/ubuntu-mini-remix-"${VERSION}"-"${ARCH}".iso wget http://ubuntu-mini-remix.mirror.garr.it/mirrors/ubuntu-mini-remix/"${VERSION}"/ubuntu-mini-remix-"${VERSION}"-"${ARCH}".iso
@ -93,20 +92,15 @@ main() {
sleep 4 sleep 4
getIso getIso
elif [[ "${list}" != "" ]] && [ -d squashfs-root ]; then elif [[ "${list}" != "" ]] && [ -d squashfs-root ]; then
clear ANSR=""
echo -e "Both an iso and squashfs-root are present...\n" while [[ $ANSR != "1" ]] && [[ $ANSR != "2" ]] && [[ $ANSR != "3" ]]; do
"Which do you wish to use?" clear
read -p "1.) $(echo ./*.iso) echo -e "Both an iso and squashfs-root are present...\n"
2.) Use former session: squashfs-root "Which do you wish to use?\n" \
3.) Exit "1.) $(echo ./*.iso)\n" \
--> : " ANSR "2.) Use former session: squashfs-root\n" \
while [[ $ANSR != "1" ]] && [[ $ANSR != "2" ]] && \ "3.) Exit"
[[ $ANSR != "3" ]] read -p "--> : " ANSR
do
read -p "1.) $(echo ./*.iso)
2.) Use former session: squashfs-root
3.) Exit
--> : " ANSR
done done
if [[ $ANSR == "1" ]]; then if [[ $ANSR == "1" ]]; then
@ -118,16 +112,17 @@ main() {
exit exit
fi fi
elif [ -d squashfs-root ]; then elif [ -d squashfs-root ]; then
clear clear
echo "Squashfs-root directory found. Chrooting to directory." echo "Squashfs-root directory found. Chrooting to directory."
sleep 4 sleep 4
chrootr chrootr
elif [[ "${list}" != "" ]]; then elif [[ "${list}" != "" ]]; then
clear clear
echo "Iso(s) found. Will mount one and copying to proper file structure. Then will chroot in..." echo -e "Iso(s) found. Will mount one and copying to proper file structure.\n" \
sleep 4 "Then will chroot in..."
mountAndCopy sleep 4
chrootr mountAndCopy
chrootr
fi fi
} }
@ -137,13 +132,20 @@ mountAndCopy() {
## Prep filesystem ## Prep filesystem
isoList=($(find . -maxdepth 1 -name "*.iso" -printf '%P\n')) isoList=($(find . -maxdepth 1 -name "*.iso" -printf '%P\n'))
x=0; count="${#isoList[@]}"
for i in "${isoList[@]}"; do ANSR=""
echo "$x - ${i}"
((x++)) while [[ "${ANSR}" > "${count}" || "${ANSR}" < "0" ]]; do
x=0;
clear
for i in "${isoList[@]}"; do
echo "$x - ${i}"
((x++))
done
echo "Chose the ISO from above using the number."
read -p "-->: " ANSR
done done
echo "Chose the ISO from above using the number."
read -p "-->: " ANSR
echo "You chose : ${isoList[$ANSR]}" echo "You chose : ${isoList[$ANSR]}"
mount -o loop ./"${isoList[$ANSR]}" mnt/ mount -o loop ./"${isoList[$ANSR]}" mnt/
cp -r mnt/. iso/ && \ cp -r mnt/. iso/ && \
@ -189,15 +191,12 @@ setConfigs() {
sed -i 14s/Ubuntu/"${lvUSER}"/g squashfs-root/etc/casper.conf sed -i 14s/Ubuntu/"${lvUSER}"/g squashfs-root/etc/casper.conf
sed -i 5,7s/ubuntu/"${lvUSER}"/g squashfs-root/etc/casper.conf sed -i 5,7s/ubuntu/"${lvUSER}"/g squashfs-root/etc/casper.conf
## Recreate manifest and clean it Note: MUST be after all setting changes ## Recreate manifest and clean it Note: MUST be after all setting changes
chroot squashfs-root/ dpkg-query -W --showformat="${Package} ${VERSION}\n" | sudo tee iso/casper/filesystem.manifest chroot squashfs-root/ dpkg-query -W --showformat="${Package} ${VERSION}\n" | sudo tee iso/casper/filesystem.manifest
cp -v iso/casper/filesystem.manifest iso/casper/filesystem.manifest-desktop cp -v iso/casper/filesystem.manifest iso/casper/filesystem.manifest-desktop
for i in $REMOVE for i in $REMOVE; do
do
sed -i "/${i}/d" iso/casper/filesystem.manifest-desktop sed -i "/${i}/d" iso/casper/filesystem.manifest-desktop
done done
genSqush genSqush
} }
@ -218,6 +217,8 @@ genSqush() {
genIsoImg() { genIsoImg() {
## Generate Iso ## Generate Iso
cd iso/ cd iso/
sudo mkisofs -D -r -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../"${NAME}".iso . sudo mkisofs -D -r -cache-inodes -J -l -b isolinux/isolinux.bin -c \
isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o \
../"${NAME}".iso .
} }
rootNisoChk rootNisoChk