This commit is contained in:
jaydee
2022-12-14 02:23:34 +01:00
parent fdcd79983a
commit 7385b59c72
43 changed files with 1729 additions and 0 deletions

View File

@ -0,0 +1,31 @@
MODE="worker"
mac=`ifconfig eth0 |grep ether|awk '{ print $2 }'`
echo $mac
syst=9
case $mac in
"00:1E:06:48:CE:E7")
syst=1
MODE="master"
;;
"00:1e:06:48:cd:86")
syst=2
;;
"00:1e:06:48:d0:01")
syst=3
;;
"00:1e:06:48:d0:00")
syst=4
;;
"00:1e:06:48:cd:8e")
syst=5
;;
esac
echo "lala" > /tmp/check.log
hostnamectl hostname odroidc4-${syst}
sed -i 's/^TERM=/#TERM=/g' /etc/update-motd.d/10-armbian-header
sed -i '32 i TERM=linux toilet -f standard -F metal $(hostname)' /etc/update-motd.d/10-armbian-header
TERM=linux toilet -f standard -F metal $(hostname)
nmcli con mod "Wired connection 1" ipv4.addresses "192.168.77.16${syst}/24" ipv4.gateway "192.168.77.1" ipv4.dns "192.168.77.1" ipv4.method "manual"
iptables -F
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

View File

@ -0,0 +1,54 @@
# Import LCD library
from RPLCD import i2c
import psutil
import datetime
import os
from uptime import uptime
# Import sleep library
from time import sleep
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
while True:
myCmd = ""
# Write a string on first line and move to next line
mem_data = psutil.virtual_memory()
net_sum = psutil.net_if_addrs()["eth0"]
eth0_ip = (net_sum[0][1])
cpu_load = round(psutil.getloadavg()[0],2)
uptime_s = int(uptime())
uptime_f = str(datetime.timedelta(seconds=uptime_s))
line1 = f'{"Mem: " + str(mem_data.percent): <20}'
line2 = f'{"IP : " + str(eth0_ip): <20}'
line4 = f'{"CPU: " + str(cpu_load): <20}'
print(cpu_load)
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string('Up : ' + str(uptime_f))
lcd.crlf()
lcd.write_string(line4)
sleep(5)
#lcd.clear()
# Switch off backlight
#lcd.backlight_enabled = False
#sleep(3)
# Clear the LCD screen
#lcd.close(clear=True)

View File

@ -0,0 +1,43 @@
# Import LCD library
from RPLCD import i2c
import subprocess
import sys
import os
pid = os.getpid()
cmnd = "ps -ef|grep lcd_control|grep -v grep |grep -v {}|wc -l".format(pid)
status, output = subprocess.getstatusoutput(cmnd)
print(output)
if int(output) > 0:
print("Running already!")
#sys.exit()
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
line1 = f'{"####": <20}'
line2 = f'{"Restarting.....": <20}'
line3 = f'{"####": <20}'
line4 = f'{"####": <20}'
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string(line3)
lcd.crlf()
lcd.write_string(line4)

View File

@ -0,0 +1,35 @@
# Import LCD library
from RPLCD import i2c
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
lcd.clear()
line1 = f'{"####": <20}'
line2 = f'{"Starting....": <20}'
line3 = f'{"####": <20}'
line4 = f'{"####": <20}'
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string(line3)
lcd.crlf()
lcd.write_string(line4)
lcd.crlf()
lcd.clear()
lcd.close(clear=True)