generic installer. include update-rpi

This commit is contained in:
nachoparker 2017-03-02 18:28:58 +01:00
parent c1618397e3
commit 88c3a60135
5 changed files with 26 additions and 17 deletions

View File

@ -15,6 +15,8 @@
#
# See the variables on the top of the script for tweaking
set -xe
sudo su
NCLOG=/var/www/nextcloud/data/nextcloud.log # location of Nextcloud logs
@ -22,8 +24,7 @@ BANTIME=600 # time to ban an IP that exceede
FINDTIME=600 # cooldown time for incorrect passwords
MAXRETRY=6 # bad attempts before banning an IP
set -x
set -e
set -xe
# INSTALLATION

View File

@ -19,9 +19,8 @@ EXTRACT=1 # Extract the image from zip, so start from 0
IMG=raspbian_lite_latest
INSTALL_SCRIPT=nextcloud.sh
IMGFILE="NextCloudPi_$( date "+%m-%d-%y" ).img-stage0"
IMGOUT="NextCloudPi_$( date "+%m-%d-%y" ).img"
source library.sh
source library.sh # initializes $IMGOUT
[[ "$DOWNLOAD" == "1" ]] && { wget https://downloads.raspberrypi.org/$IMG -O $IMG.zip || exit; }
[[ "$DOWNLOAD" == "1" ]] || [[ "$EXTRACT" == "1" ]] && {
@ -30,6 +29,8 @@ source library.sh
qemu-img resize $IMGFILE +1G || exit
}
IMGOUT="NextCloudPi_$( date "+%m-%d-%y" ).img"
launch_install_qemu $INSTALL_SCRIPT $IMGFILE $IP || exit
pack_image $IMGFILE $IMGOUT

View File

@ -1,21 +1,23 @@
#!/bin/bash
# fail2ban installation on QEMU emulated Raspbian image
# TODO
# Nextcloud installation on QEMU emulated Raspbian image
# Tested with 2017-01-11-raspbian-jessie.img (and lite)
#
# 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:
# ./install-fail2ban.sh <img> <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
IMGFILE=$1 # First argument is the image file to start from
IP=$2 # Second argument is the QEMU Raspbian IP address
INSTALL_SCRIPT=fail2ban.sh
IMGOUT=$( basename $IMGFILE .img )_fail2ban.img
source library.sh
INSTALL_SCRIPT=$1
IMGFILE=$2 # First argument is the image file to start from
IP=$3 # Second argument is the QEMU Raspbian IP address
source library.sh # initializes $IMGOUT
launch_install_qemu $INSTALL_SCRIPT $IMGFILE $IP || exit
pack_image $IMGFILE $IMGOUT

View File

@ -5,6 +5,9 @@
# 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!
IMGOUT=$( basename $IMGFILE .img )_$( basename $INSTALL_SCRIPT .sh ).img
SSH=( ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o ConnectTimeout=1 -o LogLevel=quiet )
function launch_install_qemu()
@ -43,7 +46,7 @@ function launch_qemu()
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
echo "Starting QEMU image $IMG"
( cd qemu-raspbian-network && sudo ./qemu-pi.sh ../$IMG )
( cd qemu-raspbian-network && sudo ./qemu-pi.sh ../$IMG 2>/dev/null )
}
function wait_SSH()

View File

@ -18,6 +18,8 @@
# it is required to save the state of the installation. See variable $STATE_FILE
# It will be necessary to invoke this a number of times for a complete installation
set -xe
sudo su
VER=11.0.1
@ -27,8 +29,7 @@ DBPASSWD=ownyourbits
MAX_FILESIZE=1G
STATE_FILE=/home/pi/.installation_state
set -x
set -e
set -xe
test -f $STATE_FILE && STATE=$( cat $STATE_FILE 2>/dev/null )
if [ "$STATE" == "" ]; then
@ -52,7 +53,8 @@ elif [ "$STATE" == "0" ]; then
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove
apt-get install rpi-update -y
echo -e "y\n" | rpi-update
echo 1 > $STATE_FILE
reboot