Advertisement
NittyGritty

Untitled

Mar 30th, 2023
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.09 KB | None | 0 0
  1. # OrangePi 3 LTS
  2. login: root
  3. Password: Bot7Nang
  4.  
  5. Login: pi
  6. Password: Garda3See
  7.  
  8. # in case no pi User
  9. adduser pi
  10. usermod -aG sudo pi
  11. visudo
  12. # Nessecary for /dev/ttyACM0 in zigbee2mqtt setup
  13. sudo usermod -a -G dialout pi
  14.  
  15. stty rows 43 columns 132
  16.  
  17. sudo orangepi-config
  18. # configure Network (LAN) / static IP
  19. # Personal
  20. Timezone Europe / Berlin
  21.  
  22. # Hostname
  23. FH01
  24.  
  25. # System
  26. Boot Environment > Verbosity 15
  27. Avahi -> Announce System in Network
  28.  
  29. # get last updates
  30. sudo apt update && sudo apt dist-upgrade -y
  31.  
  32. # Scargill Script
  33. wget https://bitbucket.org/api/2.0/snippets/scargill/kAR5qG/master/files/script.sh
  34.  
  35. bash ./script.sh
  36.  
  37. x [ ] quiet Quiet(er) install - untick for lots of info x
  38. x [*] prereq Install general pre-requisites x
  39. x [*] mosquitto Install Mosquitto x
  40. x [*] apache Install Apache/PHP/SQLITE + PHPLITEADMIN x
  41. x [ ] nginx Install Nginx/PHP/SQLITE + PHPLITEADMIN x
  42. x [*] nodenew Install NodeJS and NodeRed (NEW) x
  43. x [ ] nodejs Install NodeJS x
  44. x [ ] nodered Install Node-Red x
  45. x [*] webmin Install Webmin x
  46. x [ ] java Update Java x
  47. x [ ] hwsupport Enable support for Serial, I2C, GPIO, etc x
  48. x [ ] phone Install on Android Smartphone - see blog x
  49. x [ ] odroid Install ODROID C2-specific GPIO x
  50. x [ ] generich3 Install GENERIC H3 GPIO (not Raspberry Pi) x
  51. x [*] phpsysinfo Install PHPSYSYINFO x
  52. x [*] modpass Mod USER and ADMIN passwords (password123) x
  53. x [*] addindex Add an index page and some CSS x
  54. x [ ] passwords Update ROOT and PI user passwords x
  55. x [ ] rpiclone Install RPI-Clone x
  56. x [ ] log2ram Install Log2RAM default 40Meg x
  57. x [*] grafana Install Grafana and InfluxDB
  58.  
  59. # Passwords for NodeRed / NodeRed UI
  60. Login: user
  61. Password: User8Password
  62.  
  63. Login: admin
  64. Password: Admin8Password
  65.  
  66. # Grafana Login
  67. Login: admin
  68. Password: Grafana8Password
  69.  
  70. # added new user to Mosquitto
  71. cd /etc/mosquitto
  72. sudo mosquitto_passwd -b passwords moskito Mosquitto8Password
  73.  
  74. # Test MQTT Broker
  75. mosquitto_sub -u moskito -P Mosquitto8Password -v -t '#'&
  76. mosquitto_pub -u moskito -P Mosquitto8Password -t /home/test -m Hallo
  77.  
  78. # Output
  79. /home/test Hallo
  80.  
  81. # Add addtl. Nodes
  82. cd ~
  83. cd .node-red
  84. npm install node-red-contrib-fake-wemo &
  85. npm install node-red-contrib-sunpos &
  86. npm install node-red-contrib-fritz &
  87. npm install node-red-contrib-light-scheduler &
  88. npm install node-red-contrib-schedex &
  89. npm install node-red-node-twitter
  90.  
  91. # Install Zigbee2mqtt
  92.  
  93. https://www.zigbee2mqtt.io/getting_started/running_zigbee2mqtt.html
  94.  
  95. ls -l /dev/ttyACM0
  96. ls -l /dev/serial/by-id
  97. # -> lrwxrwxrwx 1 root root 13 May 4 16:41 usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE8B284-if00 -> ../../ttyACM0
  98.  
  99. cd ~
  100. tee zigbee2mqtt-install
  101.  
  102. --------------
  103. # Install Node.js and required dependencies
  104. # In Debian/Raspbian bullseye and up (11 and up), NodeJS v12.X is packaged, this is the safest method of installing NodeJS (from official repositories) for Zigbee2MQTT. Older i386 hardware can work with [unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org/download/release/v12.16.3/ e.g. Version 12.16.3 should work.
  105. # Check https://github.com/nodesource/distributions/blob/master/README.md if you want to install a specific version from NodeJS repositories instead.
  106. sudo apt-get install -y nodejs npm git make g++ gcc
  107.  
  108. # Verify that the correct nodejs and npm (automatically installed with nodejs)
  109. # version has been installed
  110. node --version # Should output v10.X, v12.X, v14.X, v15.X or V16.X
  111. npm --version # Should output 6.X or 7.X
  112.  
  113. # Clone Zigbee2MQTT repository
  114. git clone https://github.com/Koenkk/zigbee2mqtt.git
  115. sudo mv zigbee2mqtt /opt/zigbee2mqtt
  116.  
  117. # Install dependencies (as user "pi")
  118. cd /opt/zigbee2mqtt
  119. npm ci
  120. -------------------------------
  121.  
  122. bash ./zigbee2mqtt-install
  123.  
  124.  
  125. /opt/zigbee2mqtt/data/configuration.yaml
  126.  
  127. -----------------
  128. homeassistant: false
  129. permit_join: true
  130. frontend: true
  131. mqtt:
  132. base_topic: /home/zigbee
  133. server: mqtt://192.168.123.16
  134. user: moskito
  135. password: xxxxxxxxxq
  136. serial:
  137. port: null
  138. adapter: zstack
  139. baudrate: 115200
  140. rtscts: false
  141. disable_led: false
  142. advanced:
  143. ikea_ota_use_test_url: true
  144. log_level: info
  145. -----------------
  146.  
  147. # Starting Zigbee2MQTT
  148. cd /opt/zigbee2mqtt
  149. npm start
  150.  
  151. # further command see documentation at above URL
  152.  
  153. ----------------
  154. # Update zigbee2mqtt
  155. run file /opt/zigbee2mqtt/update.sh
  156.  
  157. ---------------
  158. # Setup InfluxDB
  159. https://www.sensorsiot.org/node-red-infuxdb-grafana-installation/
  160.  
  161. influx
  162. create database FH01
  163. use FH01
  164. create user "pi" with password 'Influx8Password' with all privileges
  165. show field keys
  166. select * from Werte where Room = 'Outside'
  167.  
  168. # some more DB queries (change according your structure)
  169.  
  170. SELECT * FROM Werte WHERE Room = 'Blitzwolf-Plug-01' and time > now() - 1h limit 1000;
  171. SELECT Count, Total, Time FROM Werte WHERE Room = 'Gas' and time > now() - 1h limit 1000;
  172.  
  173.  
  174. # To convert influxdb timestamp to normal timestamp you can type on console:
  175.  
  176. influx -precision rfc3339
  177.  
  178. ------------------------------------------------------------------------------
  179. # just in case there is a problem with InfluxDB
  180. # Repair influxdb
  181. https://docs.influxdata.com/influxdb/v1.8/administration/rebuild-tsi-index/
  182.  
  183. influx_inspect buildtsi -datadir ./data -waldir ./wal
  184. ls -al
  185. chown -R influxdb *
  186. chgrp -R influxdb *
  187. service influxdb start
  188.  
  189. # Backup InfluxDB
  190. -----------------
  191.  
  192. https://docs.influxdata.com/influxdb/v1.8/administration/backup_and_restore/
  193.  
  194. influxd backup -portable -database FH01 -host localhost:8088 ~/mysnapshot/FH01
  195.  
  196. # for remote backup, change /etc/influxdb/influxdb.conf
  197.  
  198. # activate RPC port !
  199. #bind-address = "127.0.0.1:8088"
  200. bind-address = ":8088"
  201.  
  202. # Backup from local Windows (D:\Onedrive ... is just an example)
  203. # IP address has to be changed, also local path on Windows computer
  204. scp root@192.168.123.16:/home/pi/mysnapshot/FH01/* D:\OneDrive\OrangePi\Influx-Backup\FH01
  205.  
  206. # Configureed Datasource in Grafana
  207. URL: http://localhost:8086
  208. Database: FH01
  209. User: pi
  210. Password: Influx8Password
  211.  
  212. --------------------------------------------------------
  213. # SSL Config for Apache2 Server
  214.  
  215. https://www.tecchannel.de/a/owncloud-9-unter-ubuntu-server-16-04-lts-installieren,3277807,2
  216.  
  217. sudo a2enmod ssl
  218. sudo mkdir /etc/apache2/ssl
  219. sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
  220.  
  221. Nun editieren Sie die Datei /etc/apache2/sites-available/default-ssl.conf. Dort finden Sie eine Zeile, die mit SSLEngine on beginnt. Fügen Sie darunter die beiden eben angelegten Zertifikate ein:
  222.  
  223. sudo vi /etc/apache2/sites-available/default-ssl.conf
  224. SSLCertificateFile /etc/apache2/ssl/apache.crt
  225. SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  226.  
  227. sudo a2ensite default-ssl.conf
  228.  
  229. Für den weiteren Verlauf dieses Artikels ändern Sie außerdem die Zeile
  230. DocumentRoot /var/www/html
  231.  
  232. sudo a2enmod headers
  233.  
  234. Editieren Sie die Datei /etc/apache2/sites-available/default-ssl.conf abermals und fügen zum Beispiel unter der Zeile mit ServerAdmin diese Sektion ein:
  235.  
  236. <IfModule mod_headers.c>Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"</IfModule>
  237.  
  238. sudo service apache2 restart
  239. -----------------------------
  240. # Password and https for NodeRed
  241.  
  242. # settings.js
  243.  
  244. cd ~/.node-red
  245. vi settings.js
  246.  
  247. adminAuth: {
  248. type: "credentials",
  249. users: [{
  250. username: "admin",
  251. password: "$2a$08$EVg5KlhlBKwZEJIMFL260uy2z/48Fu5HRsiWUPb4BkT7kkAZhMKbm",
  252. permissions: "*" }]
  253. },
  254. httpNodeAuth: {
  255. user:"user",
  256. pass:"$2a$08$qstd3YKjwXYMii3nOKqKQe7OkZGfjOx5hlCygvlz2b52j.ZVftre."
  257. },
  258. editorTheme: { projects: { enabled: false }
  259. },
  260.  
  261. // By default, credentials are encrypted in storage using a generated key. To
  262. // specify your own secret, set the following property.
  263. // If you want to disable encryption of credentials, set this property to false.
  264. // Note: once you set this property, do not change it - doing so will prevent
  265. // node-red from being able to decrypt your existing credentials and they will be
  266. // lost.
  267. //credentialSecret: "a-secret-key",
  268.  
  269. https: {
  270. key: fs.readFileSync('/home/pi/.node-red/privkey.pem'),
  271. cert: fs.readFileSync('/home/pi/.node-red/cert.pem')
  272. },
  273. requireHttps: true
  274. }
  275. ------------------------------------
  276. # Webmin SSL
  277.  
  278. https://www.webmin.com/ssl.html
  279.  
  280. If Webmin is already installed, turn on SSL
  281. In the Webmin Configuration module (under the Webmin category) an icon for SSL Encryption should appear. Click on it, and change the SSL option from Disabled to Enabled.
  282.  
  283. --------------------
  284. # https for Grafana
  285.  
  286. https://www.turbogeek.co.uk/grafana-how-to-configure-ssl-https-in-grafana/
  287.  
  288. sudo openssl genrsa -out grafana.key 2048
  289. sudo openssl req -new -key grafana.key -out grafana.csr
  290.  
  291. Country Name (2 letter code) [AU]:DE
  292. State or Province Name (full name) [Some-State]:Saxonia
  293. Locality Name (eg, city) []:Leipzig
  294. Organization Name (eg, company) [Internet Widgits Pty Ltd]:Home Ltd.
  295. Organizational Unit Name (eg, section) []:Home
  296. Common Name (e.g. server FQDN or YOUR name) []:FH01
  297. Email Address []:xxxxxxxxx@gmail.com
  298.  
  299. Please enter the following 'extra' attributes
  300. to be sent with your certificate request
  301. A challenge password []:Challenge8Password
  302. An optional company name []:Home
  303.  
  304. sudo openssl x509 -req -days 365 -in grafana.csr -signkey grafana.key -out grafana.crt
  305. -> Signature ok
  306. subject=C = DE, ST = Saxonia, L = Leipzig, O = Home Ltd., OU = Home, CN = FH01, emailAddress = xxxxxxxxx@gmail.com
  307. Getting Private key
  308.  
  309. sudo chown grafana:grafana grafana.crt
  310. sudo chown grafana:grafana grafana.key
  311. sudo chmod 400 grafana.key grafana.crt
  312.  
  313. sudo vi /etc/grafana/grafana.ini
  314.  
  315. cert_key = /etc/grafana/grafana.key
  316. cert_file = /etc/grafana/grafana.crt
  317.  
  318. sudo service grafana-server restart
  319. sudo service grafana-server status
  320. -----------------------------------------------------
  321.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement