Advertisement
NittyGritty

Untitled

Mar 30th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.81 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. # Home Assistant integration (MQTT discovery)
  129. homeassistant: false
  130.  
  131. # allow new devices to join
  132. permit_join: false
  133.  
  134. # MQTT settings
  135. mqtt:
  136. # MQTT base topic for zigbee2mqtt MQTT messages
  137. base_topic: /home/zigbee
  138. # MQTT server URL
  139. server: 'mqtt://localhost'
  140. # MQTT server authentication, uncomment if required:
  141. user: moskito
  142. password: Mosquitto8Password
  143.  
  144. # Serial settings
  145. serial:
  146. # Location of CC2531 USB sniffer
  147. port: /dev/ttyACM0
  148. -----------------
  149.  
  150. # Starting Zigbee2MQTT
  151. cd /opt/zigbee2mqtt
  152. npm start
  153.  
  154. # further command see documentation at above URL
  155.  
  156. ----------------
  157. # Update zigbee2mqtt
  158. https://domoticacloudhost.com/update-zigbee2mqtt/
  159.  
  160. cd /opt/zigbee2mqtt/
  161. git pull
  162.  
  163. rm -rf node_modules && npm install
  164.  
  165. ---------------
  166. ------------------------------------
  167. # Visualisierung Map
  168.  
  169. sudo apt-get install graphviz imagemagick
  170.  
  171. File ~/map
  172. ==================
  173. #!/bin/bash
  174. # additional dependencies: graphviz imagemagick
  175.  
  176. # put temporal files in ram filesystem
  177. file="/home/pi/zigbee/networkmap"
  178. fechahora=$(date '+%F-%H:%M')
  179. #~ echo $fechahora
  180.  
  181. mosquitto_sub -u moskito -P lokus123 -t /home/zigbee/bridge/networkmap/graphviz -C 1 >${file}.dot &
  182. mosquitto_pub -u moskito -P lokus123 -t /home/zigbee/bridge/networkmap -m graphviz
  183.  
  184. # wait until mosquitto_sub ends
  185. wait
  186.  
  187. # generate graphic with graphviz (change to short texts with sed)
  188. cat ${file}.dot| circo -Tsvg > ${file}${fechahora}.svg
  189. ===============
  190.  
  191. chmod +x map
  192.  
  193.  
  194. # Auf PC laufen lassen
  195. scp [email protected]:/home/pi/zigbee/* D:\OneDrive\OrangePi\Zigbee
  196.  
  197. ---------------
  198. # Setup InfluxDB
  199. https://www.sensorsiot.org/node-red-infuxdb-grafana-installation/
  200.  
  201. influx
  202. create database FH01
  203. use FH01
  204. create user "pi" with password 'Influx8Password' with all privileges
  205. show field keys
  206. select * from Werte where Room = 'Outside'
  207. ------------------------------------------------------------------------------
  208. # just in case there is a problem with InfluxDB
  209. # Repair influxdb
  210. https://docs.influxdata.com/influxdb/v1.8/administration/rebuild-tsi-index/
  211.  
  212. influx_inspect buildtsi -datadir ./data -waldir ./wal
  213. ls -al
  214. chown -R influxdb *
  215. chgrp -R influxdb *
  216. service influxdb start
  217.  
  218. # Backup InfluxDB
  219. -----------------
  220.  
  221. https://docs.influxdata.com/influxdb/v1.8/administration/backup_and_restore/
  222.  
  223. influxd backup -portable -database FH01 -host localhost:8088 ~/mysnapshot/FH01
  224.  
  225. # for remote backup, change /etc/influxdb/influxdb.conf
  226.  
  227. # activate RPC port !
  228. #bind-address = "127.0.0.1:8088"
  229. bind-address = ":8088"
  230.  
  231. # Backup from local Windows (D:\Onedrive ... is just an example)
  232. # IP address has to be changed, also local path on Windows computer
  233. scp [email protected]:/home/pi/mysnapshot/FH01/* D:\OneDrive\OrangePi\Influx-Backup\FH01
  234.  
  235. # Configureed Datasource in Grafana
  236. URL: http://localhost:8086
  237. Database: FH01
  238. User: pi
  239. Password: Influx8Password
  240.  
  241. --------------------------------------------------------
  242. # SSL Config for Apache2 Server
  243.  
  244. https://www.tecchannel.de/a/owncloud-9-unter-ubuntu-server-16-04-lts-installieren,3277807,2
  245.  
  246. sudo a2enmod ssl
  247. sudo mkdir /etc/apache2/ssl
  248. sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
  249.  
  250. 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:
  251.  
  252. sudo vi /etc/apache2/sites-available/default-ssl.conf
  253. SSLCertificateFile /etc/apache2/ssl/apache.crt
  254. SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  255.  
  256. sudo a2ensite default-ssl.conf
  257.  
  258. Für den weiteren Verlauf dieses Artikels ändern Sie außerdem die Zeile
  259. DocumentRoot /var/www/html
  260.  
  261. sudo a2enmod headers
  262.  
  263. 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:
  264.  
  265. <IfModule mod_headers.c>Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"</IfModule>
  266.  
  267. sudo service apache2 restart
  268. -----------------------------
  269. # Password and https for NodeRed
  270.  
  271. # settings.js
  272.  
  273. cd ~/.node-red
  274. vi settings.js
  275.  
  276. adminAuth: {
  277. type: "credentials",
  278. users: [{
  279. username: "admin",
  280. password: "$2a$08$EVg5KlhlBKwZEJIMFL260uy2z/48Fu5HRsiWUPb4BkT7kkAZhMKbm",
  281. permissions: "*" }]
  282. },
  283. httpNodeAuth: {
  284. user:"user",
  285. pass:"$2a$08$qstd3YKjwXYMii3nOKqKQe7OkZGfjOx5hlCygvlz2b52j.ZVftre."
  286. },
  287. editorTheme: { projects: { enabled: false }
  288. },
  289.  
  290. // By default, credentials are encrypted in storage using a generated key. To
  291. // specify your own secret, set the following property.
  292. // If you want to disable encryption of credentials, set this property to false.
  293. // Note: once you set this property, do not change it - doing so will prevent
  294. // node-red from being able to decrypt your existing credentials and they will be
  295. // lost.
  296. //credentialSecret: "a-secret-key",
  297.  
  298. https: {
  299. key: fs.readFileSync('/home/pi/.node-red/privkey.pem'),
  300. cert: fs.readFileSync('/home/pi/.node-red/cert.pem')
  301. },
  302. requireHttps: true
  303. }
  304. ------------------------------------
  305. # Webmin SSL
  306.  
  307. https://www.webmin.com/ssl.html
  308.  
  309. If Webmin is already installed, turn on SSL
  310. 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.
  311.  
  312. --------------------
  313. # https for Grafana
  314.  
  315. https://www.turbogeek.co.uk/grafana-how-to-configure-ssl-https-in-grafana/
  316.  
  317. sudo openssl genrsa -out grafana.key 2048
  318. sudo openssl req -new -key grafana.key -out grafana.csr
  319.  
  320. Country Name (2 letter code) [AU]:DE
  321. State or Province Name (full name) [Some-State]:Saxonia
  322. Locality Name (eg, city) []:Zwenkau
  323. Organization Name (eg, company) [Internet Widgits Pty Ltd]:Fraunholz Ltd.
  324. Organizational Unit Name (eg, section) []:Home
  325. Common Name (e.g. server FQDN or YOUR name) []:FH01
  326. Email Address []:[email protected]
  327.  
  328. Please enter the following 'extra' attributes
  329. to be sent with your certificate request
  330. A challenge password []:Challenge8Password
  331. An optional company name []:Fraunholz
  332.  
  333. sudo openssl x509 -req -days 365 -in grafana.csr -signkey grafana.key -out grafana.crt
  334. -> Signature ok
  335. subject=C = DE, ST = Saxonia, L = Zwenkau, O = Fraunholz Ltd., OU = Home, CN = FH01, emailAddress = [email protected]
  336. Getting Private key
  337.  
  338. sudo chown grafana:grafana grafana.crt
  339. sudo chown grafana:grafana grafana.key
  340. sudo chmod 400 grafana.key grafana.crt
  341.  
  342. sudo vi /etc/grafana/grafana.ini
  343.  
  344. cert_key = /etc/grafana/grafana.key
  345. cert_file = /etc/grafana/grafana.crt
  346.  
  347. sudo service grafana-server restart
  348. sudo service grafana-server status
  349. -----------------------------------------------------
  350.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement