diff --git a/build_sdcard.sh b/build_sdcard.sh index 0fd291f..44d98a4 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -4,10 +4,10 @@ # RASPBIAN STRETCH WITH DESKTOP (2019-04-09) # https://www.raspberrypi.org/downloads/raspbian/ # SHA256: 7e10a446f8e57210d0e9ad02f0c833aabb86e58187b4dc02431aff5a3f1ccb83 -# +# # or download the image for your ARM based SBC on https://DietPi.com ########################################################################## -# setup fresh SD card with image above - login per SSH and run this script: +# setup fresh SD card with image above - login per SSH and run this script: ########################################################################## echo "" @@ -41,7 +41,7 @@ echo "" echo "*** CHECK BASE IMAGE ***" # armv7=32Bit , armv8=64Bit -echo "Detect CPU architecture ..." +echo "Detect CPU architecture ..." isARM=$(uname -m | grep -c 'arm') isAARCH64=$(uname -m | grep -c 'aarch64') isX86_64=$(uname -m | grep -c 'x86_64') @@ -56,7 +56,7 @@ else fi # keep in mind that DietPi for Raspberry is also a stripped down Raspbian -echo "Detect Base Image ..." +echo "Detect Base Image ..." baseImage="?" isDietPi=$(uname -n | grep -c 'DietPi') isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian') @@ -67,7 +67,7 @@ if [ ${isRaspbian} -gt 0 ]; then fi if [ ${isArmbian} -gt 0 ]; then baseImage="armbian" -fi +fi if [ ${isUbuntu} -gt 0 ]; then baseImage="ubuntu" fi @@ -143,7 +143,7 @@ fi # special prepare when Ubuntu or Armbian if [ "${baseImage}" = "ubuntu" ] || [ "${baseImage}" = "armbian" ]; then - # make user pi and add to sudo + # make user pi and add to sudo sudo adduser --disabled-password --gecos "" pi sudo adduser pi sudo fi @@ -270,11 +270,6 @@ sudo apt-get install -y fbi # prepare for powertest sudo apt install -y sysbench -# prepare dor display service -# see https://github.com/rootzoll/raspiblitz/issues/88#issuecomment-471342311 -sudo apt-get install -y redis-server -sudo -H pip3 install redis - # check for dependencies on DietPi, Ubuntu, Armbian sudo apt-get install -y build-essential sudo apt-get install -y python-pip @@ -431,7 +426,7 @@ fi # correct versions for install if needed # just if an small update shows a different formatted version number -if [ "${bitcoinVersion}" = "0.17.0.1" ]; then +if [ "${bitcoinVersion}" = "0.17.0.1" ]; then bitcoinVersion="0.17.0" fi @@ -494,11 +489,11 @@ fi if [ ${isX86_64} -eq 1 ] ; then lndOSversion="amd64" lndSHA256="c55367edb82955dc942baf9f48f79fadde1eee0e86c1d59d2fe1993140ec1b3f" -fi +fi if [ ${isX86_32} -eq 1 ] ; then lndOSversion="386" lndSHA256="00a7cd0ca657bb242b0f3acb5f4e26a13fd789946fab73c252118e3f89c1cf57" -fi +fi echo "" echo "*** LND v${lndVersion} for ${lndOSversion} ***" @@ -506,7 +501,7 @@ echo "*** LND v${lndVersion} for ${lndOSversion} ***" # olaoluwa PGPpkeys="https://keybase.io/roasbeef/pgp_keys.asc" PGPcheck="BD599672C804AF2770869A048B80CD2BB8BD8132" -# bitconner +# bitconner #PGPpkeys="https://keybase.io/bitconner/pgp_keys.asc" #PGPcheck="9C8D61868A7C492003B2744EE7D737B67FA592C7" @@ -561,7 +556,7 @@ fi # prepare python for lnd api use # https://dev.lightning.community/guides/python-grpc/ -# +# echo "" echo "*** LND API for Python ***" sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 3 @@ -569,7 +564,8 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 echo "to switch between python2/3: sudo update-alternatives --config python" sudo apt-get -f -y install virtualenv -sudo -u admin bash -c "cd; sudo virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; sudo pip install grpcio grpcio-tools googleapis-common-protos pathlib2" +sudo chown -R admin /home/admin +sudo -u admin bash -c "cd; virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; pip install grpcio grpcio-tools googleapis-common-protos pathlib2" echo "" # "*** Installing Go ***" @@ -584,10 +580,10 @@ if [ ${isAARCH64} -eq 1 ] ; then fi if [ ${isX86_64} -eq 1 ] ; then goOSversion="amd64" -fi +fi if [ ${isX86_32} -eq 1 ] ; then goOSversion="386" -fi +fi echo "*** Installing Go v${goVersion} for ${goOSversion} ***" @@ -781,7 +777,7 @@ echo "" # install default LCD on DietPi without reboot to allow automatic build if [ "${baseImage}" = "dietpi" ]; then - echo "Installing the default display available from Amazon" + echo "Installing the default display available from Amazon" # based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip cd /home/admin/ # sudo apt-mark hold raspberrypi-bootloader @@ -820,7 +816,7 @@ if [ "${baseImage}" = "raspbian" ]; then # *** RASPIBLITZ / LCD (at last - because makes a reboot) *** # based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip - + echo "--> LCD DEFAULT" cd /home/admin/ sudo apt-mark hold raspberrypi-bootloader diff --git a/home.admin/00infoLCDTK.py b/home.admin/00infoLCDTK.py new file mode 100644 index 0000000..43e43e7 --- /dev/null +++ b/home.admin/00infoLCDTK.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# 00infoLCDTK.py +# +# called by # +# /home/pi/autostart.sh +# dev/test/run with: +# sudo -i -u pi DISPLAY=:0.0 /usr/bin/python3 /home/admin/00infoLCDTK.py + +import os +import sys +import json +import logging +import logging.config +import tkinter as tk + +COLOR = "black" +WINFO = None + +log = logging.getLogger() + + +def setup_logging(default_path='00infoLCDw.json'): + """Setup logging configuration""" + path = default_path + if os.path.exists(path): + with open(path, 'rt') as f: + config = json.load(f) + logging.config.dictConfig(config) + else: # if $default_path does not exist use the following default log setup + default_config_as_json = """ +{ + "version": 1, + "disable_existing_loggers": false, + "formatters": { + "simple": { + "format": "%(asctime)s - %(levelname)s - %(message)s" + }, + "extended": { + "format": "%(asctime)s - %(name)s - %(levelname)s - %(module)s:%(lineno)d - %(message)s" + } + + }, + + "handlers": { + "console": { + "class": "logging.StreamHandler", + "level": "INFO", + "formatter": "simple", + "stream": "ext://sys.stdout" + }, + + "file_handler": { + "class": "logging.handlers.RotatingFileHandler", + "level": "DEBUG", + "formatter": "extended", + "filename": "00infoLCDTK.log", + "maxBytes": 10485760, + "backupCount": 0, + "encoding": "utf8" + } + }, + + "loggers": { + "infoblitz": { + "level": "INFO", + "handlers": ["console", "file_handler"], + "propagate": "no" + } + }, + + "root": { + "level": "INFO", + "handlers": ["console", "file_handler"] + } +} +""" + config = json.loads(default_config_as_json) + logging.config.dictConfig(config) + + +def callback_b1(): + global WINFO + log.info("clicked b1") + if sys.platform != "win32": + os.system("xterm -fn fixed -into %d +sb -hold /home/admin/00infoLCD.sh &" % WINFO) + + +def callback_b2(): + global WINFO + log.info("clicked b2") + if sys.platform != "win32": + os.system("xterm -fn fixed -into %d +sb -hold /home/admin/XXbutton2.sh &" % WINFO) + + +def callback_b4(): + global WINFO + log.info("clicked b4") + if sys.platform != "win32": + os.system("xterm -fn fixed -into %d +sb -hold /home/admin/XXshutdown.sh &" % WINFO) + + +def main(): + global WINFO + setup_logging() + log.info("Starting 00infoLCDTK.py") + + root = tk.Tk() + root.config(bg=COLOR) + root.overrideredirect(1) + root.geometry("480x320+0+0") + root.title("RaspiBlitz 1.x") + + entry = tk.Entry(root) + entry.config(bg=COLOR, highlightbackground=COLOR) + + frame1 = tk.Frame(entry, width=60, background="black") + frame2 = tk.Frame(entry, width=420, background="grey") + + button1 = tk.Button(frame1, text='\u0397', fg='black', command=callback_b1) + button2 = tk.Button(frame1, text='\u0399', fg='black', command=callback_b2) + label3 = tk.Label(frame1, text='1.x', bg=COLOR, fg='white') + button4 = tk.Button(frame1, text='\N{BLACK CIRCLE}', fg='red', command=callback_b4) + + button1.pack(pady=24) + button2.pack(pady=24) + label3.pack(pady=24) + button4.pack(pady=24) + + entry.pack(side="bottom", fill="x") + frame1.pack(side="left", fill="both", expand=True) + frame2.pack(side="right", fill="both", expand=True) + + WINFO = frame2.winfo_id() + if sys.platform != "win32": + os.system("xterm -fn fixed -into %d +sb -hold /home/admin/00infoLCD.sh &" % WINFO) + + root.mainloop() + + +if __name__ == '__main__': + main() diff --git a/home.admin/XXbutton2.sh b/home.admin/XXbutton2.sh new file mode 100755 index 0000000..799efd9 --- /dev/null +++ b/home.admin/XXbutton2.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "" +echo "Thanks" +echo "You pressed B2" +echo "-----------------------------------------------" +echo "Sleep for 10" +sleep 10 +echo "Goodbye" +echo "-----------------------------------------------" +exit 0 diff --git a/home.admin/XXreboot.sh b/home.admin/XXreboot.sh new file mode 100755 index 0000000..c1673ac --- /dev/null +++ b/home.admin/XXreboot.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# CONFIGFILE - configuration of RaspiBlitz +configFile="/mnt/hdd/raspiblitz.conf" + +# INFOFILE - state data from bootstrap +infoFile="/home/admin/raspiblitz.info" + +# MAIN MENU AFTER SETUP +source ${infoFile} +source ${configFile} + +echo "" +echo "LCD turns white when shutdown complete." +echo "Then wait 5 seconds and disconnect power." +echo "-----------------------------------------------" +echo "stop lnd - please wait .." +sudo systemctl stop lnd +echo "stop ${network}d (1) - please wait .." +sudo -u bitcoin ${network}-cli stop +sleep 10 +echo "stop ${network}d (2) - please wait .." +sudo systemctl stop ${network}d +sleep 3 +sync +echo "starting shutdown ..." +sudo shutdown -r now +exit 0 diff --git a/home.admin/XXshutdown.sh b/home.admin/XXshutdown.sh new file mode 100755 index 0000000..9902d9f --- /dev/null +++ b/home.admin/XXshutdown.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# CONFIGFILE - configuration of RaspiBlitz +configFile="/mnt/hdd/raspiblitz.conf" + +# INFOFILE - state data from bootstrap +infoFile="/home/admin/raspiblitz.info" + +# MAIN MENU AFTER SETUP +source ${infoFile} +source ${configFile} + +network=bitcoin + +echo "" +echo "LCD turns white when shutdown complete." +echo "Then wait 5 seconds and disconnect power." +echo "-----------------------------------------------" +echo "stop lnd - please wait .." +sudo systemctl stop lnd +echo "stop ${network}d (1) - please wait .." +sudo -u bitcoin ${network}-cli stop +sleep 10 +echo "stop ${network}d (2) - please wait .." +sudo systemctl stop ${network}d +sleep 3 +sync +echo "starting shutdown ..." +sudo shutdown -h now +exit 0