Skip to content

Commit 07bab8e

Browse files
Merge pull request 'Install UFW and Update removed functions in Pillow 10' (#113) from ufw into main
Reviewed-on: pulls/113
2 parents e0ddae4 + dacc51e commit 07bab8e

5 files changed

Lines changed: 81 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ title: NODEYEZ Change Log
55

66
## main
77

8+
## 23.07
9+
10+
Released: 2023-07-30
11+
812
**New Panels and Ehancements**
913

1014
- Blockstats panels for feerates now reports the low value in addition to high and avg
@@ -16,6 +20,9 @@ title: NODEYEZ Change Log
1620
- Removed Twitter references
1721
- Added maze.html serverless sample (https://nodeyez.com/maze.html)
1822
- Reverted Python dependency to support 3.7
23+
- Installation now gives guidance on setting up UFW and fail2ban instead of assuming it was present. UFW is called upon to enable the website dashboard port for local network access
24+
- Mitigating partial RaspiBolt setup (Bitcoin installed, but not NGINX)
25+
- Updates to resolve deprecated and removed functions in Pillow
1926

2027
**Bugfixes**
2128

_install_steps/3tools.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,32 @@ Provides for network connection calls used by Miner tools
7474
sudo apt-get install netcat
7575
```
7676

77+
## Install Uncomplicated Firewall Rules
78+
79+
This provides for a convenient wrapper around iptables for network rules
80+
81+
```shell
82+
UFW_PATH=$(which ufw)
83+
if [ -z "$UFW_PATH" ]; then
84+
echo "installing and initializing ufw..."
85+
sudo apt-get -y install ufw
86+
sudo ufw default deny incoming
87+
sudo ufw default allow outgoing
88+
sudo ufw allow ssh
89+
sudo ufw logging off
90+
sudo ufw enable
91+
fi
92+
```
93+
94+
## Install Fail2Ban
95+
96+
Prevent brute force login attempts by rejecting for time after too many successive failed logins
97+
98+
```shell
99+
sudo apt-get -y install fail2ban
100+
```
101+
102+
77103
---
78104

79105
[Home](../) | [Back to Display Screen]({% link _install_steps/2displayscreen.md %}) | [Continue to Nodeyez]({% link _install_steps/4nodeyez.md %})

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Optionally attach a [Display Screen]({% link _install_steps/2displayscreen.md %}
6060

6161
Want to contribute and make changes? For guidance on setting up a development environment, start with the [Python and IDE Setup]({% link _developer/1basicsetup.md %}).
6262

63-
[Change Log]({% link CHANGELOG.md %})
63+
View the [Change Log]({% link CHANGELOG.md %})
6464

6565
You can support me by using the Mash Boost button, or sending me tips via [Strike](https://strike.me/vicariousdrama)
6666

install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ apt-get -y install \
138138
python3-venv \
139139
zlib1g-dev
140140

141+
# Install and initialize UFW if not present
142+
UFW_PATH=$(which ufw)
143+
if [ -z "$UFW_PATH" ]; then
144+
echo "installing and initializing ufw..."
145+
apt-get -y install ufw
146+
ufw default deny incoming
147+
ufw default allow outgoing
148+
ufw allow ssh
149+
ufw logging off
150+
ufw enable
151+
fi
152+
153+
# Install fail2ban
154+
apt-get -y install fail2ban
155+
141156
# Create Nodeyez user
142157
echo "================================================"
143158
echo "CREATING NODEYEZ USER"
@@ -426,6 +441,19 @@ elif [ $ISRASPIBOLT -gt 0 ]; then
426441
cp /home/nodeyez/nodeyez/scripts/nginx/https_nodeyez_raspibolt.conf /etc/nginx/streams-enabled/https_nodeyez_raspibolt.conf
427442
CREATED_WEBSITE=1
428443
fi
444+
else
445+
# nginx installed, but not with raspibolt custom config, warn and install generic
446+
echo "- based on the Bitcoin service file, this appears to be a RaspiBolt install"
447+
echo " but the Nginx configuration is default using sites-enabled instead of"
448+
echo " streams-enabled. A generic configuration for Nodeyez dashboard will be"
449+
echo " installed."
450+
echo "WARNING: If you proceed with the Raspibolt configuration of NGINX as defined here"
451+
echo " https://raspibolt.org/guide/raspberry-pi/security.html#prepare-nginx-reverse-proxy"
452+
echo "you may need to re-run this installation to setup the Nodeyez dashboard"
453+
echo "with the streams-enabled setup"
454+
echo "- copying Nodeyez site configuration as generic sites-enabled"
455+
cp /home/nodeyez/nodeyez/scripts/nginx/https_nodeyez.conf /etc/nginx/sites-enabled/https_nodeyez.conf
456+
CREATED_WEBSITE=1
429457
fi
430458
else
431459
# generic site config

scripts/vicarioustext.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,36 @@ def getmaxtextforwidth(draw, words, width, fontsize, isbold=False):
3737

3838
def gettextdimensions(draw, s, fontsize, isbold=False):
3939
thefont = getfont(fontsize, isbold)
40-
sw,sh = draw.textsize(s, thefont)
41-
return sw,sh,thefont
40+
# Deprecated, removed in Pillow 10.0.0
41+
#sw,sh = draw.textsize(s, thefont)
42+
# New in 8.0.0, required in Pillow 10.0.0
43+
left, top, right, bottom = thefont.getbbox(text=s)
44+
return right, bottom, thefont
45+
46+
def gettextoffset(thefont,s):
47+
# Deprecated, removed in Pillow 10.0.0
48+
#ox,oy = thefont.getoffset(s)
49+
# New in 8.0.0, required in Pillow 10.0.0
50+
left,top,_,_ = thefont.getbbox(text=s)
51+
return left, top
4252

4353
def drawcenteredtext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
4454
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
45-
ox,oy = thefont.getoffset(s)
55+
ox,oy = gettextoffset(thefont,s)
4656
sw += ox
4757
sh += oy
4858
draw.text(xy=(x-(sw/2),y-(sh/2)), text=s, font=thefont, fill=textcolor)
4959

5060
def drawbottomlefttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
5161
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
52-
ox,oy = thefont.getoffset(s)
62+
ox,oy = gettextoffset(thefont,s)
5363
sw += ox
5464
sh += oy
5565
draw.text(xy=(x,y-sh), text=s, font=thefont, fill=textcolor)
5666

5767
def drawbottomrighttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
5868
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
59-
ox,oy = thefont.getoffset(s)
69+
ox,oy = gettextoffset(thefont,s)
6070
sw += ox
6171
sh += oy
6272
draw.text(xy=(x-sw,y-sh), text=s, font=thefont, fill=textcolor)
@@ -99,28 +109,28 @@ def drawLabel(draw, s="", fontsize=12, anchorposition="tl", anchorx=0, anchory=0
99109

100110
def drawtoplefttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
101111
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
102-
ox,oy = thefont.getoffset(s)
112+
ox,oy = gettextoffset(thefont,s)
103113
sw += ox
104114
sh += oy
105115
draw.text(xy=(x,y), text=s, font=thefont, fill=textcolor)
106116

107117
def drawtoprighttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
108118
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
109-
ox,oy = thefont.getoffset(s)
119+
ox,oy = gettextoffset(thefont,s)
110120
sw += ox
111121
sh += oy
112122
draw.text(xy=(x-sw,y), text=s, font=thefont, fill=textcolor)
113123

114124
def drawrighttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
115125
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
116-
ox,oy = thefont.getoffset(s)
126+
ox,oy = gettextoffset(thefont,s)
117127
sw += ox
118128
sh += oy
119129
draw.text(xy=(x-sw,y-(sh/2)), text=s, font=thefont, fill=textcolor)
120130

121131
def drawlefttext(draw, s, fontsize, x, y, textcolor=colorFFFFFF, isbold=False):
122132
sw,sh,thefont = gettextdimensions(draw, s, fontsize, isbold)
123-
ox,oy = thefont.getoffset(s)
133+
ox,oy = gettextoffset(thefont,s)
124134
sw += ox
125135
sh += oy
126136
draw.text(xy=(x,y-(sh/2)), text=s, font=thefont, fill=textcolor)

0 commit comments

Comments
 (0)