Debian only image creation
This commit is contained in:
parent
4c853944e1
commit
bb8b0c9c2d
Binary file not shown.
|
@ -97,6 +97,9 @@ ONION_ONLY="no"
|
|||
#MIRROR='http://httpredir.debian.org/debian'
|
||||
MIRROR='http://ftp.de.debian.org/debian'
|
||||
|
||||
# Whether to only install debian but nothing else
|
||||
DEBIAN_INSTALL_ONLY='no'
|
||||
|
||||
mesh_router_setup_script() {
|
||||
# create a setup script for a mesh router
|
||||
mesh_script_filename=$1
|
||||
|
@ -122,115 +125,119 @@ mesh_router_setup_script() {
|
|||
|
||||
while [[ $# > 1 ]]
|
||||
do
|
||||
key="$1"
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
-c|--config)
|
||||
shift
|
||||
CONFIG_FILENAME="$1"
|
||||
if [ ! -f $CONFIG_FILENAME ]; then
|
||||
echo $"Config file $CONFIG_FILENAME not found"
|
||||
exit 3
|
||||
fi
|
||||
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
|
||||
;;
|
||||
-t|--target|--board)
|
||||
shift
|
||||
IMAGE_TYPE="$1"
|
||||
;;
|
||||
-u|--user|--username)
|
||||
shift
|
||||
USERNAME="$1"
|
||||
;;
|
||||
-p|--password)
|
||||
shift
|
||||
PASSWORD="$1"
|
||||
if [ ${#PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
|
||||
echo $"Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters"
|
||||
exit 3628
|
||||
fi
|
||||
;;
|
||||
--sshkey|--sshpubkey|--pubkey)
|
||||
shift
|
||||
SSH_PUBKEY="$1"
|
||||
;;
|
||||
-s|--size)
|
||||
shift
|
||||
IMAGE_SIZE="$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"
|
||||
;;
|
||||
-i|--interactive)
|
||||
shift
|
||||
INTERACTIVE="$1"
|
||||
;;
|
||||
-g|--generic)
|
||||
shift
|
||||
GENERIC_IMAGE="$1"
|
||||
;;
|
||||
--minimal)
|
||||
shift
|
||||
MINIMAL_INSTALL="$1"
|
||||
;;
|
||||
--ssh|--sshport)
|
||||
shift
|
||||
SSH_PORT="$1"
|
||||
;;
|
||||
-v|--variant)
|
||||
shift
|
||||
VARIANT="$1"
|
||||
;;
|
||||
-o|--onion)
|
||||
shift
|
||||
ONION_ONLY="$1"
|
||||
;;
|
||||
-r|--repo|--repository)
|
||||
shift
|
||||
PROJECT_REPO="$1"
|
||||
;;
|
||||
-m|--mirror)
|
||||
shift
|
||||
MIRROR="$1"
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
case $key in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
-c|--config)
|
||||
shift
|
||||
CONFIG_FILENAME="$1"
|
||||
if [ ! -f $CONFIG_FILENAME ]; then
|
||||
echo $"Config file $CONFIG_FILENAME not found"
|
||||
exit 3
|
||||
fi
|
||||
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
|
||||
;;
|
||||
-t|--target|--board)
|
||||
shift
|
||||
IMAGE_TYPE="$1"
|
||||
;;
|
||||
-u|--user|--username)
|
||||
shift
|
||||
USERNAME="$1"
|
||||
;;
|
||||
-p|--password)
|
||||
shift
|
||||
PASSWORD="$1"
|
||||
if [ ${#PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
|
||||
echo $"Your password chould contain at least ${MINIMUM_PASSWORD_LENGTH} characters"
|
||||
exit 3628
|
||||
fi
|
||||
;;
|
||||
--sshkey|--sshpubkey|--pubkey)
|
||||
shift
|
||||
SSH_PUBKEY="$1"
|
||||
;;
|
||||
-s|--size)
|
||||
shift
|
||||
IMAGE_SIZE="$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"
|
||||
;;
|
||||
-i|--interactive)
|
||||
shift
|
||||
INTERACTIVE="$1"
|
||||
;;
|
||||
-g|--generic)
|
||||
shift
|
||||
GENERIC_IMAGE="$1"
|
||||
;;
|
||||
--minimal)
|
||||
shift
|
||||
MINIMAL_INSTALL="$1"
|
||||
;;
|
||||
--ssh|--sshport)
|
||||
shift
|
||||
SSH_PORT="$1"
|
||||
;;
|
||||
-v|--variant)
|
||||
shift
|
||||
VARIANT="$1"
|
||||
;;
|
||||
-o|--onion)
|
||||
shift
|
||||
ONION_ONLY="$1"
|
||||
;;
|
||||
-r|--repo|--repository)
|
||||
shift
|
||||
PROJECT_REPO="$1"
|
||||
;;
|
||||
-m|--mirror)
|
||||
shift
|
||||
MIRROR="$1"
|
||||
;;
|
||||
--debianonly|--basic|--minimal)
|
||||
shift
|
||||
DEBIAN_INSTALL_ONLY="$1"
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ $INTERACTIVE == "yes" || $INTERACTIVE == "y" || $INTERACTIVE == "Yes" ]]; then
|
||||
${PROJECT_NAME}-config --minimal "$MINIMAL_INSTALL"
|
||||
if [ -f freedombone.cfg ]; then
|
||||
CONFIG_FILENAME=freedombone.cfg
|
||||
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
|
||||
fi
|
||||
${PROJECT_NAME}-config --minimal "$MINIMAL_INSTALL"
|
||||
if [ -f freedombone.cfg ]; then
|
||||
CONFIG_FILENAME=freedombone.cfg
|
||||
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $GENERIC_IMAGE == "yes" ]]; then
|
||||
USERNAME=$GENERIC_IMAGE_USERNAME
|
||||
PASSWORD=$GENERIC_IMAGE_PASSWORD
|
||||
USERNAME=$GENERIC_IMAGE_USERNAME
|
||||
PASSWORD=$GENERIC_IMAGE_PASSWORD
|
||||
fi
|
||||
|
||||
# If this is a mesh variant then create an appropriate script
|
||||
|
@ -241,45 +248,45 @@ fi
|
|||
#fi
|
||||
|
||||
if [ ! $PASSWORD ]; then
|
||||
# generate a random password
|
||||
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||
# generate a random password
|
||||
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||
fi
|
||||
|
||||
# Move any existing images into a build subdirectory
|
||||
image_types=( xz img sig vdi qcow2 )
|
||||
for im in "${image_types[@]}"
|
||||
do
|
||||
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
if [ ! -d ${CURR_DIR}/build ]; then
|
||||
mkdir ${CURR_DIR}/build
|
||||
fi
|
||||
mv -f ${CURR_DIR}/${PROJECT_NAME}*.${im} ${CURR_DIR}/build
|
||||
fi
|
||||
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
if [ ! -d ${CURR_DIR}/build ]; then
|
||||
mkdir ${CURR_DIR}/build
|
||||
fi
|
||||
mv -f ${CURR_DIR}/${PROJECT_NAME}*.${im} ${CURR_DIR}/build
|
||||
fi
|
||||
done
|
||||
|
||||
# Delete anything which didn't move
|
||||
for im in "${image_types[@]}"
|
||||
do
|
||||
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
rm -f ${CURR_DIR}/${PROJECT_NAME}*.${im}
|
||||
fi
|
||||
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
rm -f ${CURR_DIR}/${PROJECT_NAME}*.${im}
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove any existing login credentials file
|
||||
if [ -f ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt ]; then
|
||||
rm ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
||||
rm ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
||||
fi
|
||||
|
||||
if [ -d $TEMPBUILD_DIR ]; then
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
fi
|
||||
mkdir -p $TEMPBUILD_DIR
|
||||
if [ -f /usr/local/bin/$MAKEFILE ]; then
|
||||
cp /usr/local/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||
cp /usr/local/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||
else
|
||||
cp /usr/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||
cp /usr/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||
fi
|
||||
|
||||
cp -r /etc/${PROJECT_NAME}/* $TEMPBUILD_DIR
|
||||
|
@ -288,63 +295,64 @@ chown -R $CURR_USER:$CURR_USER $TEMPBUILD_DIR
|
|||
cd $TEMPBUILD_DIR
|
||||
|
||||
if [[ $MINIMAL_INSTALL == "yes" ]]; then
|
||||
IMAGE_NAME='min'
|
||||
IMAGE_NAME='min'
|
||||
fi
|
||||
|
||||
if [[ $ONION_ONLY != "no" ]]; then
|
||||
IMAGE_NAME='onion'
|
||||
IMAGE_NAME='onion'
|
||||
fi
|
||||
|
||||
cd $TEMPBUILD_DIR
|
||||
make $IMAGE_TYPE \
|
||||
USERNAME="$USERNAME" \
|
||||
PASSWORD="$PASSWORD" \
|
||||
ROUTER_IP_ADDRESS="$ROUTER_IP_ADDRESS" \
|
||||
BOX_IP_ADDRESS="$BOX_IP_ADDRESS" \
|
||||
NAMESERVER1="$NAMESERVER1" \
|
||||
NAMESERVER2="$NAMESERVER2" \
|
||||
PROJECT_NAME="$PROJECT_NAME" \
|
||||
CONFIG_FILENAME="$CONFIG_FILENAME" \
|
||||
IMAGE_SIZE="$IMAGE_SIZE" \
|
||||
SSH_PUBKEY="$SSH_PUBKEY" \
|
||||
GENERIC_IMAGE="$GENERIC_IMAGE" \
|
||||
MINIMAL_INSTALL="$MINIMAL_INSTALL" \
|
||||
SSH_PORT="$SSH_PORT" \
|
||||
ONION_ONLY="$ONION_ONLY" \
|
||||
IMAGE_NAME="$IMAGE_NAME" \
|
||||
PROJECT_REPO="$PROJECT_REPO" \
|
||||
MIRROR="$MIRROR" \
|
||||
BUILD_MIRROR="$MIRROR"
|
||||
USERNAME="$USERNAME" \
|
||||
PASSWORD="$PASSWORD" \
|
||||
ROUTER_IP_ADDRESS="$ROUTER_IP_ADDRESS" \
|
||||
BOX_IP_ADDRESS="$BOX_IP_ADDRESS" \
|
||||
NAMESERVER1="$NAMESERVER1" \
|
||||
NAMESERVER2="$NAMESERVER2" \
|
||||
PROJECT_NAME="$PROJECT_NAME" \
|
||||
CONFIG_FILENAME="$CONFIG_FILENAME" \
|
||||
IMAGE_SIZE="$IMAGE_SIZE" \
|
||||
SSH_PUBKEY="$SSH_PUBKEY" \
|
||||
GENERIC_IMAGE="$GENERIC_IMAGE" \
|
||||
MINIMAL_INSTALL="$MINIMAL_INSTALL" \
|
||||
SSH_PORT="$SSH_PORT" \
|
||||
ONION_ONLY="$ONION_ONLY" \
|
||||
IMAGE_NAME="$IMAGE_NAME" \
|
||||
PROJECT_REPO="$PROJECT_REPO" \
|
||||
MIRROR="$MIRROR" \
|
||||
BUILD_MIRROR="$MIRROR" \
|
||||
DEBIAN_INSTALL_ONLY="$DEBIAN_INSTALL_ONLY"
|
||||
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo $'Build failed'
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
exit 1
|
||||
echo $'Build failed'
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECTED_EXTENSION='xz'
|
||||
if [[ $IMAGE_TYPE == "qemu"* ]]; then
|
||||
EXPECTED_EXTENSION='qcow2'
|
||||
EXPECTED_EXTENSION='qcow2'
|
||||
fi
|
||||
if [[ $IMAGE_TYPE == "virtualbox"* ]]; then
|
||||
EXPECTED_EXTENSION='vdi'
|
||||
EXPECTED_EXTENSION='vdi'
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
imgfiles=(build/${PROJECT_NAME}*.${EXPECTED_EXTENSION})
|
||||
if [ ${#imgfiles[@]} -eq 0 ]; then
|
||||
echo $'Image was not created'
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
exit 2
|
||||
echo $'Image was not created'
|
||||
rm -rf $TEMPBUILD_DIR
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Move images from temporary directory to the current directory
|
||||
for im in "${image_types[@]}"
|
||||
do
|
||||
no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
mv build/${PROJECT_NAME}*.${im} ${CURR_DIR}/
|
||||
fi
|
||||
no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)
|
||||
if (( no_of_files > 0 )); then
|
||||
mv build/${PROJECT_NAME}*.${im} ${CURR_DIR}/
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove the temporary directory
|
||||
|
@ -359,32 +367,32 @@ Image was created.
|
|||
You will be able to log into it with:
|
||||
"
|
||||
if [[ $IMAGE_TYPE != "virtualbox"* && $IMAGE_TYPE != "qemu"* ]]; then
|
||||
echo $" ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT
|
||||
echo $" ssh $USERNAME@$DEFAULT_DOMAIN_NAME -p $SSH_PORT
|
||||
|
||||
Password: $PASSWORD
|
||||
"
|
||||
else
|
||||
if [[ $IMAGE_TYPE != "qemu"* ]]; then
|
||||
echo $" Username: $USERNAME
|
||||
if [[ $IMAGE_TYPE != "qemu"* ]]; then
|
||||
echo $" Username: $USERNAME
|
||||
Password: $PASSWORD
|
||||
"
|
||||
else
|
||||
if [[ $IMAGE_TYPE != "qemu-x86_64"* && $IMAGE_TYPE != "qemu-amd64"* ]]; then
|
||||
echo "qemu-system-i386 -m ${VM_MEMORY} $(ls ${PROJECT_NAME}*.qcow2)"
|
||||
else
|
||||
echo "qemu-system-x86_64 -m ${VM_MEMORY} $(ls ${PROJECT_NAME}*.qcow2)"
|
||||
fi
|
||||
echo $"
|
||||
else
|
||||
if [[ $IMAGE_TYPE != "qemu-x86_64"* && $IMAGE_TYPE != "qemu-amd64"* ]]; then
|
||||
echo "qemu-system-i386 -m ${VM_MEMORY} $(ls ${PROJECT_NAME}*.qcow2)"
|
||||
else
|
||||
echo "qemu-system-x86_64 -m ${VM_MEMORY} $(ls ${PROJECT_NAME}*.qcow2)"
|
||||
fi
|
||||
echo $"
|
||||
Username: $USERNAME
|
||||
Password: $PASSWORD
|
||||
"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
ls -lh ${PROJECT_NAME}*.img ${PROJECT_NAME}*.sig ${PROJECT_NAME}*.xz ${PROJECT_NAME}*.vdi ${PROJECT_NAME}*.qcow2
|
||||
|
||||
# Remove the mesh script after use
|
||||
if [[ $VARIANT == "mesh"* ]]; then
|
||||
rm -f $CONFIG_FILENAME
|
||||
rm -f $CONFIG_FILENAME
|
||||
fi
|
||||
|
||||
# record the default login credentials for later use
|
||||
|
@ -393,12 +401,12 @@ Password: $PASSWORD" > ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
|||
chmod 600 ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
||||
|
||||
if [[ $IMAGE_TYPE != "virtualbox"* && $IMAGE_TYPE != "qemu"* ]]; then
|
||||
echo ''
|
||||
echo $'You can copy the image to a microSD card with:'
|
||||
echo ''
|
||||
echo " unxz -k ${PROJECT_NAME}*.img.xz"
|
||||
echo " sudo dd bs=1M if=${PROJECT_NAME}*.img of=/dev/sdX conv=fdatasync"
|
||||
echo ''
|
||||
echo ''
|
||||
echo $'You can copy the image to a microSD card with:'
|
||||
echo ''
|
||||
echo " unxz -k ${PROJECT_NAME}*.img.xz"
|
||||
echo " sudo dd bs=1M if=${PROJECT_NAME}*.img of=/dev/sdX conv=fdatasync"
|
||||
echo ''
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -75,15 +75,18 @@ TRACKER_PORT=6969
|
|||
# Whether sites are accessible only within a Tor browser
|
||||
ONION_ONLY="no"
|
||||
|
||||
# Whether to only install debian and nothing else
|
||||
DEBIAN_INSTALL_ONLY="no"
|
||||
|
||||
WIFI_INTERFACE='wlan0'
|
||||
|
||||
enable_eatmydata_override() {
|
||||
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
|
||||
if [ -x $rootdir/usr/bin/eatmydata ] && \
|
||||
[ ! -f $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata ]; then
|
||||
[ ! -f $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata ]; then
|
||||
echo $"info: Adding apt config to call dpkg via eatmydata"
|
||||
printf "#!/bin/sh\nexec eatmydata dpkg \"\$@\"\n" \
|
||||
> $rootdir/var/tmp/dpkg-eatmydata
|
||||
> $rootdir/var/tmp/dpkg-eatmydata
|
||||
chmod 755 $rootdir/var/tmp/dpkg-eatmydata
|
||||
cat > $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata <<EOF
|
||||
Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
|
||||
|
@ -96,7 +99,7 @@ EOF
|
|||
disable_eatmydata_override() {
|
||||
for override in \
|
||||
/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
|
||||
/var/tmp/dpkg-eatmydata ; do
|
||||
/var/tmp/dpkg-eatmydata ; do
|
||||
echo $"info: Removing apt config to call dpkg via eatmydata"
|
||||
if [ -f $rootdir$override ] ; then
|
||||
rm -f $rootdir$override
|
||||
|
@ -136,27 +139,27 @@ iface eth0 inet static
|
|||
netmask 255.255.255.0
|
||||
gateway $ROUTER_IP_ADDRESS
|
||||
dns-nameservers $NAMESERVER1 $NAMESERVER2
|
||||
# Example to keep MAC address between reboots
|
||||
#hwaddress ether B5:A2:BE:3F:1A:FE
|
||||
# Example to keep MAC address between reboots
|
||||
#hwaddress ether B5:A2:BE:3F:1A:FE
|
||||
|
||||
# The secondary network interface
|
||||
#auto eth1
|
||||
#iface eth1 inet dhcp
|
||||
# The secondary network interface
|
||||
#auto eth1
|
||||
#iface eth1 inet dhcp
|
||||
|
||||
# WiFi Example
|
||||
#auto wlan0
|
||||
#iface wlan0 inet dhcp
|
||||
# wpa-ssid \"essid\"
|
||||
# wpa-psk \"password\"
|
||||
# WiFi Example
|
||||
#auto wlan0
|
||||
#iface wlan0 inet dhcp
|
||||
# wpa-ssid \"essid\"
|
||||
# wpa-psk \"password\"
|
||||
|
||||
# Ethernet/RNDIS gadget (g_ether)
|
||||
# ... or on host side, usbnet and random hwaddr
|
||||
# Note on some boards, usb0 is automaticly setup with an init script
|
||||
#iface usb0 inet static
|
||||
# address 192.168.7.2
|
||||
# netmask 255.255.255.0
|
||||
# network 192.168.7.0
|
||||
# gateway 192.168.7.1" > $rootdir/etc/network/interfaces
|
||||
# Ethernet/RNDIS gadget (g_ether)
|
||||
# ... or on host side, usbnet and random hwaddr
|
||||
# Note on some boards, usb0 is automaticly setup with an init script
|
||||
#iface usb0 inet static
|
||||
# address 192.168.7.2
|
||||
# netmask 255.255.255.0
|
||||
# network 192.168.7.0
|
||||
# gateway 192.168.7.1" > $rootdir/etc/network/interfaces
|
||||
|
||||
hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
|
||||
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||
|
@ -211,6 +214,9 @@ admin_user_sudo() {
|
|||
}
|
||||
|
||||
create_generic_image() {
|
||||
if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ $GENERIC_IMAGE == "no" ]]; then
|
||||
return
|
||||
fi
|
||||
|
@ -380,35 +386,35 @@ atheros_wifi() {
|
|||
|
||||
|
||||
initialise_mesh() {
|
||||
if [[ $VARIANT != "mesh" ]]; then
|
||||
if [[ $VARIANT != "mesh" || $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
||||
return
|
||||
fi
|
||||
freedombone-mesh-install -f firewall -r "${rootdir}"
|
||||
freedombone-mesh-install -f avahi -r "${rootdir}"
|
||||
freedombone-mesh-install -f batman -r "${rootdir}"
|
||||
freedombone-mesh-install -f tox_node -r "${rootdir}"
|
||||
freedombone-mesh-install -f tox_client -r "${rootdir}"
|
||||
freedombone-mesh-install -f zeronet -r "${rootdir}"
|
||||
freedombone-mesh-install -f avahi -r "${rootdir}"
|
||||
freedombone-mesh-install -f batman -r "${rootdir}"
|
||||
freedombone-mesh-install -f tox_node -r "${rootdir}"
|
||||
freedombone-mesh-install -f tox_client -r "${rootdir}"
|
||||
freedombone-mesh-install -f zeronet -r "${rootdir}"
|
||||
|
||||
MESH_SERVICE='mesh-setup.service'
|
||||
MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
|
||||
MESH_SERVICE='mesh-setup.service'
|
||||
MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
|
||||
|
||||
echo '[Unit]' > $MESH_SETUP_DAEMON
|
||||
echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON
|
||||
echo 'After=syslog.target' >> $MESH_SETUP_DAEMON
|
||||
echo 'After=network.target' >> $MESH_SETUP_DAEMON
|
||||
echo '[Service]' >> $MESH_SETUP_DAEMON
|
||||
echo 'Type=simple' >> $MESH_SETUP_DAEMON
|
||||
echo 'User=root' >> $MESH_SETUP_DAEMON
|
||||
echo 'Group=root' >> $MESH_SETUP_DAEMON
|
||||
echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON
|
||||
echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON
|
||||
echo '' >> $MESH_SETUP_DAEMON
|
||||
echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON
|
||||
echo '' >> $MESH_SETUP_DAEMON
|
||||
echo '[Install]' >> $MESH_SETUP_DAEMON
|
||||
echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON
|
||||
chroot "$rootdir" systemctl enable $MESH_SERVICE
|
||||
echo '[Unit]' > $MESH_SETUP_DAEMON
|
||||
echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON
|
||||
echo 'After=syslog.target' >> $MESH_SETUP_DAEMON
|
||||
echo 'After=network.target' >> $MESH_SETUP_DAEMON
|
||||
echo '[Service]' >> $MESH_SETUP_DAEMON
|
||||
echo 'Type=simple' >> $MESH_SETUP_DAEMON
|
||||
echo 'User=root' >> $MESH_SETUP_DAEMON
|
||||
echo 'Group=root' >> $MESH_SETUP_DAEMON
|
||||
echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON
|
||||
echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON
|
||||
echo '' >> $MESH_SETUP_DAEMON
|
||||
echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON
|
||||
echo '' >> $MESH_SETUP_DAEMON
|
||||
echo '[Install]' >> $MESH_SETUP_DAEMON
|
||||
echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON
|
||||
chroot "$rootdir" systemctl enable $MESH_SERVICE
|
||||
}
|
||||
|
||||
# Set to true/false to control if eatmydata is used during build
|
||||
|
@ -502,17 +508,17 @@ fi
|
|||
case "$MACHINE" in
|
||||
beaglebone)
|
||||
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
|
||||
count=1 seek=1 conv=notrunc bs=128k
|
||||
count=1 seek=1 conv=notrunc bs=128k
|
||||
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
|
||||
count=2 seek=1 conv=notrunc bs=384k
|
||||
count=2 seek=1 conv=notrunc bs=384k
|
||||
;;
|
||||
cubieboard2)
|
||||
dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
|
||||
seek=8 conv=notrunc bs=1k
|
||||
seek=8 conv=notrunc bs=1k
|
||||
;;
|
||||
a20-olinuxino-lime)
|
||||
dd if=$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin \
|
||||
of="$image" seek=8 conv=notrunc bs=1k
|
||||
of="$image" seek=8 conv=notrunc bs=1k
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ export MINIMAL_INSTALL
|
|||
export SSH_PORT
|
||||
export ONION_ONLY
|
||||
export PROJECT_REPO
|
||||
export DEBIAN_INSTALL_ONLY
|
||||
|
||||
# Locate vmdebootstrap program fetched in Makefile
|
||||
basedir=`pwd`
|
||||
|
@ -83,8 +84,8 @@ echo Building $MACHINE $PROJECT_NAME for $ARCHITECTURE.
|
|||
|
||||
case "$MACHINE" in
|
||||
beaglebone)
|
||||
extra_pkgs="$beaglebone_pkgs"
|
||||
extra_opts="\
|
||||
extra_pkgs="$beaglebone_pkgs"
|
||||
extra_opts="\
|
||||
--variant minbase \
|
||||
--bootoffset=2mib \
|
||||
--bootsize 128M \
|
||||
|
@ -94,10 +95,10 @@ case "$MACHINE" in
|
|||
--foreign /usr/bin/qemu-arm-static \
|
||||
--roottype btrfs \
|
||||
"
|
||||
;;
|
||||
;;
|
||||
cubietruck | a20-olinuxino-lime | a20-olinuxino-lime2 | a20-olinuxino-micro | cubieboard2)
|
||||
extra_pkgs="$a20_pkgs"
|
||||
extra_opts="\
|
||||
extra_pkgs="$a20_pkgs"
|
||||
extra_opts="\
|
||||
--variant minbase \
|
||||
--bootoffset=1mib \
|
||||
--bootsize 128M \
|
||||
|
@ -107,19 +108,19 @@ case "$MACHINE" in
|
|||
--foreign /usr/bin/qemu-arm-static \
|
||||
--roottype btrfs \
|
||||
"
|
||||
;;
|
||||
;;
|
||||
virtualbox)
|
||||
extra_opts="\
|
||||
extra_opts="\
|
||||
--grub \
|
||||
--roottype btrfs \
|
||||
" ;;
|
||||
qemu)
|
||||
extra_opts="\
|
||||
extra_opts="\
|
||||
--grub \
|
||||
--roottype btrfs \
|
||||
" ;;
|
||||
all)
|
||||
extra_opts="\
|
||||
all)
|
||||
extra_opts="\
|
||||
--grub \
|
||||
--roottype btrfs \
|
||||
" ;;
|
||||
|
@ -128,32 +129,32 @@ esac
|
|||
# allow for lots of extra fun customization options.
|
||||
for customization in $CUSTOMIZATIONS
|
||||
do
|
||||
case "$customization" in
|
||||
development)
|
||||
extra_pkgs="$extra_pkgs $dev_pkgs"
|
||||
;;
|
||||
esac
|
||||
case "$customization" in
|
||||
development)
|
||||
extra_pkgs="$extra_pkgs $dev_pkgs"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for p in $base_pkgs $extra_pkgs; do
|
||||
pkgopts="$pkgopts --package $p"
|
||||
pkgopts="$pkgopts --package $p"
|
||||
done
|
||||
|
||||
# Make sure file is owned by current user, not root
|
||||
touch $(dirname $IMAGE)/${PROJECT_NAME}.log
|
||||
|
||||
if [ -x vendor/vmdebootstrap/vmdebootstrap ] ; then
|
||||
VMDEBOOTSTRAP=vendor/vmdebootstrap/vmdebootstrap
|
||||
VMDEBOOTSTRAP=vendor/vmdebootstrap/vmdebootstrap
|
||||
else
|
||||
VMDEBOOTSTRAP=vmdebootstrap
|
||||
VMDEBOOTSTRAP=vmdebootstrap
|
||||
fi
|
||||
|
||||
echo $'Making customised customisation script'
|
||||
TEMP_CUSTOMISE=/etc/${PROJECT_NAME}/image-customise
|
||||
if [ -f /usr/local/bin/${PROJECT_NAME}-image-customise ]; then
|
||||
sudo cp /usr/local/bin/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE
|
||||
sudo cp /usr/local/bin/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE
|
||||
else
|
||||
sudo cp /usr/bin/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE
|
||||
sudo cp /usr/bin/${PROJECT_NAME}-image-customise $TEMP_CUSTOMISE
|
||||
fi
|
||||
sudo sed -i "s|MY_USERNAME=.*|MY_USERNAME=${MY_USERNAME}|g" $TEMP_CUSTOMISE
|
||||
sudo sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MY_PASSWORD}|g" $TEMP_CUSTOMISE
|
||||
|
@ -169,31 +170,32 @@ sudo sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" $TEM
|
|||
sudo sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" $TEMP_CUSTOMISE
|
||||
sudo sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" $TEMP_CUSTOMISE
|
||||
sudo sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" $TEMP_CUSTOMISE
|
||||
sudo sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" $TEMP_CUSTOMISE
|
||||
|
||||
echo $"starting $VMDEBOOTSTRAP"
|
||||
# Run vmdebootstrap script to create image
|
||||
sudo -H \
|
||||
SUITE="$SUITE" \
|
||||
MIRROR="$MIRROR" \
|
||||
BUILD_MIRROR="$BUILD_MIRROR"\
|
||||
MACHINE="$MACHINE" \
|
||||
ARCHITECTURE="$ARCHITECTURE" \
|
||||
SOURCE="$SOURCE" \
|
||||
CUSTOM_SETUP="$CUSTOM_SETUP" \
|
||||
$VMDEBOOTSTRAP \
|
||||
--log $(dirname $IMAGE)/${PROJECT_NAME}.log \
|
||||
--log-level debug \
|
||||
--size $IMAGE_SIZE \
|
||||
--image $IMAGE.img \
|
||||
--hostname ${PROJECT_NAME} \
|
||||
--verbose \
|
||||
--mirror $BUILD_MIRROR \
|
||||
--customize "$TEMP_CUSTOMISE" \
|
||||
--lock-root-password \
|
||||
--arch $ARCHITECTURE \
|
||||
--distribution $SUITE \
|
||||
$extra_opts \
|
||||
$pkgopts
|
||||
SUITE="$SUITE" \
|
||||
MIRROR="$MIRROR" \
|
||||
BUILD_MIRROR="$BUILD_MIRROR"\
|
||||
MACHINE="$MACHINE" \
|
||||
ARCHITECTURE="$ARCHITECTURE" \
|
||||
SOURCE="$SOURCE" \
|
||||
CUSTOM_SETUP="$CUSTOM_SETUP" \
|
||||
$VMDEBOOTSTRAP \
|
||||
--log $(dirname $IMAGE)/${PROJECT_NAME}.log \
|
||||
--log-level debug \
|
||||
--size $IMAGE_SIZE \
|
||||
--image $IMAGE.img \
|
||||
--hostname ${PROJECT_NAME} \
|
||||
--verbose \
|
||||
--mirror $BUILD_MIRROR \
|
||||
--customize "$TEMP_CUSTOMISE" \
|
||||
--lock-root-password \
|
||||
--arch $ARCHITECTURE \
|
||||
--distribution $SUITE \
|
||||
$extra_opts \
|
||||
$pkgopts
|
||||
|
||||
echo $'Removing customised customisation script'
|
||||
sudo shred -zu $TEMP_CUSTOMISE
|
||||
|
|
Loading…
Reference in New Issue