Commit da9a01de authored by Dan Johansen's avatar Dan Johansen

Trying to make the script less verbose when creating partitions and cleaning up

parent 6e3f8014
...@@ -9,12 +9,12 @@ This script is "interactive". Meaning that it asks you questions when run to cus ...@@ -9,12 +9,12 @@ This script is "interactive". Meaning that it asks you questions when run to cus
* wget * wget
* git * git
* systemd * systemd
* ncurses * dialog
## Installing: ## Installing:
To use this script, please make sure that the following is correct: To use this script, please make sure that the following is correct:
* /var/tmp/ is present. * your default Shell is Bash.
* an SD card with at least 4 GB storage is plugged in. * an SD card with at least 4 GB storage is plugged in.
## Known Issues: ## Known Issues:
...@@ -24,10 +24,10 @@ To use this script, please make sure that the following is correct: ...@@ -24,10 +24,10 @@ To use this script, please make sure that the following is correct:
To use this script, simple run it as normal user after you make it executable: To use this script, simple run it as normal user after you make it executable:
``` ```
chmod +x manjaro-arm-installer chmod +x manjaro-arm-installer
sh manjaro-arm-installer ./manjaro-arm-installer
``` ```
## other notes: ## Other notes:
This script will soon by available as a **Arch** (*pkg.tar.xz*) package in my **Manjaro Strit** repo. This script will soon by available as a **Arch** (*pkg.tar.xz*) package in my **Manjaro Strit** repo.
This script **should** be distro-agnostic, which means you can install *Manjaro ARM* from **any** distro, as long as the dependencies are met. This script **should** be distro-agnostic, which means you can install *Manjaro ARM* from **any** distro, as long as the dependencies are met.
...@@ -87,7 +87,7 @@ create_install() { ...@@ -87,7 +87,7 @@ create_install() {
# fetch and extract rootfs # fetch and extract rootfs
msg "Downloading latest $ARCH rootfs..." msg "Downloading latest $ARCH rootfs..."
cd $TMPDIR cd $TMPDIR
wget https://www.strits.dk/files/Manjaro-ARM-$ARCH-latest.tar.gz wget https://www.strits.dk/files/Manjaro-ARM-$ARCH-latest.tar.gz 1> /dev/null 2>&1
msg "Extracting $ARCH rootfs..." msg "Extracting $ARCH rootfs..."
sudo bsdtar -xpf $TMPDIR/Manjaro-ARM-$ARCH-latest.tar.gz -C $TMPDIR/root sudo bsdtar -xpf $TMPDIR/Manjaro-ARM-$ARCH-latest.tar.gz -C $TMPDIR/root
...@@ -101,8 +101,8 @@ create_install() { ...@@ -101,8 +101,8 @@ create_install() {
sudo systemd-nspawn -D $TMPDIR/root pacman -S base $PKG_DEVICE $PKG_EDITION lsb-release --needed --noconfirm sudo systemd-nspawn -D $TMPDIR/root pacman -S base $PKG_DEVICE $PKG_EDITION lsb-release --needed --noconfirm
# restore original mirrorlist to host system # restore original mirrorlist to host system
sudo mv /etc/pacman.d/mirrorlist-orig /etc/pacman.d/mirrorlist #sudo mv /etc/pacman.d/mirrorlist-orig /etc/pacman.d/mirrorlist
sudo pacman -Syy #sudo pacman -Syy
msg "Enabling services..." msg "Enabling services..."
# Enable services # Enable services
...@@ -178,15 +178,15 @@ prepare_card () { ...@@ -178,15 +178,15 @@ prepare_card () {
# For Raspberry Pi devices # For Raspberry Pi devices
if [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "rpi3" ]]; then if [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "rpi3" ]]; then
#partition with boot and root #partition with boot and root
sudo parted -s $SDCARD mklabel msdos sudo parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
sudo parted -s $SDCARD mkpart primary fat32 0% 100M sudo parted -s $SDCARD mkpart primary fat32 0% 100M 1> /dev/null 2>&1
START=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/start` START=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/start`
SIZE=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/size` SIZE=`cat /sys/block/$DEV_NAME/${DEV_NAME}1/size`
END_SECTOR=$(expr $START + $SIZE) END_SECTOR=$(expr $START + $SIZE)
sudo parted -s $SDCARD mkpart primary ext4 "${END_SECTOR}s" 100% sudo parted -s $SDCARD mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
sudo mkfs.vfat "${SDCARD}1" sudo mkfs.vfat "${SDCARD}1" 1> /dev/null 2>&1
sudo mkfs.ext4 "${SDCARD}2" sudo mkfs.ext4 "${SDCARD}2" 1> /dev/null 2>&1
#Mount SD card #Mount SD card
mkdir -p $TMPDIR/root mkdir -p $TMPDIR/root
...@@ -197,13 +197,13 @@ prepare_card () { ...@@ -197,13 +197,13 @@ prepare_card () {
# For Odroid devices # For Odroid devices
elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then
#Clear first 8mb #Clear first 8mb
sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 1> /dev/null 2>&1
#partition with a single root partition #partition with a single root partition
sudo parted -s $SDCARD mklabel msdos sudo parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
sudo parted -s $SDCARD mkpart primary ext4 0% 100% sudo parted -s $SDCARD mkpart primary ext4 0% 100% 1> /dev/null 2>&1
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 1> /dev/null 2>&1
#Mount SD card #Mount SD card
mkdir -p $TMPDIR/root mkdir -p $TMPDIR/root
...@@ -214,13 +214,13 @@ prepare_card () { ...@@ -214,13 +214,13 @@ prepare_card () {
elif [[ "$DEVICE" = "pinebook" ]]; then elif [[ "$DEVICE" = "pinebook" ]]; then
#Clear first 8mb #Clear first 8mb
sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 1> /dev/null 2>&1
#partition with a single root partition #partition with a single root partition
sudo parted -s $SDCARD mklabel msdos sudo parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
sudo parted -s $SDCARD mkpart primary ext4 0% 100% sudo parted -s $SDCARD mkpart primary ext4 0% 100% 1> /dev/null 2>&1
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 1> /dev/null 2>&1
# Mount SD card # Mount SD card
mkdir -p $TMPDIR/root mkdir -p $TMPDIR/root
...@@ -231,13 +231,13 @@ prepare_card () { ...@@ -231,13 +231,13 @@ prepare_card () {
elif [[ "$DEVICE" = "rockpro64" ]]; then elif [[ "$DEVICE" = "rockpro64" ]]; then
#Clear first 8mb #Clear first 8mb
sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 sudo dd if=/dev/zero of=${SDCARD} bs=1M count=8 1> /dev/null 2>&1
#partition with a single root partition #partition with a single root partition
sudo parted -s $SDCARD mklabel msdos sudo parted -s $SDCARD mklabel msdos 1> /dev/null 2>&1
sudo parted -s $SDCARD mkpart primary ext4 0% 100% sudo parted -s $SDCARD mkpart primary ext4 0% 100% 1> /dev/null 2>&1
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 sudo mkfs.ext4 -O ^metadata_csum,^64bit ${SDCARD}1 1> /dev/null 2>&1
# Mount SD card # Mount SD card
mkdir -p $TMPDIR/root mkdir -p $TMPDIR/root
...@@ -257,42 +257,42 @@ cleanup () { ...@@ -257,42 +257,42 @@ cleanup () {
sudo umount $TMPDIR/root sudo umount $TMPDIR/root
sudo umount $TMPDIR/boot sudo umount $TMPDIR/boot
sudo rm -r $TMPDIR/root $TMPDIR/boot sudo rm -r $TMPDIR/root $TMPDIR/boot
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
# For Odroid devices # For Odroid devices
elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then elif [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "oc2" ]] || [[ "$DEVICE" = "xu4" ]]; then
#flash bootloader #flash bootloader
cd $TMPDIR/root/boot/ cd $TMPDIR/root/boot/
sudo ./sd_fusing.sh $SDCARD sudo ./sd_fusing.sh $SDCARD 1> /dev/null 2>&1
cd ~ cd ~
#clean up #clean up
sudo umount $TMPDIR/root sudo umount $TMPDIR/root
sudo rm -r $TMPDIR/root sudo rm -r $TMPDIR/root
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
# For pinebook device # For pinebook device
elif [[ "$DEVICE" = "pinebook" ]]; then elif [[ "$DEVICE" = "pinebook" ]]; then
#flash bootloader #flash bootloader
sudo dd if=$TMPDIR/root/boot/u-boot-sunxi-with-spl-$DEVICE.bin of=${SDCARD} bs=8k seek=1 sudo dd if=$TMPDIR/root/boot/u-boot-sunxi-with-spl-$DEVICE.bin of=${SDCARD} bs=8k seek=1 1> /dev/null 2>&1
#clean up #clean up
sudo umount $TMPDIR/root sudo umount $TMPDIR/root
sudo rm -r $TMPDIR/root sudo rm -r $TMPDIR/root
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
# For rockpro64 device # For rockpro64 device
elif [[ "$DEVICE" = "rockpro64" ]]; then elif [[ "$DEVICE" = "rockpro64" ]]; then
#flash bootloader #flash bootloader
sudo dd if=$TMPDIR/root/boot/idbloader.img of=${SDCARD} seek=64 conv=notrunc sudo dd if=$TMPDIR/root/boot/idbloader.img of=${SDCARD} seek=64 conv=notrunc 1> /dev/null 2>&1
sudo dd if=$TMPDIR/root/boot/uboot.img of=${SDCARD} seek=16384 conv=notrunc sudo dd if=$TMPDIR/root/boot/uboot.img of=${SDCARD} seek=16384 conv=notrunc 1> /dev/null 2>&1
sudo dd if=$TMPDIR/root/boot/trust.img of=${SDCARD} seek=24576 conv=notrunc sudo dd if=$TMPDIR/root/boot/trust.img of=${SDCARD} seek=24576 conv=notrunc 1> /dev/null 2>&1
#clean up #clean up
sudo umount $TMPDIR/root sudo umount $TMPDIR/root
sudo rm -r $TMPDIR/root sudo rm -r $TMPDIR/root
sudo partprobe $SDCARD sudo partprobe $SDCARD 1> /dev/null 2>&1
fi fi
} }
...@@ -314,21 +314,26 @@ fi ...@@ -314,21 +314,26 @@ fi
# Using ncurses to ask for user input for variables # Using ncurses to ask for user input for variables
DEVICE=$(dialog --clear --title "Manjaro-ARM Installer" \ DEVICE=$(dialog --clear --title "Manjaro ARM Installer" \
--menu "Choose a device:" 20 51 4 \ --menu "Choose a device:" 20 51 6 \
"rpi3" "Raspberry Pi 3" \ "rpi3" "Raspberry Pi 3" \
"oc2" "Odroid C2" \ "oc2" "Odroid C2" \
"pinebook" "PineBook" 3>&1 1>&2 2>&3 3>&-) "pinebook" "PineBook" \
"rpi2" "Raspberry Pi 2 (not maintained)" \
"oc1" "Odroid C1/C1+ (not maintained)" \
"xu4" "Odroid XU4 (not maintained)" 3>&1 1>&2 2>&3 3>&-)
#The if statement makes sure that the user has put in something in the previous prompt. If not (left blank or pressed cancel) the script will end #The if statement makes sure that the user has put in something in the previous prompt. If not (left blank or pressed cancel) the script will end
if [ ! -z "$DEVICE" ] if [ ! -z "$DEVICE" ]
then then
EDITION=$(dialog --clear --title "Manjaro-ARM Installer" \ EDITION=$(dialog --clear --title "Manjaro ARM Installer" \
--menu "Choose an edition:" 20 50 4 \ --menu "Choose an edition:" 20 50 5 \
"minimal" "Minimal Edition (Just CLI)" \ "minimal" "Minimal Edition (Just CLI)" \
"lxqt" "Full LXQT Desktop and apps (lightweight)" \ "lxqt" "Full LXQT Desktop and apps (lightweight)" \
"kde" "Full KDE Desktop (Heavy)" 3>&1 1>&2 2>&3 3>&-) "kde" "Full KDE Desktop (Heavy)" \
"mate" "Full MATE desktop and apps (lightweight, not maintained)" \
"i3" "Mininal i3 WM with apps (very light)" 3>&1 1>&2 2>&3 3>&-)
else else
clear clear
...@@ -338,7 +343,7 @@ fi ...@@ -338,7 +343,7 @@ fi
if [ ! -z "$EDITION" ] if [ ! -z "$EDITION" ]
then then
USER=$(dialog --clear --title "Manjaro-ARM Installer" \ USER=$(dialog --clear --title "Manjaro ARM Installer" \
--inputbox "Enter username:" 8 50 \ --inputbox "Enter username:" 8 50 \
3>&1 1>&2 2>&3 3>&-) 3>&1 1>&2 2>&3 3>&-)
else else
...@@ -351,8 +356,8 @@ fi ...@@ -351,8 +356,8 @@ fi
if [ ! -z "$USER" ] if [ ! -z "$USER" ]
then then
PASSWORD=$(dialog --clear --title "Manjaro-ARM Installer" \ PASSWORD=$(dialog --clear --title "Manjaro ARM Installer" \
--passwordbox "Enter Password:" 8 50 \ --passwordbox "Enter Password for $USER:" 8 50 \
3>&1 1>&2 2>&3 3>&- \ 3>&1 1>&2 2>&3 3>&- \
) )
else else
...@@ -364,7 +369,7 @@ fi ...@@ -364,7 +369,7 @@ fi
if [ ! -z "$PASSWORD" ] if [ ! -z "$PASSWORD" ]
then then
ROOTPASSWORD=$(dialog --clear --title "Manjaro-ARM Installer" \ ROOTPASSWORD=$(dialog --clear --title "Manjaro ARM Installer" \
--passwordbox "Enter Root Password:" 8 50 \ --passwordbox "Enter Root Password:" 8 50 \
3>&1 1>&2 2>&3 3>&- \ 3>&1 1>&2 2>&3 3>&- \
) )
...@@ -385,9 +390,9 @@ W=() ...@@ -385,9 +390,9 @@ W=()
while read -r line; do while read -r line; do
let i=$i+1 let i=$i+1
W+=($line "") W+=($line "")
done < $(lsblk -adn -o NAME) done < <( lsblk -adn -o NAME )
SDCARD=$(dialog --title "Manjaro-ARM Installer" \ SDCARD=$(dialog --title "Manjaro ARM Installer" \
--menu "Chose your SDCard" 20 50 4 \ --menu "Chose your SDCard" 20 50 10 \
"${W[@]}" 3>&2 2>&1 1>&3) "${W[@]}" 3>&2 2>&1 1>&3)
# add /dev/ to the selected option above # add /dev/ to the selected option above
...@@ -403,7 +408,7 @@ clear ...@@ -403,7 +408,7 @@ clear
echo "Device = $DEVICE" echo "Device = $DEVICE"
echo "Edition = $EDITION" echo "Edition = $EDITION"
echo "User name = $USER" echo "User name = $USER"
echo "Password = ********** ($PASSWORD)" #password is here for testing purposes echo "Password for $USER = ********** ($PASSWORD)" #password is here for testing purposes
echo "Root Password = ********** ($ROOTPASSWORD)" #password is here for testing purposes echo "Root Password = ********** ($ROOTPASSWORD)" #password is here for testing purposes
echo "SDCard = $SDCARD" echo "SDCard = $SDCARD"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment