2015-11-20 17:09:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Creates a debian image using vmdebootstrap
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-11-20 22:43:03 +01:00
|
|
|
IMAGE_TYPE='beaglebone'
|
2015-11-20 17:09:21 +01:00
|
|
|
CURR_DIR=$(pwd)
|
|
|
|
BUILD_DIR=~/.tmp_freedombone_build
|
2015-11-20 22:43:03 +01:00
|
|
|
VMDEBOOTSTRAP_REPO=git://git.liw.fi/vmdebootstrap
|
|
|
|
VMDEBOOTSTRAP_VERSION=0.8
|
|
|
|
MAKEFILE=freedombone-image-makefile
|
2015-11-20 17:09:21 +01:00
|
|
|
|
2015-11-20 22:43:03 +01:00
|
|
|
USERNAME=$(echo $USER)
|
|
|
|
PASSWORD='freedombone'
|
|
|
|
|
|
|
|
# IP address of the router (gateway)
|
|
|
|
ROUTER_IP_ADDRESS="192.168.1.254"
|
|
|
|
|
|
|
|
# The fixed IP address of the Beaglebone Black (or other SBC) on your local network
|
|
|
|
BOX_IP_ADDRESS="192.168.1.55"
|
|
|
|
|
|
|
|
# DNS
|
|
|
|
NAMESERVER1='213.73.91.35'
|
|
|
|
NAMESERVER2='85.214.20.141'
|
|
|
|
|
|
|
|
while [[ $# > 1 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
;;
|
|
|
|
-t|--target|--board)
|
|
|
|
shift
|
|
|
|
IMAGE_TYPE="$1"
|
|
|
|
;;
|
|
|
|
-u|--user|--username)
|
|
|
|
shift
|
|
|
|
USERNAME="$1"
|
|
|
|
;;
|
|
|
|
-p|--password)
|
|
|
|
shift
|
|
|
|
PASSWORD="$1"
|
|
|
|
;;
|
|
|
|
# Box static IP address on the LAN
|
|
|
|
--ip)
|
|
|
|
shift
|
|
|
|
BOX_IP_ADDRESS="$1"
|
|
|
|
;;
|
|
|
|
# Router IP address on the LAN
|
|
|
|
--iprouter)
|
|
|
|
shift
|
|
|
|
ROUTER_IP_ADDRESS="$1"
|
|
|
|
;;
|
|
|
|
# nameserver 1
|
|
|
|
--ns1|--nameserver1)
|
|
|
|
shift
|
|
|
|
NAMESERVER1="$1"
|
|
|
|
;;
|
|
|
|
# nameserver 2
|
|
|
|
--ns2|--nameserver2)
|
|
|
|
shift
|
|
|
|
NAMESERVER2="$1"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rm $CURR_DIR/*.img.bz2
|
2015-11-20 17:09:21 +01:00
|
|
|
rm $CURR_DIR/*.img
|
2015-11-20 22:43:03 +01:00
|
|
|
rm $CURR_DIR/*.sig
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
if [ -d $BUILD_DIR ]; then
|
2015-11-20 22:43:03 +01:00
|
|
|
rm -rf $BUILD_DIR
|
2015-11-20 17:09:21 +01:00
|
|
|
fi
|
|
|
|
mkdir -p $BUILD_DIR
|
2015-11-20 22:43:03 +01:00
|
|
|
if [ -f /usr/local/bin/$MAKEFILE ]; then
|
|
|
|
cp /usr/local/bin/$MAKEFILE $BUILD_DIR/Makefile
|
2015-11-20 17:09:21 +01:00
|
|
|
else
|
2015-11-20 22:43:03 +01:00
|
|
|
cp /usr/bin/$MAKEFILE $BUILD_DIR/Makefile
|
2015-11-20 17:09:21 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
cp -r /etc/freedombone/* $BUILD_DIR
|
|
|
|
cd $BUILD_DIR
|
|
|
|
|
|
|
|
rm -rf vendor
|
|
|
|
mkdir vendor
|
|
|
|
if [ -d vendor/vmdebootstrap ] ; then
|
|
|
|
(cd vendor/vmdebootstrap; git checkout .; git pull)
|
|
|
|
else
|
2015-11-20 22:43:03 +01:00
|
|
|
git clone $VMDEBOOTSTRAP_REPO vendor/vmdebootstrap
|
2015-11-20 17:09:21 +01:00
|
|
|
fi
|
|
|
|
cd vendor/vmdebootstrap
|
2015-11-20 22:43:03 +01:00
|
|
|
git checkout tags/vmdebootstrap-${VMDEBOOTSTRAP_VERSION}
|
|
|
|
git checkout -b tags/vmdebootstrap-${VMDEBOOTSTRAP_VERSION}
|
2015-11-20 17:09:21 +01:00
|
|
|
for f in ../../vendor-patches/vmdebootstrap/* ; do
|
|
|
|
echo applying $(basename $f)
|
|
|
|
patch -p1 < $f
|
|
|
|
done
|
|
|
|
|
|
|
|
cd $BUILD_DIR
|
2015-11-20 22:43:03 +01:00
|
|
|
make $IMAGE_TYPE \
|
|
|
|
USERNAME="$USERNAME" \
|
|
|
|
PASSWORD="$PASSWORD" \
|
|
|
|
ROUTER_IP_ADDRESS="$ROUTER_IP_ADDRESS" \
|
|
|
|
BOX_IP_ADDRESS="$BOX_IP_ADDRESS" \
|
|
|
|
NAMESERVER1="$NAMESERVER1" \
|
|
|
|
NAMESERVER2="$NAMESERVER2"
|
|
|
|
|
2015-11-21 11:29:10 +01:00
|
|
|
shopt -s nullglob
|
|
|
|
imgfiles=(build/freedombone*.img)
|
|
|
|
if [ ${#imgfiles[@]} -eq 0 ]; then
|
|
|
|
echo 'Image was not created'
|
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mv build/freedombone*.bz2 $CURR_DIR
|
|
|
|
mv build/freedombone*.img $CURR_DIR
|
|
|
|
mv build/freedombone*.sig $CURR_DIR
|
2015-11-20 17:09:21 +01:00
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
|
2015-11-21 11:29:10 +01:00
|
|
|
clear
|
|
|
|
echo '
|
|
|
|
Image was created
|
|
|
|
'
|
|
|
|
ls -lh freedombone*.img freedombone*.sig freedombone*.bz2
|
|
|
|
|
2015-11-20 17:09:21 +01:00
|
|
|
exit 0
|