diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-06-12 23:52:14 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-06-12 23:55:15 +0300 |
commit | 2a90a83ad2fd28277f678ef530aed44dc3344deb (patch) | |
tree | 6da7c243224df7dd2d97a57872a087aef76e547f | |
parent | 1357ed7240f47abbdce45c4fbd6673b2669afa3a (diff) |
QEMU docker ARM environment
-rwxr-xr-x | batch.sh | 8 | ||||
-rw-r--r-- | docker/docker-env.sh | 46 | ||||
-rwxr-xr-x | etc/library.sh | 18 | ||||
-rw-r--r--[-rwxr-xr-x] | etc/nextcloudpi-config.d/nc-automount.sh | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | etc/nextcloudpi-config.d/nc-nextcloud.sh | 0 | ||||
-rwxr-xr-x | installer.sh | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | prepare-build-env-docker.sh (renamed from prepare-img.sh) | 34 | ||||
-rw-r--r-- | prepare.sh | 2 |
8 files changed, 88 insertions, 22 deletions
@@ -17,16 +17,18 @@ NC_CONFIG=etc/nc-init.sh IMGBASE="NextCloudPi_$( date "+%m-%d-%y" )_base.img" -export NO_CONFIG=1 # skip interactive configuration +export NO_CONFIG=1 # skip interactive configuration -NO_HALT_STEP=1 ./prepare-img.sh $IP $IMGBASE || exit 1 +download_resize_raspbian_img 1G $IMGBASE || exit 1 + +NO_HALT_STEP=1 ./installer.sh prepare.sh $IP $IMGBASE || exit 1 ./installer.sh lamp.sh $IP $( ls -1t *.img | head -1 ) || exit 1 ./installer.sh $NC_INSTALL $IP $( ls -1t *.img | head -1 ) || exit 1 ./installer.sh $NC_CONFIG $IP $( ls -1t *.img | head -1 ) || exit 1 ./installer.sh nextcloudpi.sh $IP $( ls -1t *.img | head -1 ) || exit 1 IMGFILE=$( ls -1t *.img | head -1 ) -IMGOUT=$( basename "$IMGFILE" _base_lamp_nc-nextcloud_nc-init_nextcloudpi.img ).img +IMGOUT=$( basename "$IMGFILE" _base_prepare_lamp_nc-nextcloud_nc-init_nextcloudpi.img ).img pack_image "$IMGFILE" "$IMGOUT" md5sum $( ls -1t *.img | head -1 ) diff --git a/docker/docker-env.sh b/docker/docker-env.sh new file mode 100644 index 00000000..9320375a --- /dev/null +++ b/docker/docker-env.sh @@ -0,0 +1,46 @@ +#!/bin/bish + +# Install docker ARM on Raspbian +# Tested with 2017-03-02-raspbian-jessie-lite.img +# +# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> +# GPL licensed (see end of file) * Use at your own risk! +# +# Usage: ./installer.sh docker-env.sh <DHCP QEMU image IP> <image> +# + + +install() +{ + curl -sSL get.docker.com | sh + usermod -aG docker pi +} + +configure(){ :; } + +cleanup() +{ + apt-get autoremove + apt-get clean + rm /var/lib/apt/lists/* -r + rm -f /home/pi/.bash_history + + systemctl disable ssh +} + +# License +# +# This script 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 2 of the License, or +# (at your option) any later version. +# +# This script 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 script; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA diff --git a/etc/library.sh b/etc/library.sh index 5cfd1cba..fc6f1141 100755 --- a/etc/library.sh +++ b/etc/library.sh @@ -257,6 +257,24 @@ function copy_to_image() rmdir tmpmnt &>/dev/null } +function download_resize_raspbian_img() +{ + local SIZE=$1 + local IMGFILE=$2 + local IMG=raspbian_lite_latest + + test -f $IMGFILE && \ + echo -e "INFO: $IMGFILE already exists. Skipping download ..." && return 0 + + test -f $IMG.zip || \ + wget https://downloads.raspberrypi.org/$IMG -O $IMG.zip || return 1 + + unzip -o $IMG.zip && \ + mv *-raspbian-*.img $IMGFILE && \ + qemu-img resize -f raw $IMGFILE +$SIZE && \ + return 0 +} + function pack_image() { local IMGOUT="$1" diff --git a/etc/nextcloudpi-config.d/nc-automount.sh b/etc/nextcloudpi-config.d/nc-automount.sh index 3e95db67..3e95db67 100755..100644 --- a/etc/nextcloudpi-config.d/nc-automount.sh +++ b/etc/nextcloudpi-config.d/nc-automount.sh diff --git a/etc/nextcloudpi-config.d/nc-nextcloud.sh b/etc/nextcloudpi-config.d/nc-nextcloud.sh index 20d84b15..20d84b15 100755..100644 --- a/etc/nextcloudpi-config.d/nc-nextcloud.sh +++ b/etc/nextcloudpi-config.d/nc-nextcloud.sh diff --git a/installer.sh b/installer.sh index 06a32cde..d6f2c06c 100755 --- a/installer.sh +++ b/installer.sh @@ -38,7 +38,7 @@ IMGFILE=$3 # Third argument is the image file to start from ( empty source etc/library.sh # initializes $IMGNAME -config $INSTALL_SCRIPT || exit 1 +config $INSTALL_SCRIPT || exit 1 # Initializes $INSTALLATION_CODE if [[ "$IMGFILE" != "" ]]; then launch_install_qemu "$IMGFILE" $IP || { sudo killall qemu-system-arm; exit 1; } # initializes $IMGOUT diff --git a/prepare-img.sh b/prepare-build-env-docker.sh index c61f869e..a63e1ab5 100644..100755 --- a/prepare-img.sh +++ b/prepare-build-env-docker.sh @@ -1,41 +1,42 @@ #!/bin/bash -# Nextcloud installation on QEMU emulated Raspbian image +# Create a Raspbian image with docker # Tested with 2017-03-02-raspbian-jessie-lite.img # # Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> # GPL licensed (see end of file) * Use at your own risk! # # Usage: -# ./prepare-img.sh <IP> # Use the IP of your running QEMU Raspbian image +# ./prepare-build-env-docker.sh <IP> # Use the IP of your running QEMU Raspbian image # # Notes: # Set DOWNLOAD=0 if you have already downloaded an image. # Set EXTRACT=0 if you have already extracted the image. # -# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ +# More at https://ownyourbits.com # IP=$1 # First argument is the QEMU Raspbian IP address -IMGFILE=$2 # Second argument is the name for the output image -DOWNLOAD=1 # Download the latest image -EXTRACT=1 # Extract the image from zip, so start from 0 +DOWNLOAD=0 # Download the latest image +EXTRACT=0 # Extract the image from zip, so start from 0 IMG=raspbian_lite_latest -INSTALL_SCRIPT=prepare.sh source etc/library.sh # initializes $IMGNAME -[[ "$DOWNLOAD" == "1" ]] && { wget https://downloads.raspberrypi.org/$IMG -O $IMG.zip || exit 1; } -[[ "$DOWNLOAD" == "1" ]] || [[ "$EXTRACT" == "1" ]] && { - unzip $IMG.zip && \ - mv *-raspbian-*.img $IMGFILE && \ - qemu-img resize $IMGFILE +1G || exit 1 -} +IMGBASE="raspbian_docker_base.img" -config $INSTALL_SCRIPT || exit 1 # Initializes $INSTALLATION_CODE -launch_install_qemu "$IMGFILE" $IP || exit 1 # initializes $IMGOUT +export NO_CONFIG=1 # skip interactive configuration + +download_resize_raspbian_img 3G $IMGBASE || exit 1 + +NO_HALT_STEP=1 ./installer.sh prepare.sh $IP $IMGBASE || exit 1 + ./installer.sh docker/docker-env.sh $IP $( ls -1t *.img | head -1 ) || exit 1 + +IMGFILE=$( ls -1t *.img | head -1 ) +IMGOUT="raspbian_docker.img" + +pack_image "$IMGFILE" "$IMGOUT" -pack_image $IMGOUT $IMGFILE # License # @@ -53,4 +54,3 @@ pack_image $IMGOUT $IMGFILE # along with this script; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA - @@ -1,6 +1,6 @@ #!/bin/bish -# Prepare a Raspbian image (download, resize and update) +# Prepare a Raspbian image (resize and update) # Tested with 2017-03-02-raspbian-jessie-lite.img # # Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> |