Generic image setup

This commit is contained in:
Bob Mottram 2015-11-23 10:33:45 +00:00
parent fb676a24fa
commit ae7169e88f
4 changed files with 42 additions and 1 deletions

Binary file not shown.

View File

@ -65,6 +65,9 @@ SSH_PUBKEY="no"
# interactive mode
INTERACTIVE="no"
# Whether this is a generic image for mass redistribution on the interwebs
GENERIC_IMAGE="no"
while [[ $# > 1 ]]
do
key="$1"
@ -130,6 +133,10 @@ case $key in
shift
INTERACTIVE="$1"
;;
-g|--generic)
shift
GENERIC_IMAGE="$1"
;;
*)
# unknown option
;;
@ -182,7 +189,8 @@ make $IMAGE_TYPE \
PROJECT_NAME="$PROJECT_NAME" \
CONFIG_FILENAME="$CONFIG_FILENAME" \
IMAGE_SIZE="$IMAGE_SIZE" \
SSH_PUBKEY="$SSH_PUBKEY"
SSH_PUBKEY="$SSH_PUBKEY" \
GENERIC_IMAGE="$GENERIC_IMAGE"
shopt -s nullglob
imgfiles=(build/${PROJECT_NAME}*.img)

View File

@ -50,6 +50,9 @@ CONFIG_FILENAME=
# Optional ssh public key to allow
SSH_PUBKEY="no"
# Whether this is a generic image for mass redistribution on the interwebs
GENERIC_IMAGE="no"
enable_eatmydata_override() {
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
if [ -x $rootdir/usr/bin/eatmydata ] && \
@ -181,6 +184,33 @@ admin_user_sudo() {
echo "$MY_USERNAME ALL=(ALL) ALL" >> $rootdir/etc/sudoers
}
create_generic_image() {
if [[ $GENERIC_IMAGE == "no" ]]; then
return
fi
# Don't install any configuration. This will be a base system
CONFIG_FILENAME=
# The presence of this file indicates that the initial
# setup has not yet been completed
touch $rootdir/home/$MY_USERNAME/.initial_setup
cat >> /home/$MY_USERNAME/.bashrc <<EOF
if [ -f ~/.initial_setup ]; then
clear
echo '>>> Freedombone system initial setup <<<'
echo ''
echo 'The first thing you need to do is to change your password, otherwise'
echo 'your system will be insecure. Your password should be at least 10'
echo 'characters long and contain letters and numbers. Do this now:'
passwd
sudo su
freedombone menuconfig
rm ~/.initial_setup
fi
EOF
}
continue_installation() {
# If a configuration file exists then run with it
# otherwise the interactive installer can be used
@ -298,6 +328,7 @@ chroot "$rootdir" apt-get update
configure_ssh
configure_networking
admin_user_sudo
create_generic_image
continue_installation
cd /

View File

@ -45,6 +45,7 @@ export NAMESERVER2
export PROJECT_NAME
export CONFIG_FILENAME
export SSH_PUBKEY
export GENERIC_IMAGE
# Locate vmdebootstrap program fetched in Makefile
basedir=`pwd`
@ -144,6 +145,7 @@ sudo sed -i "s|NAMESERVER2=.*|NAMESERVER2=${NAMESERVER1}|g" $TEMP_CUSTOMISE
sudo sed -i "s|PROJECT_NAME=.*|PROJECT_NAME=${PROJECT_NAME}|g" $TEMP_CUSTOMISE
sudo sed -i "s|CONFIG_FILENAME=.*|CONFIG_FILENAME=${CONFIG_FILENAME}|g" $TEMP_CUSTOMISE
sudo sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" $TEMP_CUSTOMISE
sudo sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" $TEMP_CUSTOMISE
echo "starting $VMDEBOOTSTRAP"
# Run vmdebootstrap script to create image