add Vagrantfile

This commit is contained in:
nachoparker 2018-10-21 21:16:41 -06:00
parent 20a4147147
commit b3069cb353
5 changed files with 125 additions and 6 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ raspbian_boot
ncp-web/wizard.cfg
ncp-web/ncp-web.cfg
docker-armhf/qemu-arm-static
.vagrant/

50
Vagrantfile vendored Normal file
View File

@ -0,0 +1,50 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Vagrantfile test the NCP curl installer
#
# Instructions: vagrant up; vagrant ssh
#
# Notes: User/Pass is ubnt/ubnt.
# $HOME is accessible as /external. CWD is accessible as /cwd
#
Vagrant.configure("2") do |config|
vmname = "NCP Debian VM"
config.vm.box = "debian/stretch64"
config.vm.box_check_update = false
config.vm.hostname = "ncp-vm"
$script = <<-SHELL
sudo su
BRANCH=master
#BRANCH=devel # uncomment to install devel
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git
# indicate that this will be an image build
touch /.ncp-image
# install
git clone -b "$BRANCH" https://github.com/nextcloud/nextcloudpi.git /tmp/nextcloudpi
cd /tmp/nextcloudpi
# uncomment to install devel
#sed -i 's|^BRANCH=master|BRANCH=devel|' install.sh ncp.sh
bash install.sh
# cleanup
source etc/library.sh
install_script post-inst.sh
cd -
rm -r /tmp/nextcloudpi
poweroff
SHELL
# Provision the VM
config.vm.provision "shell", inline: $script
end

View File

@ -30,6 +30,9 @@ IMG="$( ls -1t tmp/*.img | head -1 )"
./build-SD-armbian.sh rock64 Rock64
./build-SD-armbian.sh bananapi Bananapi
# VM
./build-VM.sh
# Docker x86
make nextcloudpi-x86

68
build-VM.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
# Batch creation of NextCloudPi VM image
#
# 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: ./batch.sh <DHCP QEMU image IP>
#
set -e
source buildlib.sh
IP=${1:-192.168.0.145} # For QEMU automated testing (optional)
SIZE=3G # Raspbian image size
#CLEAN=0 # Pass this envvar to skip cleaning download cache
IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img"
##############################################################################
## preparations
IMG="NextCloudPi_VM_$( date "+%m-%d-%y" ).img"
IMG=tmp/"$IMG"
VM="/var/lib/libvirt/images/nextcloudpi_default.img"
set -e
prepare_dirs # tmp cache output
## BUILD NCP
echo -e "\e[1m\n[ Build NCP ]\e[0m"
vagrant destroy -f
vagrant up --provider=libvirt --provision
sudo chown "$USER" "$VM"
sudo cp --reflink=auto --sparse=auto "$VM" "$IMG"
## pack
TAR=output/"$( basename "$IMG" .img ).tar.bz2"
pack_image "$IMG" "$TAR"
## test
#set_static_IP "$IMG" "$IP"
#test_image "$IMG" "$IP" # TODO fix tests
# upload
create_torrent "$TAR"
upload_ftp "$( basename "$TAR" .tar.bz2 )"
# 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

View File

@ -72,12 +72,9 @@ install()
usermod -a -G redis www-data
# refresh configuration, only needed in curl installer
[[ ! -f /.ncp-image ]] && {
systemctl restart redis-server
systemctl enable redis-server
systemctl restart php${PHPVER}-fpm
}
service redis-server restart
update-rc.d redis-server enable
service php${PHPVER}-fpm restart
# service to randomize passwords on first boot
mkdir -p /usr/lib/systemd/system