forked from MadDoct/hassio-installer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhassio_s9xxarmbian.sh
138 lines (112 loc) · 5.28 KB
/
hassio_s9xxarmbian.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
###################################################################
###################################################################
## ##
## THIS SCRIPT SHOULD ONLY BE RUN ON A S9xxx BOX RUNNING ARMBIAN ##
## ##
###################################################################
###################################################################
set -o errexit # Exit script when a command exits with non-zero status
set -o errtrace # Exit on error inside any functions or sub-shells
set -o nounset # Exit script on use of an undefined variable
set -o pipefail # Return exit status of the last command in the pipe that failed
#
## ==============================================================================
## GLOBALS
## ==============================================================================
readonly HOSTNAME="TV4YOU"
readonly REQUIREMENTS=(
apparmor-utils
apt-transport-https
avahi-daemon
ca-certificates
curl
dbus
jq
network-manager
socat
software-properties-common
udisks2
wget
)
os_agent_version="1.4.1"
ARCHITECTURE="linux_aarch64.deb"
# ==============================================================================
# SCRIPT LOGIC
# ==============================================================================
# ==============================================================================
# Are we root?
# ==============================================================================
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
echo "Please try again after running:"
echo " sudo su"
exit 1
fi
# ------------------------------------------------------------------------------
# Ensures the hostname of the Pi is correct.
# ------------------------------------------------------------------------------
old_hostname=$(< /etc/hostname)
if [[ "${old_hostname}" != "${HOSTNAME}" ]]; then
sed -i "s/${old_hostname}/${HOSTNAME}/g" /etc/hostname
sed -i "s/${old_hostname}/${HOSTNAME}/g" /etc/hosts
hostname "${HOSTNAME}"
echo "Hostname will be changed on next reboot: ${HOSTNAME}"
fi
echo "# ------------------------------------------------------------------------------"
echo "Updating APT packages list..."
echo "# ------------------------------------------------------------------------------"
apt-get clean
rm -rf /var/lib/apt/lists/*
apt-get clean
apt --fix-broken install -y
apt-get update
apt-get upgrade -y
apt-get install -y software-properties-common
apt-get update
echo "# ------------------------------------------------------------------------------"
echo "Ensure all requirements are installed..."
echo "# ------------------------------------------------------------------------------"
apt-get install -y "${REQUIREMENTS[@]}"
# ------------------------------------------------------------------------------
# Installs the os-agent
# ------------------------------------------------------------------------------
echo "# ------------------------------------------------------------------------------"
echo "Installing os-agent ${ARCHITECTURE} V:${os_agent_version}..."
echo "# ------------------------------------------------------------------------------"
wget -c https://github.com/home-assistant/os-agent/releases/download/${os_agent_version}/os-agent_${os_agent_version}_${ARCHITECTURE}
echo "# ------------------------------------------------------------------------------"
echo "dpkg os-agent V${os_agent_version}..."
echo "# ------------------------------------------------------------------------------"
dpkg -i os-agent_${os_agent_version}_${ARCHITECTURE}
{
echo -e "\n[device]";
echo "wifi.scan-rand-mac-address=no";
echo -e "\n[connection]";
echo "wifi.clone-mac-address=preserve";
} >> "/etc/NetworkManager/NetworkManager.conf"
# ------------------------------------------------------------------------------
# Installing Docker...
# ------------------------------------------------------------------------------
echo "# ------------------------------------------------------------------------------"
echo "Installing Docker..."
echo "# ------------------------------------------------------------------------------"
curl -fsSL https://get.docker.com | sh
# ------------------------------------------------------------------------------
# Installs and starts Hass.io
# ------------------------------------------------------------------------------
echo "# ------------------------------------------------------------------------------"
echo "Installing Hass.io..."
echo "# ------------------------------------------------------------------------------"
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# Friendly closing message
ip_addr=$(hostname -I | cut -d ' ' -f1)
echo "======================================================================="
echo "Hass.io is now installing Home Assistant."
echo "This process may take up to 20 minutes. Please visit:"
echo "http://${HOSTNAME}.local:8123/ in your browser and wait"
echo "for Home Assistant to load."
echo "If the previous URL does not work, please try http://${ip_addr}:8123/"
journalctl -f