Skip to content
Snippets Groups Projects
Commit ae7169e8 authored by Bob Mottram's avatar Bob Mottram
Browse files

Generic image setup

parent fb676a24
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -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)
......
......@@ -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 /
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment