From d876a2fa81899eb2bc689a0ac9d0ecd9513cf187 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 26 Sep 2015 17:25:43 -0300 Subject: Adds provision-chroot --- share/hydra/provision-chroot | 1 + share/hydractl/provision-chroot | 59 +++++++++++++++++++++++++++++++++++++++++ share/hydractl/provision-raspi | 22 +++++++++------ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 120000 share/hydra/provision-chroot create mode 100755 share/hydractl/provision-chroot diff --git a/share/hydra/provision-chroot b/share/hydra/provision-chroot new file mode 120000 index 0000000..e98b45a --- /dev/null +++ b/share/hydra/provision-chroot @@ -0,0 +1 @@ +provision \ No newline at end of file diff --git a/share/hydractl/provision-chroot b/share/hydractl/provision-chroot new file mode 100755 index 0000000..7910879 --- /dev/null +++ b/share/hydractl/provision-chroot @@ -0,0 +1,59 @@ +#!/bin/bash +# +# System installer, chroot version. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . + +# Load. +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +# Make sure there is provision config. +function hydra_provision_config { + hydra_user_config interactive y "Interactive mode? (y/n)" + hydra_user_config folder /var/chroot/debian "Destination device" + hydra_user_config hostname machine "Hostname" + hydra_user_config domain example.org "Domain" + hydra_user_config arch amd64 "System arch" + hydra_user_config version jessie "Distro version" + hydra_user_config mirror http://http.debian.net/debian/ "Debian mirror" +} + +# Load configuration +hydra_provision_config_load $1 + +# Parameters +WORK="$folder" +CHROOT="hydra_sudo_run chroot $WORK" + +# Get config parameters. +hydra_provision_config + +# Check for requirements. +for req in debootstrap qemu-user-static; do + hydra_install_package $req +done + +hydra_sudo_run mkdir -p /var/chroot +hydra_sudo_run sudo debootstrap --variant=minbase --arch $arch $version $WORK $mirror + +# Arch specific procedures +if [ "$arch" != "armel" ] && [ "$arch" != "armhf" ]; then + hydra_sudo_run cp /usr/bin/qemu-arm-static $WORK/usr/bin/ + $CHROOT /debootstrap/debootstrap --second-stage +fi + +echo "$hostname.$domain" | hydra_sudo_run tee /var/chroot/squeeze/etc/hostname > /dev/null +$CHROOT apt-get install locales diff --git a/share/hydractl/provision-raspi b/share/hydractl/provision-raspi index 5b3ea15..38bc0b7 100755 --- a/share/hydractl/provision-raspi +++ b/share/hydractl/provision-raspi @@ -1,6 +1,7 @@ #!/bin/bash # # System installer, Raspberry Pi version. +# Based on https://wiki.debian.org/MatthiasSchmitz#Building_own_Debian_image_for_Raspberry_Pi # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -49,6 +50,11 @@ RPI_URL="https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update" # Get config parameters. hydra_provision_config +# Check for requirements. +for req in debootstrap parted qemu-user-static; do + hydra_install_package $req +done + # Partitioning hydra_sudo_run parted -s -- $device mklabel msdos hydra_sudo_run parted -s -- $device unit MB mkpart primary fat32 1 100 @@ -62,13 +68,13 @@ hydra_sudo_run mkfs.ext4 "$device"p2 hydra_sudo_run mount "$device"p2 $WORK # Bootstrap the system -hydra_sudo_run debootstrap --foreign --arch=$arch $version $WORK +hydra_sudo_run debootstrap --foreign --arch=$arch $version $WORK $mirror hydra_sudo_run cp /usr/bin/qemu-arm-static $WORK/usr/bin/ $CHROOT /debootstrap/debootstrap --second-stage # Apt configuration -echo "deb http://http.debian.net/debian/ $version main contrib non-free" | hydra_sudo_run tee $WORK/etc/apt/sources.list -echo "deb http://security.debian.org/ $version/updates main contrib non-free" | hydra_sudo_run tee -a $WORK/etc/apt/sources.list +echo "deb $mirror $version main contrib non-free" | hydra_sudo_run tee $WORK/etc/apt/sources.list > /dev/null +echo "deb http://security.debian.org/ $version/updates main contrib non-free" | hydra_sudo_run tee -a $WORK/etc/apt/sources.list > /dev/null # Basic packages $CHROOT apt-get update @@ -76,7 +82,7 @@ $CHROOT apt-get install -y locales && $CHROOT dpkg-reconfigure locales $CHROOT apt-get install -y screen cron lsb-release openssl openssh-server less ntp # Hostname -echo $hostname.$domain | hydra_sudo_run tee $WORK/etc/hostname +echo $hostname.$domain | hydra_sudo_run tee $WORK/etc/hostname > /dev/null # Temporary root password $CHROOT passwd @@ -86,8 +92,8 @@ $CHROOT apt-get install -y wpasupplicant firmware-ralink # para conexao usando s hydra_sudo_run chmod 0600 $WORK/etc/network/interfaces # Modules -echo "vchiq" | hydra_sudo_run tee -a $WORK/etc/modules -echo "snd_bcm2835" | hydra_sudo_run tee -a $WORK/etc/modules +echo "vchiq" | hydra_sudo_run tee -a $WORK/etc/modules > /dev/null +echo "snd_bcm2835" | hydra_sudo_run tee -a $WORK/etc/modules > /dev/null # Fstab echo "Doing a basic network config..." @@ -98,14 +104,14 @@ proc /proc proc defaults 0 0 EOF # Inittab -echo "T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" | hydra_sudo_run tee -a $WORK/etc/inittab +echo "T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" | hydra_sudo_run tee -a $WORK/etc/inittab > /dev/null # Networking hydra_provision_networking # Boot setup hydra_sudo_run mount "$device"p1 /$WORK/boot/ -echo $CMDLINE | hydra_sudo_run tee $WORK/boot/cmdline.txt +echo $CMDLINE | hydra_sudo_run tee $WORK/boot/cmdline.txt > /dev/null $CHROOT apt-get install -y git-core binutils ca-certificates $CHROOT wget $RPI_URL -O /usr/bin/rpi-update $CHROOT chmod +x /usr/bin/rpi-update -- cgit v1.2.3