mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-09 14:42:01 -03:30
split code into a library to reuse. creation of launch_install_qemu()
This commit is contained in:
parent
9f5a7b6f64
commit
c0bfe37e74
@ -7,21 +7,22 @@
|
||||
# GPL licensed (see end of file) * Use at your own risk!
|
||||
#
|
||||
# Usage:
|
||||
# ./install-image.sh <IP> # Use the IP of your running QEMU Raspbian image
|
||||
# ./install-nextcloud.sh <IP> # Use the IP of your running QEMU Raspbian image
|
||||
#
|
||||
# Notes:
|
||||
# Set DOWNLOAD=0 if you have already downloaded an image. Rename it to nextcloudpi.img
|
||||
|
||||
IP=$1 # First argument is the QEMU Raspbian IP address
|
||||
DOWNLOAD=1 # Download the latest image
|
||||
DOWNLOAD=0 # Download the latest image
|
||||
#IMG=raspbian_latest
|
||||
IMG=raspbian_lite_latest
|
||||
|
||||
[[ "$IP" == "" ]] && { echo "usage: ./install-image.sh <IP>"; exit; }
|
||||
|
||||
SSH="ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o ConnectTimeout=1 -o LogLevel=quiet"
|
||||
INSTALL_SCRIPT=nextcloud.sh
|
||||
IMGFILE="NextCloudPi_$( date "+%m-%d-%y" ).img"
|
||||
|
||||
[[ "$IP" == "" ]] && { echo "usage: ./$0 <IP>"; exit; }
|
||||
|
||||
source library.sh
|
||||
|
||||
if [[ "$DOWNLOAD" == "1" ]]; then
|
||||
wget https://downloads.raspberrypi.org/$IMG -O $IMG.zip && \
|
||||
unzip $IMG.zip && \
|
||||
@ -29,32 +30,8 @@ if [[ "$DOWNLOAD" == "1" ]]; then
|
||||
qemu-img resize $IMGFILE +1G
|
||||
fi
|
||||
|
||||
test -d qemu-raspbian-network || git clone https://github.com/nachoparker/qemu-raspbian-network.git
|
||||
sed -i '30s/NO_NETWORK=1/NO_NETWORK=0/' qemu-raspbian-network/qemu-pi.sh
|
||||
launch_install_qemu $INSTALL_SCRIPT $IMGFILE $IP
|
||||
|
||||
NUM_REBOOTS=$( grep -c reboot install-nextcloud.sh )
|
||||
while [[ $NUM_REBOOTS != -1 ]]; do
|
||||
echo "Starting QEMU"
|
||||
cd qemu-raspbian-network
|
||||
sudo ./qemu-pi.sh ../$IMGFILE &
|
||||
cd -
|
||||
|
||||
sleep 10
|
||||
echo "Waiting for SSH to be up"
|
||||
while true; do
|
||||
sshpass -praspberry $SSH pi@$IP ls &>/dev/null && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 120
|
||||
echo "Launching installation"
|
||||
cat install-nextcloud.sh | sshpass -praspberry $SSH pi@$IP
|
||||
wait
|
||||
NUM_REBOOTS=$(( NUM_REBOOTS-1 ))
|
||||
done
|
||||
echo "$IMGFILE generated successfully. Compressing"
|
||||
TARNAME=$( basename $IMGFILE ).tar.bz2
|
||||
test -f $TARNAME || tar -I pbzip2 -cvf $TARNAME $IMGFILE
|
||||
|
||||
# License
|
||||
#
|
||||
|
||||
60
library.sh
Normal file
60
library.sh
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Library to install software on Raspbian ARM through QEMU
|
||||
#
|
||||
# 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!
|
||||
|
||||
function launch_install_qemu()
|
||||
{
|
||||
local INSTALL_SCRIPT=$1
|
||||
local IMGFILE=$2
|
||||
local IP=$3
|
||||
[[ "$IP" == "" ]] && { echo "usage: launch_install_qemu <script> <img> <IP>"; exit; } # TODO
|
||||
local SSH="ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o ConnectTimeout=1 -o LogLevel=quiet"
|
||||
local NUM_REBOOTS=$( grep -c reboot $INSTALL_SCRIPT )
|
||||
|
||||
test -d qemu-raspbian-network || git clone https://github.com/nachoparker/qemu-raspbian-network.git
|
||||
sed -i '30s/NO_NETWORK=1/NO_NETWORK=0/' qemu-raspbian-network/qemu-pi.sh
|
||||
|
||||
while [[ $NUM_REBOOTS != -1 ]]; do
|
||||
echo "Starting QEMU"
|
||||
cd qemu-raspbian-network
|
||||
sudo ./qemu-pi.sh ../$IMGFILE &
|
||||
cd -
|
||||
|
||||
sleep 10
|
||||
echo "Waiting for SSH to be up"
|
||||
while true; do
|
||||
sshpass -praspberry $SSH pi@$IP ls &>/dev/null && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 120
|
||||
echo "Launching installation"
|
||||
cat install-nextcloud.sh | sshpass -praspberry $SSH pi@$IP
|
||||
wait
|
||||
NUM_REBOOTS=$(( NUM_REBOOTS-1 ))
|
||||
done
|
||||
echo "$IMGFILE generated successfully. Compressing"
|
||||
local TARNAME=$( basename $IMGFILE ).tar.bz2
|
||||
test -f $TARNAME || tar -I pbzip2 -cvf $TARNAME $IMGFILE
|
||||
}
|
||||
|
||||
# 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user