Skip to content

Instantly share code, notes, and snippets.

@kuoruan
Last active September 22, 2022 16:42
Show Gist options
  • Save kuoruan/a3825e61365b3f44ef220bc4c0bab285 to your computer and use it in GitHub Desktop.
Save kuoruan/a3825e61365b3f44ef220bc4c0bab285 to your computer and use it in GitHub Desktop.
OneCloud Home Assistant install script
#!/bin/sh
set -e
install_deps() {
apt-get update
apt-get upgrade -y
apt-get install -y \
apparmor \
armbian-config \
ca-certificates \
curl \
dbus \
jq \
libglib2.0-bin \
network-manager \
rauc-service \
udisks2 \
wget \
vim
}
set_sysctl() {
echo -e 'net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1' | tee -a /etc/sysctl.conf > /dev/null
sysctl -p
}
set_armbian_env() {
sed -i 's/^# extraargs=""/extraargs="apparmor=1 security=apparmor systemd.unified_cgroup_hierarchy=false"/' \
/boot/armbianEnv.txt
}
install_docker() {
wget -qO- https://get.docker.com/ | sh
}
docekr_enable_ipv6() {
echo '{
"ipv6": true",
"fixed-cidr-v6": "fc00:100:10::/64",
"experimental": true,
"ip6tables": true
}' | tee /etc/docker/daemon.json > /dev/null
}
unzip_firmware() {
wget -qO - https://v2.kuoruan.net/rtl_bt.tar.gz | tar -xz -C /lib/firmware/rtl_bt
wget -qO - https://v2.kuoruan.net/rtl_wifi.tar.gz | tar -xz -C /lib/firmware/rtl_wifi
}
ask_for_reboot() {
echo "Reboot is required. Do you want to reboot now? [Y/n]"
read -r answer
if [ "$answer" != "${answer#[Nn]}" ]; then
exit 1
fi
reboot
}
install_home_assistant() {
wget -qO - \
https://github.com/home-assistant/os-agent/releases/latest/download/os-agent_1.3.0_linux_armv7.deb | \
dpkg -i -
wget -qO - \
https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb | \
dpkg -i -
}
action=$1
case $action in
prepare)
install_deps
install_docker
set_sysctl
set_armbian_env
unzip_firmware
ask_for_reboot
;;
install)
install_home_assistant
;;
*)
echo "Usage: $0 [prepare|install]"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment