Permalink
Browse files

Added sanity checks

  • Loading branch information...
laurivosandi committed Mar 12, 2015
1 parent f2f4478 commit 5796c3f4a35a0df3bdddb6b4d12796a9af5094d7
Showing with 50 additions and 16 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 README.rst
  3. +11 −0 buildroot/overlay/sbin/init
  4. +34 −14 buildroot/overlay/sbin/provision
View
@@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.goutputstream*
# C extensions
*.so
View
@@ -11,14 +11,16 @@ and LXC containers.
Features
--------
* Deploy customized Ubuntu/Debian/Fedora workstation in 5 minutes
* Prepare template of your favourite Linux based OS using LXC
* Deploy customized OS in 5 minutes
* Deploy hundreds of machines simultanously within same timeframe
* Perform incremental upgrades
* Persistent Btrfs subvolumes for home folders, Puppet keys etc
Installation
------------
First set up machine with Ubuntu 14.04 LTS on top of btrfs filesystem to
First set up machine with Ubuntu 14.04 LTS on top of Btrfs filesystem to
be used as snapshot server.
Before doing any filesystem magic ensure that you're running 3.16+ kernel.
@@ -4,6 +4,17 @@
mount -t proc none /proc
mount -t sysfs sysfs /sys
#################################################################
### There should be at least one network interface to proceed ###
#################################################################
if [ -z "$(ls /sys/class/net/ | grep -v '^lo$')" ]; then
dialog --msgbox "Butterknife was unable to detect any network interfaces,\
are you sure network interface is attached properly and we have drivers for it?" 0 0
exit 254
fi
udhcpc
while [ 1 ]; do
@@ -23,6 +23,19 @@ if [ -f $POOL_TEMPLATES/dirty ]; then
#done
fi
#######################################
### Check for presence of utilities ###
#######################################
for util in btrfs jq fdisk find ntfsresize; do
if [ -z "$(which $util)" ]; then
dialog --msgbox "Butterknife was unable to locate $util,\
are you sure the provisioning image was compiled properly?" 0 0
exit 253
else
echo "Found $util..."
fi
done
# These Bashisms are insane
for chunk in $(cat /proc/cmdline); do
case "$chunk" in
@@ -50,25 +63,33 @@ set -e # Bail on error
#############################
### Target disk selection ###
#############################
for disk in /dev/sd?; do
slug=$(echo $disk | cut -d "/" -f 3)
sector_count=$(cat /sys/block/$slug/size)
sector_size=$(cat /sys/block/$slug/queue/hw_sector_size)
# Hack around these dumbass cardreaders
if [ "$sector_count" == "0" ]; then
continue
if [ -z "$(ls /sys/class/block/" ]; then
dialog --msgbox "Butterknife was unable to detect any harddisks,\
are you sure harddisk is connected and we have drivers for it?" 0 0
exit 255
fi
for disk in /sys/class/block/*; do
if [ -d $disk/device ]; then
slug=$(basename $disk)
sector_count=$(cat $disk/size)
sector_size=$(cat $disk/queue/hw_sector_size)
# Hack around these dumbass cardreaders
if [ "$sector_count" == "0" ]; then
continue
fi
size=$(expr $sector_count / 1000000 \* $sector_size / 1000)G
echo "$slug \"$(cat $disk/device/model | xargs) ($size)\"";
fi
size=$(($sector_count / 1000000 \* $sector_size / 1000))G
echo "$disk \"$(cat /sys/block/$slug/device/model | xargs) ($size)\"";
done > /tmp/disks
dialog \
--menu "Target disk" 0 0 0 \
--file /tmp/disks \
2> /tmp/selected_disk
DISK=$(cat /tmp/selected_disk)
DISK_SLUG=$(echo $DISK | cut -d "/" -f 3)
DISK_SLUG=$(cat /tmp/selected_disk)
DISK=/dev/$DISK_SLUG
dialog --menu "Partitioning $DISK" 0 0 0 \
purge "Overwrite whole disk" \
@@ -80,7 +101,6 @@ dialog --menu "Partitioning $DISK" 0 0 0 \
# TODO: deploy "Deploy received template" \
# TODO: postinstall "Run postinstall scripts (reinstall GRUB)" \
# TODO: EFI way is not currently covered!
case $(cat /tmp/partitioning_method) in
unpartitioned)
@@ -102,9 +122,9 @@ for partition in $DISK?; do
partition_slug=$(echo $partition | cut -d "/" -f 3)
sector_count=$(cat /sys/block/$DISK_SLUG/$partition_slug/size)
sector_size=$(cat /sys/block/$DISK_SLUG/queue/hw_sector_size)
size=$(($sector_count / 1000000 \* $sector_size / 1000000))G
size=$(expr $sector_count / 1000000 \* $sector_size / 1000000)G
if [ $size == "0G" ]; then
size=$(($sector_count / 1000 \* $sector_size / 1000))M
size=$(expr $sector_count / 1000 \* $sector_size / 1000)M
fi
echo "$partition \"$size\"";
done > /tmp/partitions

0 comments on commit 5796c3f

Please sign in to comment.