From b5816c7f793d9461f875ed5eecd87eb48febab0c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 14 Oct 2020 01:31:27 +0200 Subject: [PATCH] Optimize Vagrant Mode #1579 (#1665) --- Vagrantfile | 2 +- alternative.platforms/amd64/README.md | 7 ++- .../amd64/packer/scripts/init_vagrant.sh | 32 +++++------ home.admin/00raspiblitz.sh | 14 +++++ home.admin/XXsendNotification.py | 0 home.admin/XXsyncScripts.sh | 54 +++++++++++-------- .../blitz.subscriptions.ip2tor.py | 0 .../blitz.subscriptions.letsencrypt.py | 0 .../config.scripts/blitz.subscriptions.py | 0 .../config.scripts/bonus.angular_cli.sh | 0 .../config.scripts/bonus.circuitbreaker.sh | 0 home.admin/config.scripts/bonus.mempool.sh | 0 home.admin/config.scripts/bonus.typescript.sh | 0 home.admin/config.scripts/lnd.initwallet.py | 0 14 files changed, 63 insertions(+), 46 deletions(-) mode change 100644 => 100755 home.admin/XXsendNotification.py mode change 100644 => 100755 home.admin/config.scripts/blitz.subscriptions.ip2tor.py mode change 100644 => 100755 home.admin/config.scripts/blitz.subscriptions.letsencrypt.py mode change 100644 => 100755 home.admin/config.scripts/blitz.subscriptions.py mode change 100644 => 100755 home.admin/config.scripts/bonus.angular_cli.sh mode change 100644 => 100755 home.admin/config.scripts/bonus.circuitbreaker.sh mode change 100644 => 100755 home.admin/config.scripts/bonus.mempool.sh mode change 100644 => 100755 home.admin/config.scripts/bonus.typescript.sh mode change 100644 => 100755 home.admin/config.scripts/lnd.initwallet.py diff --git a/Vagrantfile b/Vagrantfile index 8c74f8ac..5bfaf7fc 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,7 +3,7 @@ Vagrant.configure('2') do |config| - config.vm.box = 'raspiblitz' + config.vm.box = 'rootzoll/raspiblitz' config.vm.network "private_network", type: "dhcp" diff --git a/alternative.platforms/amd64/README.md b/alternative.platforms/amd64/README.md index bd80038c..e5eaf198 100644 --- a/alternative.platforms/amd64/README.md +++ b/alternative.platforms/amd64/README.md @@ -14,11 +14,10 @@ On MacOS you need to install: 3. vagrant: `brew install vagrant` 4. virtualbox: `brew cask install virtualbox` (maybe re-run after you changed the requested secruity permission to be successfull) -```sha +``` cd alternative.platforms/amd64/packer packer build raspiblitz.json - -vagrant box add --force raspiblitz output/raspiblitz.box +vagrant box add --force rotzoll/raspiblitz output/raspiblitz.box cd ../../.. ``` @@ -36,4 +35,4 @@ You will need to connect a virtual data drive to the RaspiBlitzVM ... todo so: Every file in `home.admin` will be linked to `/home/admin` inside the VM, if you add a new file you should run `vagrant provision` to make sure it gets linked inside the VM. Every time you boot the VM, `home.admin` files will be linked automatically. -The content of the `/home/admin/assets` folder is not kept in sync at the moment (see [#1578](https://github.com/rootzoll/raspiblitz/issues/1578)). You can still access your development assets file inside the VM in `/vagrant/home.admin/assets/`. +The content of the `/home/admin/assets` folder is not kept in sync at the moment (see [#1578](https://github.com/rootzoll/raspiblitz/issues/1578)). You can still access your development assets file inside the VM in `/vagrant/home.admin/assets/`. \ No newline at end of file diff --git a/alternative.platforms/amd64/packer/scripts/init_vagrant.sh b/alternative.platforms/amd64/packer/scripts/init_vagrant.sh index 78465d6a..bad737a3 100644 --- a/alternative.platforms/amd64/packer/scripts/init_vagrant.sh +++ b/alternative.platforms/amd64/packer/scripts/init_vagrant.sh @@ -1,26 +1,18 @@ #!/bin/bash -set -e +echo "************* Vagrant Provisioning ********************" -echo "************* Vagrant provisioning ********************" +echo 'Syncing local code with RaspiBlitzVM' -echo 'linking development files' -source_dir=/vagrant/home.admin -dest_dir=$HOME +# make sure the lastest sync script is in place +cp /vagrant/home.admin/XXsyncScripts.sh /home/admin/XXsyncScripts.sh -cd $source_dir -for f in *; do - if [ "$f" = "assets" ] ; then - continue - fi +# execute 'patch' command to sync laptop with VM +/home/admin/XXsyncScripts.sh -run - source_file="$source_dir/$f" - dest_file="$dest_dir/$f" - - if [ -L $dest_file ] && [ "$(readlink "$dest_file")" = "$source_file" ]; then - continue - fi - - rm -rf "$dest_file" - ln -s "$source_file" "$dest_file" -done +echo +echo "************* NEXT ********************" +echo "vagrant ssh --> ssh into your RaspiBlitzVM" +echo "vagrant provision --> trigger code sync from outside VM" +echo "patch --> trigger code sync from inside the VM" +echo \ No newline at end of file diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 4388c11b..b49aae87 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -20,6 +20,20 @@ if [ ${isMounted} -eq 0 ] && [ ${#hddCandidate} -eq 0 ]; then echo "***********************************************************" echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart." echo "***********************************************************" + vagrant=$(df | grep -c "/vagrant") + if [ ${vagrant} ]; then + echo "To connect a HDD data disk to your VagrantVM:" + echo "- shutdown VM with command: off" + echo "- open your VirtualBox GUI and select RaspiBlitzVM" + echo "- change the 'mass storage' settings" + echo "- add a second 'Primary Slave' drive to the already existing controller" + echo "- close VirtualBox GUI and run: vagrant up & vagrant ssh" + echo "***********************************************************" + echo "You can either create a new dynamic VDI with around 900GB or download" + echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB" + echo "space on your laptop you can store the VDI file on an external drive." + echo "***********************************************************" + fi exit fi diff --git a/home.admin/XXsendNotification.py b/home.admin/XXsendNotification.py old mode 100644 new mode 100755 diff --git a/home.admin/XXsyncScripts.sh b/home.admin/XXsyncScripts.sh index dd125b34..cb08e645 100755 --- a/home.admin/XXsyncScripts.sh +++ b/home.admin/XXsyncScripts.sh @@ -30,6 +30,7 @@ if [ "$1" == "info" ]; then fi # change branch if set as parameter +vagrant=0 clean=0 install=0 wantedBranch="$1" @@ -38,6 +39,12 @@ if [ "${wantedBranch}" = "-run" ]; then # "-run" ist just used by "patch" command and will ignore all further parameter wantedBranch="${activeBranch}" wantedGitHubUser="${activeGitHubUser}" + # detect if running in vagrant VM + vagrant=$(df | grep -c "/vagrant") + if [ "$2" = "git" ]; then + echo "# forcing guthub over vagrant sync" + vagrant=0 + fi fi if [ "${wantedBranch}" = "-clean" ]; then clean=1 @@ -57,7 +64,7 @@ if [ "${wantedBranch}" = "-justinstall" ]; then fi # set to another GutHub repo as origin -if [ ${#wantedGitHubUser} -gt 0 ]; then +if [ ${#wantedGitHubUser} -gt 0 ] && [ ${vagrant} -eq 0 ]; then echo "# your active GitHubUser is: ${activeGitHubUser}" echo "# your wanted GitHubUser is: ${wantedGitHubUser}" if [ "${activeGitHubUser}" = "${wantedGitHubUser}" ]; then @@ -77,7 +84,7 @@ if [ ${#wantedGitHubUser} -gt 0 ]; then fi fi -if [ ${#wantedBranch} -gt 0 ]; then +if [ ${#wantedBranch} -gt 0 ] && [ ${vagrant} -eq 0 ]; then echo "# your active branch is: ${activeBranch}" echo "# your wanted branch is: ${wantedBranch}" if [ "${wantedBranch}" = "${activeBranch}" ]; then @@ -109,26 +116,35 @@ if [ ${#wantedBranch} -gt 0 ]; then fi fi -origin=$(git remote -v | grep 'origin' | tail -n1) checkSumBlitzPyBefore=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum) checkSumBlitzTUIBefore=$(find /home/admin/raspiblitz/home.admin/BlitzTUI -type f -exec md5sum {} \; | md5sum) -echo "# *** SYNCING SHELL SCRIPTS WITH GITHUB ***" -echo "# This is for developing on your RaspiBlitz." -echo "# THIS IS NOT THE REGULAR UPDATE MECHANISM" -echo "# and can lead to dirty state of your scripts." -echo "# REPO ----> ${origin}" -echo "# BRANCH --> ${activeBranch}" -echo "# ******************************************" -git pull 1>&2 -cd .. +if [ ${vagrant} -eq 0 ]; then + origin=$(git remote -v | grep 'origin' | tail -n1) + echo "# *** SYNCING RASPIBLITZ CODE WITH GITHUB ***" + echo "# This is for developing on your RaspiBlitz." + echo "# THIS IS NOT THE REGULAR UPDATE MECHANISM" + echo "# and can lead to dirty state of your scripts." + echo "# REPO ----> ${origin}" + echo "# BRANCH --> ${activeBranch}" + echo "# ******************************************" + git pull 1>&2 + cd .. +else + cd .. + echo "# --> VAGRANT IS ACTIVE" + echo "# *** SYNCING RASPIBLITZ CODE WITH VAGRANT LINKED DIRECTORY ***" + echo "# This is for developing on your RaspiBlitz with a VM." + sudo rm -r /home/admin/raspiblitz + sudo cp -r /vagrant /home/admin/raspiblitz + sudo chown admin:admin -R /home/admin/raspiblitz +fi + if [ ${clean} -eq 1 ]; then - echo "# Cleaning scripts & assets/config.scripts" + echo "# Cleaning assets .. " sudo rm -f *.sh sudo rm -rf assets - mkdir assets - sudo rm -rf config.scripts - mkdir config.scripts + sudo -u admin mkdir assets else echo "# ******************************************" echo "# NOT cleaning/deleting old files" @@ -137,16 +153,12 @@ else fi echo "# COPYING from GIT-Directory to /home/admin/" +sudo rm -r /home/admin/config.scripts sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin -echo "# .." sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/assets /home/admin -echo "# .." sudo -u admin chmod +x /home/admin/*.sh -echo "# .." sudo -u admin chmod +x /home/admin/*.py -echo "# .." sudo -u admin chmod +x /home/admin/config.scripts/*.sh -echo "# .." sudo -u admin chmod +x /home/admin/config.scripts/*.py echo "# ******************************************" diff --git a/home.admin/config.scripts/blitz.subscriptions.ip2tor.py b/home.admin/config.scripts/blitz.subscriptions.ip2tor.py old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/blitz.subscriptions.letsencrypt.py b/home.admin/config.scripts/blitz.subscriptions.letsencrypt.py old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/blitz.subscriptions.py b/home.admin/config.scripts/blitz.subscriptions.py old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/bonus.angular_cli.sh b/home.admin/config.scripts/bonus.angular_cli.sh old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/bonus.circuitbreaker.sh b/home.admin/config.scripts/bonus.circuitbreaker.sh old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/bonus.mempool.sh b/home.admin/config.scripts/bonus.mempool.sh old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/bonus.typescript.sh b/home.admin/config.scripts/bonus.typescript.sh old mode 100644 new mode 100755 diff --git a/home.admin/config.scripts/lnd.initwallet.py b/home.admin/config.scripts/lnd.initwallet.py old mode 100644 new mode 100755