Last active
October 11, 2020 20:00
-
-
Save Underknowledge/d8301a369f573175536fc3bfb45c9eb3 to your computer and use it in GitHub Desktop.
debian install home-assistant supervised on a fresh installed system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function info { echo -e "\033[1;34m[Info]\033[0m $*"; } | |
function warn { echo -e "\e[33m[warn] $*\e[39m"; } | |
function error { echo -e "\033[0;31m[Error]\033[0m $*"; exit 1; } | |
if [ "$EUID" -ne 0 ] | |
then error "Please run as root eg: 'su -', 'sudo su' or 'sudo bash'" | |
fi | |
if [ -f /home/*/.ssh/authorized_keys ] && [ -s /home/*/.ssh/authorized_keys ]; then | |
info "found authorized_keys, disableing password login" | |
sed -i -e 's/^[#\t ]*PubkeyAuthentication[\t ]*.*$/PubkeyAuthentication yes/' /etc/ssh/sshd_config | |
sed -i -e 's/^[#\t ]*PasswordAuthentication[\t ]*.*$/PasswordAuthentication no/' /etc/ssh/sshd_config | |
if [ -f /root/.ssh/authorized_keys ] && [ -s /root/.ssh/authorized_keys ]; then | |
info "allowing passwordless root login" | |
sed -i -e 's/^[#\t ]*PermitRootLogin[\t ]*.*$/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config | |
fi | |
fi | |
info "system upgrade" | |
apt update | |
apt upgrade -y | |
apt autoremove -y | |
info "installing pip" | |
apt-get -y update | |
apt-get install -y python3-pip | |
pip3 install --upgrade pip | |
apt-get install -y software-properties-common apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager gnupg | |
if [ ! -f /usr/bin/docker ] ; then | |
info "installing docker" | |
apt-get remove docker docker-engine docker.io | |
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh | |
sh /tmp/get-docker.sh | |
apt-get -y update | |
apt-get install -y docker-ce | |
systemctl enable --now docker | |
else | |
info "docker is already installed" | |
fi | |
info "install docker-compose" | |
pip install docker-compose -U | |
info `docker-compose --version` | |
info "disable systemd services" | |
systemctl disable --now ModemManager.service pppd-dns.service debug-shell.service | |
systemctl mask accounts-daemon.service | |
if [ ! -f /usr/bin/ha ] ; then | |
info "install home-assistant supervised" | |
curl -fsSL "https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh" -o /tmp/supervised-installer.sh | |
bash /tmp/supervised-installer.sh | |
else | |
info "home-assistant supervised is already installed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment