Skip to content

Commit

Permalink
Merge pull request #238 from nolim1t/issue-236
Browse files Browse the repository at this point in the history
Merged into master as now working
  • Loading branch information
nolim1t authored Oct 7, 2019
2 parents 9113327 + dd69e61 commit b8e4011
Show file tree
Hide file tree
Showing 34 changed files with 250 additions and 459 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

/.idea

# Don't commit .vagrant
.vagrant

# Alpine sensitive stuff: Docker key
key.json

Expand All @@ -24,9 +27,11 @@ home/lncm/README.*
# Don't commit LNCM variant build stuff
lncm-box-*.tar.gz
*.img
lncm-box-*.img.zip

# Don't commit work dir
lncm-workdir/

# Don't apkvol
*.apkovl.tar.gz

2 changes: 1 addition & 1 deletion etc/apk/arch
Original file line number Diff line number Diff line change
@@ -1 +1 @@
armhf
aarch64
26 changes: 10 additions & 16 deletions etc/apk/protected_paths.d/lbu.list
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
+etc/tor/torrc
+etc/motd
+etc/init.d/lncm
+etc/init.d/lncm-post
+etc/init.d/lncm-online
+etc/init.d/docker-compose
+etc/init.d/iotwifi
+etc/tor/torrc
+etc/init.d/avahi-daemon
+etc/init.d/portainer
+etc/init.d/wpa_supplicant
+etc/init.d/noma
+etc/init.d/sshd
+etc/init.d/nginx
+etc/init.d/wpa_supplicant.alt
+etc/init.d/wpa_supplicant
+home/lncm/.ssh
+home/lncm/bitcoin
+home/lncm/litecoin
+home/lncm/lnd
Expand All @@ -21,15 +22,8 @@
+home/lncm/public_html/wifi/index.html
+home/lncm/nginx
+home/lncm/nginx/conf.d
+home/lncm/.ssh/authorized_keys
+home/lncm/save_password
+home/lncm/seed.txt
+home/lncm/.ssh/authorized_key
+etc/ssh/sshd_config
+usr/local/bin/setup-disk.sh
+usr/local/sbin
+usr/local/sbin/mana
+usr/local/sbin/lncm-usb
+usr/local/sbin/lncm-usb.py
+usr/local/sbin/lncm-unlock.py
+usr/local/sbin/check-invoicer-status
+usr/local/sbin/lncm-createwallet.py
+usr/local/sbin/lncm-istorprivkeycreated.py
+usr/local/sbin/lncm-configinvoicer.py
+usr/local/sbin/lncm-getinfo.py
16 changes: 6 additions & 10 deletions etc/apk/repositories
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/media/mmcblk0p1/apks
http://mirror.rise.ph/alpine-linux/v3.8/main
http://mirror.rise.ph/alpine-linux/v3.8/community
http://mirror.xtom.com.hk/alpine/v3.8/main
http://mirror.xtom.com.hk/alpine/v3.8/community
#http://dl-3.alpinelinux.org/alpine/v3.8/main
#http://dl-3.alpinelinux.org/alpine/v3.8/community
#http://dl-5.alpinelinux.org/alpine/v3.8/main
#http://dl-5.alpinelinux.org/alpine/v3.8/community
#http://dl-8.alpinelinux.org/alpine/v3.8/main
#http://dl-8.alpinelinux.org/alpine/v3.8/community
http://mirror.xtom.com.hk/alpine/v3.10/main
http://mirror.xtom.com.hk/alpine/v3.10/community
#http://mirror.xtom.com.hk/alpine/edge/main
#http://mirror.xtom.com.hk/alpine/edge/community
#http://mirror.xtom.com.hk/alpine/edge/testing

4 changes: 2 additions & 2 deletions etc/apk/world
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
alpine-base
avahi
dbus
docker
chrony
openssh
openssl
wireless-tools
wpa_supplicant
3 changes: 2 additions & 1 deletion etc/group
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ nogroup:x:65533:
nobody:x:65534:
avahi:x:86:avahi
messagebus:x:101:messagebus
docker:x:102:
docker:x:102:lncm
lncm:x:1001:
chrony:x:101:chrony
30 changes: 0 additions & 30 deletions etc/init.d/avahi-daemon

This file was deleted.

66 changes: 0 additions & 66 deletions etc/init.d/docker-compose

This file was deleted.

16 changes: 0 additions & 16 deletions etc/init.d/iotwifi

This file was deleted.

9 changes: 4 additions & 5 deletions etc/init.d/lncm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ start() {
# This script will only run once, for persistent installation to SD

# LNCM version
VER="v0.4.1"
VER="v0.5.0"

# apkovl
APK=box.apkovl.tar.gz
Expand Down Expand Up @@ -47,7 +47,6 @@ start() {

install_tools() {
echo "Add partitioning and filesystem tools"
/sbin/setup-apkcache /media/mmcblk0p1/cache && \
/sbin/apk add parted e2fsprogs
}

Expand Down Expand Up @@ -103,8 +102,8 @@ start() {
setup_user() {
echo "Create lncm home dir if necessary"
/bin/mkdir -p /media/sd/home/lncm
echo "Set user permissions"
/bin/chown lncm:lncm /media/sd/home/lncm
echo "Fix user permissions"
/bin/chown -R lncm:lncm /media/sd/home/lncm
}

install_boot() {
Expand Down Expand Up @@ -190,7 +189,7 @@ start() {
setup_user
install_boot
mark_sd
#create_swap # disable sd card swap
create_swap
enable_post
disable_install
persist_state
Expand Down
10 changes: 8 additions & 2 deletions etc/init.d/lncm-online
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ start() {
}

ONLINE=1
COUNT=0

while [ $ONLINE -eq 1 ]
while [ $ONLINE -eq 1 ] && [ $COUNT -lt 10 ]
do
echo "Checking for internet connection..."
echo "Checking for internet connection for 10 seconds..."
net_check
COUNT=$((COUNT + 1))
sleep 1
done

if [ $ONLINE -eq 0 ]; then
echo "Connected to internet"
exit 0
else
echo "Not connected to internet.. please update wpa_supplicant"
echo "and then reboot to continue the setup process"
exit 1
fi

eend $?
Expand Down
69 changes: 42 additions & 27 deletions etc/init.d/lncm-post
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,41 @@ start() {
fi
/sbin/setup-apkcache /var/cache/apk
}

install_python3() {
echo "Install Python 3 and upgrade PIP"
/sbin/apk update && \
/sbin/apk add python3 python3-dev

/usr/bin/pip3 install --upgrade pip
}

install_utils() {
echo "Installing utils (avahi/dbus/curl/jq)"
/sbin/apk update && \
/sbin/apk add dbus avahi curl jq docker
}

config_avahi() {
echo "Configuring Avahi"
/sbin/rc-update add dbus boot || echo "Unable to add dbus to boot runlevels"
/sbin/rc-update add avahi-daemon boot || echo "Unable to add avahi to boot runlevels"
echo "Starting DBUS and AVAHI"
/etc/init.d/dbus start || echo "Failed to start dbus"
/etc/init.d/avahi-daemon start || echo "Failed to start avahi"
}

config_docker() {
echo "Configuring docker"
/sbin/rc-update add docker default
echo "Starting docker"
/etc/init.d/docker start || echo "Failed to start docker"
}

install_alpine_sdk() {
echo "Install alpine devtools (used for building)"
/sbin/apk add alpine-sdk linux-headers libffi-dev
}

install_compose() {
echo "Install docker-compose and dependencies"
Expand All @@ -44,7 +79,7 @@ start() {
echo "Install Noma dependencies in case user wants to install it"
/sbin/apk add py3-psutil
#Uncomment noma for now because noma stop seems to be broken
#/usr/bin/pip3 install noma==0.4.5
/usr/bin/pip3 install noma==0.5.0
}

install_toml() {
Expand Down Expand Up @@ -148,7 +183,7 @@ start() {
setup_tor() {
CHECKTOR_HOSTNAME=1
# Check to see if Tor generated directory exists
while [ ! -d /var/lib/tor/lnd-v3 ] && [ $CHECKTOR_HOSTNAME -lt 10 ];
while [ ! -d /var/lib/tor/ssh-v3 ] && [ $CHECKTOR_HOSTNAME -lt 10 ];
do
echo "Tor generated directory doesn't exist yet.. waiting";
CHECKTOR_HOSTNAME=$((CHECKTOR_HOSTNAME+1))
Expand Down Expand Up @@ -266,11 +301,6 @@ start() {
/usr/bin/crontab /home/lncm/crontab
}

persist_state() {
echo "Backup apkovl.tar.gz to USB storage"
/sbin/lbu package /media/important/important/box.apkovl.tar.gz
}

disable_post() {
echo "Remove lncm-post from boot"
/sbin/rc-update del lncm-post default
Expand All @@ -291,29 +321,14 @@ start() {
fi

move_cache
install_compose
install_toml
install_noma
usb_setup
verify_usb
# Fetch invoicer into path
fetch_invoicerconfig
fetch_rpcauth
check_rpc
# Configure invoicer, and services stage
generate_rpc
install_utils
config_docker
config_avahi
install_alpine_sdk
install_python3
install_tor
enable_tor
setup_tor
# Copy into path
config_bitcoind
config_lnd
config_nginx
fetch_invoicerui
install_crontab
disable_post
enable_compose
persist_state
}

main
Expand Down
Loading

0 comments on commit b8e4011

Please sign in to comment.