mirror of
https://github.com/tteck/Proxmox.git
synced 2024-12-24 14:01:56 +00:00
Update ha_setup.sh
This commit is contained in:
parent
0538a5f56b
commit
adf10bf927
@ -52,6 +52,9 @@ apt-get -qqy install \
|
|||||||
curl \
|
curl \
|
||||||
sudo &>/dev/null
|
sudo &>/dev/null
|
||||||
|
|
||||||
|
echo -e "${CHECKMARK} \e[1;92m Installing pip3... \e[0m"
|
||||||
|
apt-get install -y python3-pip &>/dev/null
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Installing Docker... \e[0m"
|
echo -e "${CHECKMARK} \e[1;92m Installing Docker... \e[0m"
|
||||||
DOCKER_CONFIG_PATH='/etc/docker/daemon.json'
|
DOCKER_CONFIG_PATH='/etc/docker/daemon.json'
|
||||||
mkdir -p $(dirname $DOCKER_CONFIG_PATH)
|
mkdir -p $(dirname $DOCKER_CONFIG_PATH)
|
||||||
@ -93,31 +96,29 @@ docker run -d \
|
|||||||
--net=host \
|
--net=host \
|
||||||
homeassistant/home-assistant:stable &>/dev/null
|
homeassistant/home-assistant:stable &>/dev/null
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating Update Script... \e[0m"
|
echo -e "${CHECKMARK} \e[1;92m Installing runlike... \e[0m"
|
||||||
file_path="/root/update.sh"
|
pip3 install runlike &>/dev/null
|
||||||
echo "#!/bin/bash
|
|
||||||
echo -e '\e[1;33m Pulling New Stable Version... \e[0m'
|
echo -e "${CHECKMARK} \e[1;92m Creating Update-Containers Script... \e[0m"
|
||||||
docker pull homeassistant/home-assistant:stable
|
UPDATE_CONTAINERS_PATH='/root/update-containers.sh'
|
||||||
echo -e '\e[1;33m Stopping Home Assistant... \e[0m'
|
cat >$UPDATE_CONTAINERS_PATH <<'EOF'
|
||||||
docker stop homeassistant
|
#!/bin/bash
|
||||||
echo -e '\e[1;33m Removing Home Assistant... \e[0m'
|
set -o errexit
|
||||||
docker rm homeassistant
|
CONTAINER_LIST="${1:-$(docker ps -q)}"
|
||||||
echo -e '\e[1;33m Starting Home Assistant... \e[0m'
|
for container in ${CONTAINER_LIST}; do
|
||||||
docker run -d \
|
CONTAINER_IMAGE="$(docker inspect --format "{{.Config.Image}}" --type container ${container})"
|
||||||
--name homeassistant \
|
RUNNING_IMAGE="$(docker inspect --format "{{.Image}}" --type container "${container}")"
|
||||||
--privileged \
|
docker pull "${CONTAINER_IMAGE}"
|
||||||
--restart unless-stopped \
|
LATEST_IMAGE="$(docker inspect --format "{{.Id}}" --type image "${CONTAINER_IMAGE}")"
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
if [[ "${RUNNING_IMAGE}" != "${LATEST_IMAGE}" ]]; then
|
||||||
-v /dev:/dev \
|
echo "Updating ${container} image ${CONTAINER_IMAGE}"
|
||||||
-v hass_config:/config \
|
DOCKER_COMMAND="$(runlike "${container}")"
|
||||||
-v /etc/localtime:/etc/localtime:ro \
|
docker rm --force "${container}"
|
||||||
-v /etc/timezone:/etc/timezone:ro \
|
eval ${DOCKER_COMMAND}
|
||||||
--net=host \
|
fi
|
||||||
homeassistant/home-assistant:stable
|
done
|
||||||
echo -e '\e[1;33m Removing Old Image... \e[0m'
|
EOF
|
||||||
docker image prune -f
|
sudo chmod +x /root/update-containers.sh
|
||||||
echo -e '\e[1;33m Finished Update! \e[0m'" > $file_path
|
|
||||||
sudo chmod +x /root/update.sh
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m"
|
echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m"
|
||||||
rm /etc/motd
|
rm /etc/motd
|
||||||
|
Loading…
Reference in New Issue
Block a user