Compare commits

...

6 commits

12 changed files with 528 additions and 0 deletions

2
10-local_i2c_group.rules Normal file
View file

@ -0,0 +1,2 @@
# Make /dev/i2c-[0-9]* accessible to users from group "sasha" without sudo
KERNEL=="i2c-[0-9]*", GROUP="sasha"

98
Zhu Yuan.md Normal file
View file

@ -0,0 +1,98 @@
# Zhu Yuan SETUP
## 1. OSInstall
Debian
Mount points - Data1
User setup - sasha (with sudo)
Software selection - Basic utilities + SSH server
## 2. Access
- SSH is already enabled, now install NetworkManager and remove all interfaces except `lo` from `/etc/network/interfaces` and reboot.
- [Disable password login!](https://www.cyberciti.biz/faq/how-to-disable-ssh-password-login-on-linux/)
Network
Method - Manual
LAN IP - 192.168.10.42/24
Gateway - 192.168.10.254
DNS - 192.168.10.254
## 3. Wireguard
- Install `wireguard-tools` with apt and run
```
wget https://git.io/wireguard -O wireguard-install.sh && sudo bash wireguard-install.sh
```
## 4. Utilities
install packages: htop smartmontools lm-sensors unzip wireguard-tools
## 5. Zram
```
echo "zram" > /etc/modules-load.d/zram.conf
echo "options zram num_devices=1" > /etc/modprobe.d/zram.conf
echo 'KERNEL=="zram0", ATTR{disksize}="4G",TAG+="systemd"' > /etc/udev/rules.d/99-zram.rules
```
Create `/etc/systemd/system/zram.service` containing this:
```
[Unit]
Description=Swap with zram
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/sbin/mkswap /dev/zram0
ExecStart=/sbin/swapon /dev/zram0
ExecStop=/sbin/swapoff /dev/zram0
[Install]
WantedBy=multi-user.target
```
Let Zram start on next boot:
sudo systemctl enable zram
And reboot the machine.
## 6. BOINC
install via apt
```
sudo apt install boinc-client
sudo systemctl enable --now boinc-client
```
## 7. CernVM-FS
install from CERN repos
```
wget https://ecsft.cern.ch/dist/cvmfs/cvmfs-release/cvmfs-release-latest_all.deb
sudo dpkg -i cvmfs-release-latest_all.deb
rm -f cvmfs-release-latest_all.deb
sudo apt-get update
sudo apt-get install cvmfs
sudo cvmfs_config setup
```
Put these in `/etc/cvmfs/default.local`, since we don't have a proxy
```
CVMFS_REPOSITORIES=atlas.cern.ch,atlas-condb.cern.ch,grid.cern.ch
CVMFS_CLIENT_PROFILE=single
```
Test with
```
cvmfs_config probe
```

13
boinc/app_config_template.xml Executable file
View file

@ -0,0 +1,13 @@
<app_config>
<app>
<name>myapp</name>
<gpu_versions>
<cpu_usage>1.0</cpu_usage>
<gpu_usage>0.5</gpu_usage>
</gpu_versions>
</app>
</app_config>
<app_config>
<project_max_concurrent>1</project_max_concurrent>
</app_config>

View file

@ -0,0 +1,42 @@
[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
Documentation=man:boinc(1)
After=network-online.target
[Service]
Environment=GPU_SINGLE_ALLOC_PERCENT=100
Environment=GPU_MAX_HEAP_SIZE=100
Environment=GPU_FORCE_64BIT_PTR=1
Environment=GPU_USE_SYNC_OBJECTS=1
Environment=GPU_MAX_ALLOC_PERCENT=100
Type=simple
ProtectHome=true
PrivateTmp=true
#ProtectSystem=strict
#ProtectControlGroups=true
ReadWritePaths=-/var/lib/boinc -/etc/boinc-client
Nice=10
User=boinc
WorkingDirectory=/var/lib/boinc
ExecStart=/usr/bin/boinc
ExecStop=/usr/bin/boinccmd --quit
ExecReload=/usr/bin/boinccmd --read_cc_config
ExecStopPost=/bin/rm -f lockfile
IOSchedulingClass=idle
# The following options prevent setuid root as they imply NoNewPrivileges=true
# Since Atlas requires setuid root, they break Atlas
# In order to improve security, if you're not using Atlas,
# Add these options to the [Service] section of an override file using
# sudo systemctl edit boinc-client.service
#NoNewPrivileges=true
#ProtectKernelModules=true
#ProtectKernelTunables=true
#RestrictRealtime=true
#RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
#RestrictNamespaces=true
#PrivateUsers=true
#CapabilityBoundingSet=
#MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,11 @@
<cc_config>
<log_flags>
<task>1</task>
<file_xfer>1</file_xfer>
<sched_ops>1</sched_ops>
</log_flags>
<options>
<allow_remote_gui_rpc>1</allow_remote_gui_rpc>
</options>
</cc_config>

10
boinc/screenlock.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# If screen is locked (GNOME Screensaver true), enable GPU computing. Otherwise disable GPU computing.
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" |
while read x; do
case "$x" in
*"boolean true"*) boinccmd --set_gpu_mode always && echo "GPU Computing Enabled";;
*"boolean false"*) boinccmd --set_gpu_mode never && echo "GPU Computing Disabled";;
esac
done

View file

@ -0,0 +1,296 @@
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: serial
serial_port: /dev/ttyUSB_CH340
baudrate: 9600
template:
sensor:
- name: Temperature
unit_of_measurement: "°C"
state: "{{ states('sensor.serial_sensor').split()[2] | float(default=0) }}"
unique_id: temperature_sensor
- name: Humidity
unit_of_measurement: "%"
state: "{{ states('sensor.serial_sensor').split()[1] | float(default=0) }}"
unique_id: humidity_sensor
modbus:
- name: "SDM230 Smart Meter"
type: serial
baudrate: 9600
bytesize: 8
method: rtu
parity: N
port: /dev/ttyUSB_FT232
stopbits: 1
sensors:
- name: Voltage
unit_of_measurement: Volts
slave: 2
address: 0
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_Voltage"
- name: Current
unit_of_measurement: Amps
slave: 2
address: 6
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_Current"
- name: Active_Power
unit_of_measurement: Watts
slave: 2
address: 12
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ActivePower"
- name: Apparent_Power
unit_of_measurement: Watts
slave: 2
address: 18
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ApparentPower"
- name: Reactive_Power
unit_of_measurement: Watts
slave: 2
address: 24
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ReactivePower"
- name: Power_Factor
slave: 2
address: 30
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_PowerFactor"
- name: Frequency
unit_of_measurement: Hz
slave: 2
address: 70
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_Frequency"
- name: Import_Active_Energy
unit_of_measurement: kWh
slave: 2
address: 72
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ImportActiveEnergy"
- name: Export_Active_Energy
unit_of_measurement: kWh
slave: 2
address: 74
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ExportActiveEnergy"
- name: Import_Reactive_Energy
unit_of_measurement: kVARh
slave: 2
address: 76
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ImportReactiveEnergy"
- name: Export_Reactive_Energy
unit_of_measurement: kVARh
slave: 2
address: 78
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_ExportReactiveEnergy"
- name: Total_Active_Energy
unit_of_measurement: kWh
slave: 2
address: 342
input_type: input
data_type: float32
precision: 2
state_class: total_increasing
unique_id: "SDM230_TotalActiveEnergy"
- name: Total_Reactive_Energy
unit_of_measurement: kVARh
slave: 2
address: 344
input_type: input
data_type: float32
precision: 2
unique_id: "SDM230_TotalReactiveEnergy"
http:
# For extra security set this to only accept connections on localhost if NGINX is on the same machine
# Uncommenting this will mean that you can only reach Home Assistant using the proxy, not directly via IP from other clients.
# server_host: 127.0.0.1
use_x_forwarded_for: true
# You must set the trusted proxy IP address so that Home Assistant will properly accept connections
# Set this to your NGINX machine IP, or localhost if hosted on the same machine.
trusted_proxies: 192.168.10.41
# Modpoll for CJ meter
#./modpoll/x86_64-linux-gnu/modpoll -h
#modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
#Copyright (c) 2002-2021 proconX Pty Ltd
#Visit https://www.modbusdriver.com for Modbus libraries and tools.
#
#Usage: modpoll [OPTIONS] SERIALPORT|HOST [WRITEVALUES...]
#Arguments:
#SERIALPORT Serial port when using Modbus ASCII or Modbus RTU protocol
# COM1, COM2 ... on Windows
# /dev/ttyS0, /dev/ttyS1 ... on Linux
#HOST Host name or dotted IP address when using MDBUS/TCP protocol
#WRITEVALUES List of values to be written. If none specified (default) modpoll reads data.
#General options:
#-m ascii Modbus ASCII protocol
#-m rtu Modbus RTU protocol (default if SERIALPORT contains a /)
#-m tcp MODBUS/TCP protocol (default otherwise)
#-m udp MODBUS UDP
#-m enc Encapsulated Modbus RTU over TCP
#-a # Slave address (1-247 for serial, 0-255 for TCP, 1 is default)
#-r # Start reference (1-65536, 100 is default)
#-c # Number of values to read (1-125, 1 is default), optional for writing (use -c 1 to force FC5 or FC6)
#-t 0 Discrete output (coil) data type
#-t 1 Discrete input data type
#-t 3 16-bit input register data type
#-t 3:hex 16-bit input register data type with hex display
#-t 3:int 32-bit integer data type in input register table
#-t 3:mod 32-bit module 10000 data type in input register table
#-t 3:float 32-bit float data type in input register table
#-t 4 16-bit output (holding) register data type (default)
#-t 4:hex 16-bit output (holding) register data type with hex display
#-t 4:int 32-bit integer data type in output (holding) register table
#-t 4:mod 32-bit module 10000 type in output (holding) register table
#-t 4:float 32-bit float data type in output (holding) register table
#-i Slave operates on big-endian 32-bit integers
#-f Slave operates on big-endian 32-bit floats
#-e Use Daniel/Enron single register 32-bit mode (implies -i and -f)
#-0 First reference is 0 (PDU addressing) instead 1
#-1 Poll only once only, otherwise every poll rate interval
#-l # Poll rate in ms, (1000 is default)
#-o # Time-out in seconds (0.01 - 10.0, 1.0 s is default)
#Options for MODBUS/TCP, UDP and RTU over TCP:
#-p # IP protocol port number (502 is default)
#Options for Modbus ASCII and Modbus RTU:
#-b # Baudrate (e.g. 9600, 19200, ...) (19200 is default)
#-d # Databits (7 or 8 for ASCII protocol, 8 for RTU)
#-s # Stopbits (1 or 2, 1 is default)
#-p none No parity
#-p even Even parity (default)
#-p odd Odd parity
#-4 # RS-485 mode, RTS on while transmitting and another # ms after
# ./modpoll -c 80 -b 9600 -a 1 -1 -p none -t 3 /dev/ttyUSB0
# modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
# Copyright (c) 2002-2021 proconX Pty Ltd
# Visit https://www.modbusdriver.com for Modbus libraries and tools.
#
#Protocol configuration: Modbus RTU, FC4
#Slave configuration...: address = 1, start reference = 1, count = 80
#Communication.........: /dev/ttyUSB0, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
#Data type.............: 16-bit register, input register table
#-- Polling slave...
#[1]: 8888
#[2]: 256
#[3]: 0
#[4]: 1
#[5]: 16
#[6]: -30846
#[7]: 5000
#[8]: 3000
#[9]: -31868
#[10]: 3000
#[11]: 6000
#[12]: 257
#[13]: 257
#[14]: 257
#[15]: 0
#[16]: 0
#[17]: 0
#[18]: 0
#[19]: 0
#[20]: 0
#[21]: 500
#[22]: 30
#[23]: -30844
#[24]: 6000
#[25]: 6000
#[26]: 257
#[27]: 0
#[28]: 0
#[29]: 0
#[30]: 0
#[31]: 0
#[32]: 0
#[33]: 0
#[34]: 0
#[35]: 0
#[36]: 769
#[37]: 1135
#[38]: 2288
#[39]: 0
#[40]: 0
#[41]: 2288
#[42]: 0
#[43]: 2288
#[44]: 5216
#[45]: 0
#[46]: 0
#[47]: 865
#[48]: 0
#[49]: 0
#[50]: 865
#[51]: 587
#[52]: 0
#[53]: 0
#[54]: 587
#[55]: 827
#[56]: 999
#[57]: 999
#[58]: 827
#[59]: 1046
#[60]: 0
#[61]: 0
#[62]: 1046
#[63]: 4995
#[64]: 14
#[65]: -25104
#[66]: 0
#[67]: 0
#[68]: 9
#[69]: -13187
#[70]: 0
#[71]: 0
#[72]: 19305
#[73]: -4744
#[74]: 0
#[75]: 0
#[76]: 19228
#[77]: -11734
#[78]: 0
#[79]: 0
#[80]: 0

View file

@ -0,0 +1,23 @@
#include "DHT.h"
DHT dht;
void setup()
{
Serial.begin(9600);
dht.setup(3); // data pin 3
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();
Serial.print(dht.getStatusString());
Serial.print("\t");
Serial.print(humidity, 1);
Serial.print("\t");
Serial.print(temperature, 1);
Serial.print("\n");
}
void loop()
{
}

9
reconnect-vpn.service Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=Reconnect VPN
[Service]
Type=oneshot
ExecStart=nmcli con up vpn-name
[Install]
WantedBy=default.target

8
reconnect-vpn.timer Normal file
View file

@ -0,0 +1,8 @@
[Unit]
Description=Reconnect VPN every 15 minutes
[Timer]
OnCalendar=*:0/15
[Install]
WantedBy=default.target

4
vncstart.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
# Start an x11vnc server on display :0 at port 5183, with password auth and continue running after client disconnects
x11vnc -display :0 -forever -loop -noxdamage -repeat -rfbauth ~/.vnc/passwd -rfbport 5183 -shared

12
x11vnc.service Executable file
View file

@ -0,0 +1,12 @@
[Unit]
Description=run x11vnc as a service
[Service]
Type=simple
User=sasha
WorkingDirectory=/home/sasha
ExecStart=sh /home/sasha/vncstart.sh
ExecStop=killall x11vnc
[Install]
WantedBy=graphical.target