Skip to content

Instantly share code, notes, and snippets.

@renatofrota
Last active May 2, 2022 12:34
Show Gist options
  • Save renatofrota/c15be47cd445a405daa8e20484bc8969 to your computer and use it in GitHub Desktop.
Save renatofrota/c15be47cd445a405daa8e20484bc8969 to your computer and use it in GitHub Desktop.
Deploy Chrome OS (Brunch Framework)
#!/bin/bash
# https://bit.ly/chrome-os-install-sh
# Script to deploy Chrome OS (using Brunch Framework)
# Author renatofrota: https://github.com/renatofrota/
# Brunch Framework: https://github.com/sebanc/brunch/
deployed() {
echo "Deployment complete. Install script by Renato Frota. Donate:"
echo "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R58RLRMM8YM6U"
xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R58RLRMM8YM6U"
}
wget -q --spider http://google.com || { echo "You are offline. Connect to internet first." && exit 1 ; }
sudo apt-add-repository -y ppa:danielrichter2007/grub-customizer || exit $?
sudo apt-get update || exit $?
sudo apt-get install -y pv || exit $?
sudo apt-get install -y cgpt || exit $?
sudo apt-get install -y dmenu || exit $?
sudo apt-get install -y xclip || exit $?
sudo apt-get install -y grub-customizer || exit $?
recoveryimage=$(sudo ls *.bin | dmenu -l 10 -p "Select image:") || exit $?
dstdevice=$(sudo lsblk -prno type,name | grep -v 'loop' | dmenu -nf 'red' -nb 'white' -sf 'white' -sb 'red' -l 30 -p "Select destination partition/device:" | awk '{print $2}') || exit $?
type=$(sudo lsblk -pnro type,name | grep -w $dstdevice | awk '{print $1}')
confirm="n"
case $type in
part*)
echo -e "\n\n#####\n\nYou selected the PARTITION $dstdevice"
echo "Chrome OS diskimage will be generated at $dstdevice/chromeos.img"
echo -e "Partition details:\n"
sudo df -h $dstdevice
echo ""
echo -n "Enter size for the image (in GBs): "
read size
size=$(echo $size | awk '{print int($1)}')
mkdir -p ~/tmpmount
sudo umount $dstdevice
sudo mount $dstdevice ~/tmpmount
sudo bash chromeos-install.sh -src $recoveryimage -dst ~/tmpmount/chromeos.img -s $size | tee /tmp/chromeinstall.log
sudo umount ~/tmpmount
grep -A100 'menuentry' /tmp/chromeinstall.log | grep -B100 initrd | grep -v menuentry | xclip -selection clipboard
echo "Now, grub-customizer will open. Create a new entry, name it Chrome OS, and paste data from your clipboard (press ctrl+v)"
echo -n "Press enter to open grub-customizer"
read proceed
sudo grub-customizer
deployed
exit
;;
disk)
echo -e "\n\n#####\n\nYou selected the DISK $dstdevice"
echo "Disk $dstdevice will be wiped out (ALL PARTITIONS) and Chrome OS will be installed on it"
echo -e "HEY! All below will be gone. Forever!\n"
sudo lsblk $dstdevice -p
echo ""
echo -n "Do you confirm (y/n)? "
read confirm
if [[ "$confirm" =~ (y|Y) ]]; then
sudo bash chromeos-install.sh -src $recoveryimage -dst $dstdevice
deployed
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment