Created
October 9, 2022 16:36
-
-
Save whoo/2da1cc170b6441c624ebe7f8d33d5afe to your computer and use it in GitHub Desktop.
HomeAssistant-Alpine-create
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
#!/bin/sh | |
function create_files() | |
{ | |
echo "initial.sh" | |
cat <<EOF > initial.sh | |
#!/bin/sh | |
source /environ | |
apk add py3-pip gcc g++ musl-dev rust cargo patchelf python3-dev libffi-dev openssl-dev zlib-dev jpeg-dev scapy tzdata make bash procps | |
apk add py3-jinja2 py3-attrs py3-cryptography py3-certifi py3-requests py3-yaml py3-voluptuous py3-numpy | |
apk add py3-bcrypt py3-aiohttp py3-cffi py3-argon2-cffi py3-awesomeversion py3-jwt py3-yarl py3-sqlalchemy py3-qrcode py3-otp scapy | |
pip install pyotp pyqrcode pillow aiohttp_cors sqlalchemy fnvhash home-assistant-frontend scapy pyudev aiodiscover pyroute2 PyTurboJPEG | |
pip install homeassistant | |
EOF | |
echo "environ" | |
cat <<EOF > environ | |
#!/bin/sh | |
export HOME=/root | |
export PATH=/bin:/sbin:/usr/bin:/usr/sbin | |
if [ -e /proc/self/exe ] | |
then | |
echo "Proc is ok" | |
else | |
echo "Mount Proc" | |
mount -t proc /proc /proc | |
fi | |
EOF | |
echo "start.sh" | |
cat <<EOF > start.sh | |
#!/bin/sh | |
source /environ | |
echo "Start Hass" | |
hass | |
EOF | |
echo "hass.service" | |
cat <<EOF > hass.service | |
[Unit] | |
Description=Home Assistant | |
[Service] | |
ExecStart=/usr/sbin/chroot /storage/hass ./start.sh | |
ProtectHome=read-only | |
KillSignal=SIGINT | |
Restart=on-failure | |
RestartSec=30 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
chmod a+x *sh | |
} | |
DIR=hass | |
wget https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/armv7/alpine-minirootfs-3.16.2-armv7.tar.gz | |
mkdir $DIR | |
cd $DIR | |
zcat ../alpine-minirootfs-3.16.2-armv7.tar.gz|tar -x | |
cp /etc/resolv.conf etc/ | |
create_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment