fredag 7 februari 2020

Docker Swarm and NFS


sudo apt-get update && sudo apt-get -y dist-upgrade


sudo apt install nfs-kernel-server

 sudo chown -R pi:pi /usbdisc/docker-volumes/tmp/

sudo nano /etc/exports

/usbdisc/docker-volumes/home-assistant-config *(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)

sudo exportfs -ra

  node-red:
    imagenodered/node-red:latest
    environment:
      - TZ=Europe/Stockholm
    ports:
      - "1880:1880"
    networks:
      - default
    volumes:
#      - ../docker-volumes/node-red-config/:/data/
      - node-red-data:/data/
    restartalways

volumes:
  node-red-data:
    driverlocal
    driver_opts:
      typenfs
      onfsvers=4,addr=192.168.1.102,rw
      device":/usbdisc/docker-volumes/node-red-data"

tisdag 28 januari 2020

Telldus-Core on Raspbian Buster

Tested to work 2020-01-28.




#
# Start by upgrading and configuring raspbian
#

sudo apt-get update && sudo apt-get -y upgrade

sudo apt-get -y dist-upgrade


sudo raspi-config

#Do localization, hostname, password etc.


#

# Install telldus-core# Source: https://www.styrahem.se/Faq/2

sudo sh -c 'echo "deb-src http://download.telldus.com/debian/ stable main" > /etc/apt/sources.list.d/telldus.list'


wget -q http://download.telldus.com/debian/telldus-public.key -O- | sudo apt-key add -

sudo apt-get update

sudo apt-get build-dep telldus-core

sudo apt-get -y install cmake libconfuse-dev libftdi-dev help2man

mkdir -p ~/tellstick-build

cd ~/tellstick-build

tdtool -l


# Then install Node-RED

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

sudo apt-get -y install git

sudo systemctl enable nodered.service

onsdag 12 juni 2019

MySQL on USB disk with Raspbian

#Install MySQL
sudo apt-get install -y mysql-server

#Stop daemon
sudo /etc/init.d/mysql stop

#Copy data
sudo cp -Rp /var/lib/mysql /usbdisc

#Manualy edit config file to change data dir
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf 

datadir = /usbdisc/mysql
#bind-address            = 127.0.0.1


#Start MySQL
sudo /etc/init.d/mysql start



#Create root user
sudo mysql -u root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
exit



#*************************************************** 
#**********            Misc               **********
#***************************************************


#Config directory
/etc/mysql


#Uninstall
sudo apt-get remove --purge mysql-server mysql-client mysql-common -y

sudo apt-get autoremove -y

sudo apt-get autoclean

#Remove the MySQL folder:
rm -rf /etc/mysql

#Delete all MySQL files on your server. This is dangerous!!!
sudo find / -iname 'mysql*' -exec rm -rf {} \;


pi02 Installation

#Update system
sudo apt-get update && sudo apt-get -y dist-upgrade

#List all available disks
sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

#Create mount point
sudo mkdir /usbdisc

#Configure disc mounting
sudo nano /etc/fstab

/dev/sda1 /usbdisc ext4 defaults,errors=remount-ro 0 1

#Mount disc
sudo mount -a


#
# Install MySQL
#
sudo apt-get install -y mysql-server
sudo apt-get install -y mariadb-server

#Stop daemon
sudo /etc/init.d/mysql stop
sudo systemctl stop mysqld

#Copy data
sudo cp -Rp /var/lib/mysql /usbdisc

#Manualy edit config file to change data dir
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
datadir = /usbdisc/mysql
#bind-address = 127.0.0.1

#Start MySQL
sudo /etc/init.d/mysql start
sudo systemctl start mysqld

#Create root user
sudo mysql -u root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
exit;

!!! Just saving data dir does not work, need to create backup scripts!


#
# Install InfluxDB
# Source: 
https://pimylifeup.com/raspberry-pi-influxdb/

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -

echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

sudo apt-get update

sudo apt-get install influxdb

#Manually edit config file
sudo nano /etc/influxdb/influxdb.conf

[meta]
dir = "/usbdisc/influxdb/meta"

[data]
dir = "/usbdisc/influxdb/data"

#Note! Did not change wal-dir

[http]
enabled = true


mkdir /usbdisc/influxdb

sudo chown influxdb:influxdb /usbdisc/influxdb/

sudo systemctl unmask influxdb
sudo systemctl enable influxdb

sudo systemctl start influxdb

#Takes long time to start! Syslog says Started, but keep waiting, more to come
tail /var/log/syslog -f

#Connecting also takes serious long time!
sudo influx
> CREATE USER grafana WITH PASSWORD '***' WITH ALL PRIVILEGES
> CREATE USER 'homeassistant' WITH PASSWORD '***' WITH ALL PRIVILEGES
> CREATE DATABASE homeassistant
> exit

#Manually edit config file again
sudo nano /etc/influxdb/influxdb.conf

[http]
auth-enabled = true
pprof-enabled = true
pprof-auth-enabled = true
ping-auth-enabled = true

sudo systemctl restart influxdb

torsdag 8 november 2018

433mhz Sensorer

Kanal Alias Protokoll Id
1 Tvättstuga temperaturehumidity 135
1 Ute temperature 136
2 Vind Norr temperaturehumidity 151
3 Vind Syd temperaturehumidity 167
4 Badrum Ovanvåning temperaturehumidity 183
(random) Kök temperature 5
(random) Entre temperature 110
(random) Bar temperature 225




tisdag 12 juni 2018

Raspberry Pi Media Center

#Update Raspbian
sudo apt-get update && sudo apt-get upgrade -y

#Install Samba
sudo apt-get install -y samba samba-common-bin

#List all discs
lsblk

#Unmount auto-mount
sudo umount /media/pi/Elements

#Install ntfs-3g, ntfs is readonly without it
sudo apt-get install ntfs-3g

#Create mount point
sudo mkdir /media/usbdisc

#Configure discs in fstab
nano /etc/fstab
/dev/sda1 /media/usbdisc ntfs defaults 0 0

#Reboot, "mount -a" seems to not work here?
#mount -a
sudo reboot

sudo nano /etc/samba/smb.conf

[usbdisc$]
comment = USB Disc
browseable = yes
path = /media/usbdisc
writeable = Yes
create mask = 0777
directory mask = 0777

[Media]
comment = Media
browseable = yes
path = /media/usbdisc/media
writeable = Yes
create mask = 0777
directory mask = 0777
#guest ok = no

## Kodi
sudo apt-get install kodi
##Transmission
sudo apt-get install -y transmission-daemon

sudo usermod -a -G pi debian-transmission

#Sources
#https://eltechs.com/raspberry-pi-nas-guide/
#https://www.raspberrypi.org/forums/viewtopic.php?t=192499
#https://www.addictivetips.com/media-streaming/kodi/install-transmission-raspberry-pi-torrent/


fredag 16 mars 2018

My Pi's

My Pi's


HostRevisionModelMemUsageHardware
pi010002B256MBRetired
pi02000eB512MBStorage, database500GB HDD
PI6pi03000eB512MBGreenhouse AutomationPumps and sensors
pi04000eB512MBHome Automation: Z-WaveRaZberry
PI30010B+512MBBroken NIC
PI3c031114B4GBHome Automation: Logic
PI1pi06a020823B1GBWeb/Proxy
pi07a020823B1GBUnifi Controller
PI7pi08a020d33B+1GB(ol-results) ToBe: Beer
pi099000c1Zero W512MBHome Automation: Bedroom BlindsBofu tubular motors
pi109000c1Zero W512MBHome Automation: Plejd/Shellies
pi119000c1Zero W512MBHome Automation: TellstickTellstick Duo
pi12c031114B4GBMedia center2TB HDD



cat /proc/cpuinfo
https://elinux.org/RPi_HardwareHistory#Which_Pi_have_I_got.3F


Regular upgrade:
sudo apt-get update && sudo apt-get -y dist-upgrade

Upgrade stretch to buster:

https://pimylifeup.com/upgrade-raspbian-stretch-to-raspbian-buster/


Upgrade Node-REDbash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
https://nodered.org/docs/getting-started/raspberrypi