-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ad.github.com:lncm/pi-factory
- Loading branch information
Showing
2 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters