From b3069cb353340a1d1b25c260419a830b65ae4997 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Sun, 21 Oct 2018 21:16:41 -0600 Subject: [PATCH] add Vagrantfile --- .gitignore | 1 + Vagrantfile | 50 +++++++++++++++++++++++ batch.sh | 3 ++ build-VM.sh | 68 ++++++++++++++++++++++++++++++++ etc/ncp-config.d/nc-nextcloud.sh | 9 ++--- 5 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 Vagrantfile create mode 100755 build-VM.sh diff --git a/.gitignore b/.gitignore index 0fe723ec..da3509e3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ raspbian_boot ncp-web/wizard.cfg ncp-web/ncp-web.cfg docker-armhf/qemu-arm-static +.vagrant/ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..f8626245 --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/batch.sh b/batch.sh index 8a50c041..08c2874e 100755 --- a/batch.sh +++ b/batch.sh @@ -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 diff --git a/build-VM.sh b/build-VM.sh new file mode 100755 index 00000000..a1a54f4b --- /dev/null +++ b/build-VM.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# Batch creation of NextCloudPi VM image +# +# Copyleft 2017 by Ignacio Nunez Hernanz +# GPL licensed (see end of file) * Use at your own risk! +# +# Usage: ./batch.sh +# + +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 diff --git a/etc/ncp-config.d/nc-nextcloud.sh b/etc/ncp-config.d/nc-nextcloud.sh index 45b5fe02..e4de7ea0 100644 --- a/etc/ncp-config.d/nc-nextcloud.sh +++ b/etc/ncp-config.d/nc-nextcloud.sh @@ -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