Advertisement
JLindvig

Home Assistant - auto

Nov 4th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.16 KB | None | 0 0
  1. explorer "https://google.com"
  2.  
  3. putty -ssh pi@192.168.0.12 22 -pw Kar2ffel!
  4.  
  5. #!/bin/sh
  6.  
  7. ip="$(hostname -I | awk '{print $1}')"
  8. locale=da_DK.UTF-8
  9. tz=Europe/Copenhagen
  10.  
  11. read -p "Indtast dit hostname på systemet: " hostname
  12. read -p "Indtast dit nye kodeord: " password
  13. read -p "Indtast dit DuckDNS domæne: " domain
  14. read -p "Indtast dit Token: " token
  15. read -p "Indtast din email adresse: " email
  16.  
  17. # Opdatering
  18. sudo apt update -y
  19. sudo apt full-upgrade -y
  20. sudo apt autoremove -y
  21. sudo apt clean -y
  22. sudo apt autoclean -y
  23.  
  24. # Konfiguration
  25. sudo raspi-config nonint do_hostname %hostname
  26. sudo raspi-config nonint do_boot_behaviour B2
  27. sudo raspi-config nonint do_boot_wait 0
  28. sudo raspi-config nonint do_change_locale $locale
  29. sudo raspi-config nonint do_change_timezone $tz
  30. sudo raspi-config # ÆNDRES
  31.  
  32. # Ekstra pakker
  33. sudo apt-get install mc python-pip augeas-lenses libaugeas0 libffi-dev libssl-dev python-virtualenv python3-virtualenv virtualenv -y
  34.  
  35. # Docker, Docker-Compose + mapper
  36. cd
  37. curl -fsSL get.docker.com -o get-docker.sh
  38. sudo sh get-docker.sh
  39. sudo usermod -aG docker pi
  40. sudo pip install docker-compose~=1.23.2
  41. sudo mkdir /opt
  42. sudo chown pi:pi /opt
  43. cd /opt
  44. mkdir homeassistant organizr portainer duckdns
  45.  
  46. # Reboot
  47. sudo reboot # måske ikke nødvendigt
  48.  
  49. # Docker-Compose
  50. wget -O /opt/docker-compose.yaml http://my.ocloud.dk/index.php/s/67CwXciqmYzWZMD/download
  51. cd /opt # Hvis reboot ikke var nødvendig - så slettes
  52. docker-compose pull
  53.  
  54. # Home Assistant
  55. docker-compose up -d homeassistant
  56.  
  57. # Portainer
  58. docker-compose up -d portainer
  59.  
  60. # DuckDNS
  61. echo 'echo url="https://www.duckdns.org/update?domains='$domain'&token='$token'&ip=" | curl -k -o /opt/duckdns/duck.log -K -' > ./duckdns/duck1.sh
  62. chmod 700 ./duckdns/duck.sh
  63. crontab -l > file; echo "*/5 * * * * /opt/duckdns/duck.sh >/dev/null 2>&1" >> file; crontab file; rm file
  64.  
  65. # Cert-Bot
  66. cd /
  67. sudo wget https://dl.eff.org/certbot-auto
  68. sudo chmod 755 certbot-auto
  69. sudo rm /etc/pip.conf -f
  70. ./certbot-auto certonly --standalone --preferred-challenges http-01 --email $email -d $domain.duckdns.org
  71. ./certbot-auto certonly --standalone --preferred-challenges http-01 --email $email -d ha.$domain.duckdns.org
  72. ./certbot-auto certonly --standalone --preferred-challenges http-01 --email $email -d portainer.$domain.duckdns.org
  73.  
  74. # Organizr
  75. cd /opt
  76. docker-compose up -d organizr
  77. sed -i 's/# server_names_hash_bucket_size 64;/server_names_hash_bucket_size 64;/g' /opt/organizr/nginx/nginx.conf
  78. rm organizr/nginx/site-confs/default
  79.  
  80. wget -O organizr/nginx/site-confs/default https://my.ocloud.dk/index.php/s/JtrTDtmwkgf8eLA/download
  81. wget -O organizr/nginx/site-confs/homeassistant https://my.ocloud.dk/index.php/s/9MbJYc5Sd7EbLnf/download
  82. wget -O organizr/nginx/site-confs/portainer https://my.ocloud.dk/index.php/s/pbARKoQg8BRRFit/download
  83. wget -O organizr/nginx/site-confs/upstreams http://my.ocloud.dk/index.php/s/LSNZA8QWAHpnjSW/download
  84.  
  85. sed -i "s/DIT_DOMAIN/$domain;/g" organizr/nginx/site-confs/default
  86. sed -i "s/DIT_DOMAIN/$domain;/g" organizr/nginx/site-confs/homeassistant
  87. sed -i "s/DIT_DOMAIN/$domain;/g" organizr/nginx/site-confs/portainer
  88. sed -i "s/DIN_PI_IP/$ip/g" organizr/nginx/site-confs/upstreams
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement