Last active
December 7, 2022 05:27
-
-
Save katabame/142fcc685c43b0f0884de015b3211af9 to your computer and use it in GitHub Desktop.
This file contains 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
version: '3' | |
services: | |
homeassistant: | |
container_name: homeassistant | |
image: "ghcr.io/home-assistant/home-assistant:stable" | |
volumes: | |
- /var/lib/homeassistant/config:/config | |
- /etc/localtime:/etc/localtime:ro | |
restart: unless-stopped | |
privileged: true | |
network_mode: host |
This file contains 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
# Plug WiFi dongle and type followings in the terminal, even device is not connected to wired network, will WiFi network available. | |
# But after NetworkManager (nmcli) is installed, `nmcli d s` will shows wlan0 is `unmanaged` or `unavailable` | |
# Because we added wlan0 connection via wpa_supplicant, which is installed by default. | |
# And wpa_supplicant and nmcli will conflicts if we added connection via wpa_supplicant manually. | |
# | |
# Maybe `systemctl disable wpa_supplicant && systemctl stop wpa_supplicant` | |
# `systemctl enable NetworkManager && systemctl start NetworkManager` | |
# `reboot` partically solves this problem, but seems not solves everything. | |
# So I gave up for now. | |
# The setup is one-time only, also needs monitor and keyboard. | |
# This means we have to sit at a desktop PC, why don't we have any wired network cable? lmao;; | |
echo 'auto wlan0 | |
iface wlan0 inet dhcp | |
wpa-ssid Chamomile-5GHz | |
wpa-psk "energy in adversity" | |
' > /etc/network/interfaces.d/wlan0 |
This file contains 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
set -ex | |
: 'Define variables' | |
DEBIAN_FRONTEND=noninteractive | |
OSAGENT_DEB=$(mktemp) | |
OSAGENT_VER=$(curl -fsSL https://api.github.com/repos/home-assistant/os-agent/releases/latest | jq -r .tag_name) | |
SUPERVISED_DEB=$(mktemp) | |
: 'Upgrade packages to latest' | |
apt-get update > /dev/null | |
apt-get upgrade -y --no-install-recommends > /dev/null | |
: 'Install Home-Assistant dependencies' | |
apt-get install -y --no-install-recommends apparmor jq wget curl udisks2 libglib2.0-bin network-manager dbus systemd-journal-remote > /dev/null | |
: 'Install Docker CE' | |
curl -fsSL https://get.docker.com | sh | |
: 'Install Home-Assistant OS-Agent' | |
wget -qO $OSAGENT_DEB "https://github.com/home-assistant/os-agent/releases/download/${OSAGENT_VER}/os-agent_${OSAGENT_VER}_linux_aarch64.deb" | |
dpkg -i $OSAGENT_DEB > /dev/null | |
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os > /dev/null | |
: 'Install Home-Assistant Supervised' | |
wget -qO $SUPERVISED_DEB 'https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb' | |
: 'If you stacked after PING result, press ENTER' | |
dpkg -i $SUPERVISED_DEB > /dev/null | |
: 'Change timezone to JST' | |
timedatectl set-timezone Asia/Tokyo | |
echo 'NTP=ntp.nict.jp' >> /etc/systemd/timesyncd.conf | |
systemctl restart systemd-timesyncd | |
: 'Change hostname to raspberry' | |
hostnamectl set-hostname raspberry | |
echo 127.0.0.1 $(hostname) >> /etc/hosts | |
: 'Install optional packages' | |
apt-get install -y --no-install-recommends screen sudo > /dev/null | |
: 'Add user katabame' | |
adduser --disabled-password --gecos "" katabame | |
gpasswd -a katabame sudo | |
printf 'katabame ALL=NOPASSWD: ALL' >> /etc/sudoers | |
mkdir /home/katabame/.ssh | |
curl -fsSL https://github.com/katabame.keys >> /home/katabame/.ssh/authorized_keys | |
chmod 700 /home/katabame/.ssh | |
chmod 600 /home/katabame/.ssh/authorized_keys | |
chown -R katabame:katabame /home/katabame/.ssh | |
: 'Configure sshd' | |
printf 'PermitRootLogin no\nPasswordAuthentication no\nUsePAM no\nPubkeyAuthentication yes\nChallengeResponseAuthentication no\nX11Forwarding no\nAuthorizedKeysFile .ssh/authorized_keys' >> /etc/ssh/sshd_config.d/raspberry | |
/usr/sbin/sshd -t | |
systemctl restart sshd | |
: 'Connect to WiFi network' | |
nmcli device wifi connect Chamomile-5GHz password 'energy in adversity' | |
: 'Sanitize packages' | |
apt-get update > /dev/null | |
apt-get upgrade -y --no-install-recommends > /dev/null | |
apt-get autoremove | |
apt-get autoclean | |
: 'Show IP information' | |
ip -br addr show | grep -E "(eth[0-9]|wlan[0-9]) " | |
ip -br link show | grep -E "(eth[0-9]|wlan[0-9]) " | |
: 'Everything is done!' | |
: 'What is next?' | |
: 'Execute `shutdown now` and make sure fully shutted down (no green led light)' | |
: 'UnPlug ethernet cable and move to desired location' | |
: 'Finally continue setup via SSH' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment