checkin work so far on new install script
This commit is contained in:
parent
dce78f64ac
commit
a28ea7f847
@ -19,23 +19,91 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
RESOURCES=/InstallResources
|
||||
# Grab the boot device, which is either /dev/sda for usb or /dev/mmcblk0 for an sd card
|
||||
BOOT_DEVICE=$(mount | head -n 1 | cut -d '2' -f 1)
|
||||
main() {
|
||||
|
||||
#The currently booted device is $BOOT_DEVICE
|
||||
RESOURCES=/InstallResources
|
||||
# Grab the boot device, which is either /dev/sda for usb or /dev/mmcblk0 for an sd card
|
||||
BOOT_DEVICE=$(mount | head -n 1 | cut -d '2' -f 1)
|
||||
|
||||
echo "Expand or Install?"
|
||||
echo "Expand in place to fill the entire booted external device"
|
||||
echo "Install to another internal or external device besides the one we are booted from"
|
||||
echo "Installation allow for root encryption to be setup, but must target a external or internal device other than the currently booted device"
|
||||
echo "The currently booted device is ${BOOT_DEVICE}"
|
||||
while true; do
|
||||
read -p "[I]nstall or [E]xpand?" IE
|
||||
case $IE in
|
||||
[Ii]* ) install; break;;
|
||||
[Ee]* ) expand; break;;
|
||||
* ) echo "Please answer I or E";;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
#Now to pick the install target: internal, sd, or usb
|
||||
#if target is usb, and boot device is usb, target is sdb
|
||||
#and whether to enable crypto
|
||||
install() {
|
||||
|
||||
echo "Pick an install target. This can be the Internal Emmc, an SD card, or a USB device"
|
||||
echo "Please ensure you have only have the booted device and the desired target device inserted."
|
||||
echo "The currently booted device is ${BOOT_DEVICE}"
|
||||
while true; do
|
||||
read -p "[I]nternal Emmc, [S]D card, or [U]SB device?" ISU
|
||||
case $IE in
|
||||
[Ii]* ) $TARGET=/dev/mmcblk2; break;;
|
||||
[Ss]* ) $TARGET=/dev/mmcblk0; break;;
|
||||
[Uu]* ) $TARGET=USB; break;;
|
||||
* ) echo "Please answer I, S, or U";;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $TARGET == "USB" ]]
|
||||
then
|
||||
if [[ $BOOT_DEVICE == "/dev/sda" ]]
|
||||
then
|
||||
$TARGET=/dev/sdb
|
||||
else
|
||||
$TARGET=/dev/sda
|
||||
fi
|
||||
fi
|
||||
if [[ $TARGET == $BOOT_DEVICE ]]
|
||||
then
|
||||
echo "Can't install to booted device, please ensure you have only have the booted device and one single other inserted"
|
||||
exit
|
||||
fi
|
||||
|
||||
#Now on to the installation, basically copy InstallToInternal.sh
|
||||
|
||||
}
|
||||
|
||||
#simply expand to fill the current boot device
|
||||
expand() {
|
||||
|
||||
if [[ $BOOT_DEVICE == "/dev/mmcblk2" ]]
|
||||
then
|
||||
echo "Can't expand to fill internal emmc, install will have done this already"
|
||||
exit
|
||||
fi
|
||||
|
||||
#Make the boot partition fille the whole drive
|
||||
#Delete the partition
|
||||
sgdisk -d 2 $BOOT_DEVICE
|
||||
#Make new partition map entry, with full size
|
||||
sgdisk -N 2 $BOOT_DEVICE
|
||||
#Set the type to "data"
|
||||
sgdisk -t 2:0700 $BOOT_DEVICE
|
||||
#Name it "properly" - Probably not required, but looks nice
|
||||
sgdisk -c 2:Root $BOOT_DEVICE
|
||||
#Reload the partition mapping
|
||||
partprobe $BOOT_DEVICE
|
||||
#Force the filesystem to fill the new partition
|
||||
resize2fs -f ${BOOT_DEVICE}p2
|
||||
echo "/dev/${BOOT_DEVICE}p2 / ext4 defaults,noatime 0 1" > /etc/fstab
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo "Expand or Install?"
|
||||
echo "Expand in place to fill the entire booted external device"
|
||||
echo "Install to another internal or external device besides the one we are booted from"
|
||||
echo "Installation allow for root encryption to be setup, but must target a external or internal device other than the currently booted device"
|
||||
echo "The currently booted device is $BOOT_DEVICE"
|
||||
while true; do
|
||||
read -p "[I]nstall or [E]xpand?" IE
|
||||
case $IE in
|
||||
[Ii]* ) METHOD=INSTALL; break;;
|
||||
[Ee]* ) METHOD=EXPAND; break;;
|
||||
* ) echo "Please answer I or E";;
|
||||
esac
|
||||
done
|
||||
#call the main function, script technically starts here
|
||||
main "$@"; exit
|
||||
|
Loading…
Reference in New Issue
Block a user