From 38c38b3ec39a1506431e5c676c53067dbea407d8 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Thu, 13 Dec 2018 12:05:48 +0700 Subject: [PATCH 1/3] Add bitcoind install placeholder --- etc/init.d/bitcoind-install | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 etc/init.d/bitcoind-install diff --git a/etc/init.d/bitcoind-install b/etc/init.d/bitcoind-install new file mode 100644 index 00000000..b9526a42 --- /dev/null +++ b/etc/init.d/bitcoind-install @@ -0,0 +1,74 @@ +#!/sbin/openrc-run +# +# Copyright 2018 LNCM contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +## LNCM post-installation script +## To be run on persistently installed SD card + +depend() { + need net sshd +} + +start() { + ebegin "Starting bitcoind-installation" + # This script will only run once, to complete post-installation + + # LNCM version + VER="v0.3.0" + + # Check if main mirror is reachable + net_check() { + ONLINE=$(echo -e 'GET http://dl-cdn.alpinelinux.org/alpine/ HTTP/1.0\n\n' | nc dl-cdn.alpinelinux.org 80 > /dev/null 2>&1; echo $?) + } + + ONLINE=1 + + if [ -f /etc/lncm-post-installed ]; then + while [ $ONLINE -eq 1 ] + do + echo "Checking for internet connection..." + net_check + sleep 1 + done + + if [ $ONLINE -eq 0 ]; then + echo "Online, proceeding with bitcoin installation" + cd /home/lncm + mkdir -p /home/lncm/.bitcoin + mv /home/lncm/bitcoin.conf /home/lncm/.bitcoin/ + + echo "Grab docker image from docker hub" + docker pull lncm/bitcoind:0.17.0-alpine-arm7 + + echo "Remove bitcoind-install from boot" + /sbin/rc-update del bitcoind-install default + + touch /etc/lncm-post-installed + + exit 0 + else + echo "LNCM post installation already complete" + exit 0 + fi + else + echo "LNCM post installation not found!" + exit 1 + fi + if [ $ONLINE -eq 1] + echo "No internet connection. Aborting installation!" + exit 1 + fi + eend $? +} From 0f800f8fae77ce2bb83d6736813abd36f57cf285 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Thu, 13 Dec 2018 12:22:11 +0700 Subject: [PATCH 2/3] Add some pre-condition checks --- etc/init.d/bitcoind-install | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/etc/init.d/bitcoind-install b/etc/init.d/bitcoind-install index b9526a42..7320dad1 100644 --- a/etc/init.d/bitcoind-install +++ b/etc/init.d/bitcoind-install @@ -44,20 +44,30 @@ start() { done if [ $ONLINE -eq 0 ]; then - echo "Online, proceeding with bitcoin installation" - cd /home/lncm - mkdir -p /home/lncm/.bitcoin - mv /home/lncm/bitcoin.conf /home/lncm/.bitcoin/ + if ! [ -f /etc/bitcoind-installed ]; then + echo "Online, proceeding with bitcoin installation, if not installed" + cd /home/lncm + mkdir -p /home/lncm/.bitcoin + mv /home/lncm/bitcoin.conf /home/lncm/.bitcoin/ - echo "Grab docker image from docker hub" - docker pull lncm/bitcoind:0.17.0-alpine-arm7 + echo "Grab docker image from docker hub - if supported" + if [ $(uname -m) == "armv7l" ]; then + if ! docker images | grep 0.17.0-alpine-arm7; then + echo "Grabbing arm7 image" + docker pull lncm/bitcoind:0.17.0-alpine-arm7 + fi + fi - echo "Remove bitcoind-install from boot" - /sbin/rc-update del bitcoind-install default + echo "Remove bitcoind-install from boot" + /sbin/rc-update del bitcoind-install default - touch /etc/lncm-post-installed + touch /etc/bitcoind-installed - exit 0 + exit 0 + else + echo "bitcoind - already installed" + exit 0 + fi else echo "LNCM post installation already complete" exit 0 From acc6d1ac1049b32c3a17c8875774ac62808ef822 Mon Sep 17 00:00:00 2001 From: Another Droog <36770425+AnotherDroog@users.noreply.github.com> Date: Thu, 13 Dec 2018 18:05:59 +0700 Subject: [PATCH 3/3] Bump version number --- make_img.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make_img.sh b/make_img.sh index 358a123f..35143efd 100755 --- a/make_img.sh +++ b/make_img.sh @@ -28,7 +28,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -VER=v0.3.0 +VER=v0.3.1 ALP=alpine-rpi-3.8.1-armhf.tar.gz IMG=lncm-box-${VER}.img IOT=iotwifi.tar.gz @@ -105,4 +105,4 @@ umount $MNT losetup -d ${DEV} echo "Compress img as zip" zip -r ${IMG}.zip $IMG -echo -e "\nDone!\nYou may flash your ${IMG}.zip using Etcher or dd the ${IMG}" \ No newline at end of file +echo -e "\nDone!\nYou may flash your ${IMG}.zip using Etcher or dd the ${IMG}"