Skip to content

Commit

Permalink
Merge branch 'master' of ad.github.com:lncm/pi-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherDroog committed Dec 13, 2018
2 parents b14c915 + acc6d1a commit 968b2cd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
84 changes: 84 additions & 0 deletions etc/init.d/bitcoind-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/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
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 - 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

touch /etc/bitcoind-installed

exit 0
else
echo "bitcoind - already installed"
exit 0
fi
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 $?
}
4 changes: 2 additions & 2 deletions make_img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
echo -e "\nDone!\nYou may flash your ${IMG}.zip using Etcher or dd the ${IMG}"

0 comments on commit 968b2cd

Please sign in to comment.