batch build improvements

This commit is contained in:
nachoparker 2017-03-15 08:05:10 +01:00
parent 6ed507a7f7
commit 71cfa60d22
4 changed files with 29 additions and 26 deletions

View File

@ -11,15 +11,16 @@
IP=$1 # First argument is the QEMU Raspbian IP address
IMG=$2 # TODO
IMG=NextCloudPi_03-13-17.img
IMGFILE="NextCloudPi_$( date "+%m-%d-%y" ).img"
NO_CONFIG=1 NO_HALT_STEP=1 ./install-nextcloud.sh $IP
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh fail2ban.sh $IP $( ls -1t *.img | head -1 )
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh no-ip.sh $IP $( ls -1t *.img | head -1 )
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh dnsmasq.sh $IP $( ls -1t *.img | head -1 )
#TODO rename to FULL
NO_CONFIG=1 NO_HALT_STEP=1 ./install-nextcloud.sh $IP $IMGFILE
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh fail2ban.sh $IP $( ls -1t *.img | head -1 )
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh no-ip.sh $IP $( ls -1t *.img | head -1 )
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh dnsmasq.sh $IP $( ls -1t *.img | head -1 )
NO_CONFIG=1 NO_CFG_STEP=1 ./installer.sh letsencrypt.sh $IP $( ls -1t *.img | head -1 )
cp -v "$( ls -1t *.img | head -1 )" $( basename "$IMGFILE" .img )_FULL.img
# License
#

View File

@ -13,11 +13,11 @@
# 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
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
IMG=raspbian_lite_latest
INSTALL_SCRIPT=nextcloud.sh
IMGFILE="NextCloudPi_$( date "+%m-%d-%y" ).img"
source library.sh # initializes $IMGOUT
@ -34,9 +34,9 @@ config $INSTALL_SCRIPT || exit 1
launch_install_qemu "$IMGFILE" $IP || exit 1
CONFDIR=/usr/local/etc/nextcloudpi-config.d/
copy_to_image $( ls -1t $IMGFILE-stage* | head -1 ) $CONFDIR nc-limits.sh nc-datadir.sh
copy_to_image $( ls -1t $IMGFILE-stage* | head -1 ) $CONFDIR/library library.sh
copy_to_image $( ls -1t $IMGFILE-stage* | head -1 ) /usr/local/bin/ nextcloudpi-config
copy_to_image "$IMGOUT" $CONFDIR nc-limits.sh nc-datadir.sh
copy_to_image "$IMGOUT" $CONFDIR/library library.sh
copy_to_image "$IMGOUT" /usr/local/bin/ nextcloudpi-config
pack_image $IMGFILE $IMGOUT

View File

@ -35,14 +35,14 @@ IP=$2 # Second argument is the QEMU Raspbian IP address
IMGFILE=$3 # Third argument is the image file to start from ( empty for online installation )
CONFDIR=/usr/local/etc/nextcloudpi-config.d/
source library.sh # initializes $IMGOUT
source library.sh # initializes $IMGNAME
config $INSTALL_SCRIPT || exit 1
if [[ "$IMGFILE" != "" ]]; then
launch_install_qemu "$IMGFILE" $IP || exit 1
copy_to_image $( ls -1t $IMGFILE-stage* | head -1 ) $CONFDIR $INSTALL_SCRIPT || exit 1
pack_image "$IMGFILE" "$IMGOUT"
launch_install_qemu "$IMGFILE" $IP || exit 1 # initializes $IMGOUT
copy_to_image "$IMGOUT" $CONFDIR $INSTALL_SCRIPT || exit 1
pack_image "$IMGOUT" "$IMGNAME"
else
launch_installation_online $IP
fi

View File

@ -6,10 +6,11 @@
# GPL licensed (see end of file) * Use at your own risk!
IMGOUT=$( basename $IMGFILE .img )_$( basename $INSTALL_SCRIPT .sh ).img
IMGNAME=$( basename $IMGFILE .img )_$( basename $INSTALL_SCRIPT .sh ).img
CFGOUT=config_$( basename $INSTALL_SCRIPT .sh ).txt
DBG=x
# $IMGOUT will contain the name of the last step
function launch_install_qemu()
{
local IMG=$1
@ -24,18 +25,18 @@ function launch_install_qemu()
local NUM_REBOOTS=$( grep -c reboot $INSTALL_SCRIPT )
while [[ $NUM_REBOOTS != -1 ]]; do
NUM=$(( NUM+1 ))
local IMGFILE="$BASE-stage$NUM"
cp -v $IMG $IMGFILE || return 1 # take a copy of the input image for processing ( append "-stage1" )
IMGOUT="$BASE-stage$NUM"
cp -v $IMG $IMGOUT || return 1 # take a copy of the input image for processing ( append "-stage1" )
launch_qemu $IMGFILE &
launch_qemu $IMGOUT &
sleep 10
wait_SSH $IP
launch_installation_qemu $IP || return 1
wait
IMG="$IMGFILE"
IMG="$IMGOUT"
NUM_REBOOTS=$(( NUM_REBOOTS-1 ))
done
echo "$IMGFILE generated successfully"
echo "$IMGOUT generated successfully"
}
function launch_qemu()
@ -217,6 +218,7 @@ function copy_to_image()
local SECTOR=$( fdisk -l $IMG | grep Linux | awk '{ print $2 }' )
local OFFSET=$(( SECTOR * 512 ))
[ -f "$IMG" ] || { echo "no image"; return 1; }
mkdir -p tmpmnt
sudo mount $IMG -o offset=$OFFSET tmpmnt || return 1
sudo cp $SRC tmpmnt/$DST || return 1
@ -226,11 +228,11 @@ function copy_to_image()
function pack_image()
{
local IMGFILE="$1"
local IMGOUT="$2"
local TARNAME=$( basename $IMGOUT .img ).tar.bz2
cp -v $( ls -1t $IMGFILE-stage* | head -1 ) $IMGOUT
tar -I pbzip2 -cvf $TARNAME $IMGOUT &>/dev/null && \
local IMGOUT="$1"
local IMGNAME="$2"
local TARNAME=$( basename $IMGNAME .img ).tar.bz2
cp -v "$IMGOUT" "$IMGNAME" || return 1
tar -I pbzip2 -cvf $TARNAME "$IMGNAME" &>/dev/null && \
echo -e "$TARNAME packed successfully"
}