mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 09:36:31 +00:00
Allow resinhup autoupdate
This commit is contained in:
parent
f13406b2f8
commit
12b561c0bf
@ -8,6 +8,11 @@ Builds are published on: https://hub.docker.com/r/pvizeli/
|
||||
|
||||
- yocto-build-env: Allow us to build yocto resinos images
|
||||
- docker-build-env: Allow us to build docker image for all archs
|
||||
- resinhup-build: Create docker image for inplace update perform
|
||||
- resinos-build: Create image for SD and docker for inplace update
|
||||
- hassio-supervisor: Create our supervisor update
|
||||
- homeassistant: Create docker image with homeassistant
|
||||
|
||||
|
||||
## Create a server
|
||||
|
||||
|
@ -20,8 +20,8 @@ cleanup() {
|
||||
trap 'cleanup fail' SIGINT SIGTERM
|
||||
|
||||
# Sanity checks
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: create_resinos.sh <MACHINE> <SUPERVISOR_TAG>"
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: create_resinos.sh <MACHINE> <SUPERVISOR_TAG> <HASSIO_VERSION>"
|
||||
echo "Optional environment: BUILD_DIR, PERSISTENT_WORKDIR, RESIN_BRANCH, HASSIO_ROOT"
|
||||
exit 1
|
||||
fi
|
||||
@ -33,6 +33,7 @@ popd > /dev/null 2>&1
|
||||
|
||||
MACHINE=$1
|
||||
SUPERVISOR_TAG=$2
|
||||
HASSIO_VERSION=$3
|
||||
PERSISTENT_WORKDIR=${PERSISTENT_WORKDIR:=~/yocto}
|
||||
BUILD_DIR=${BUILD_DIR:=$SCRIPTPATH}
|
||||
WORKSPACE=${BUILD_DIR:=$SCRIPTPATH}/resin-board
|
||||
@ -68,7 +69,7 @@ echo "[INFO] Inject HassIO yocto layer"
|
||||
cp -fr $HASSIO_ROOT/meta-hassio $WORKSPACE/layers/
|
||||
|
||||
# Additional variables
|
||||
BARYS_ARGUMENTS_VAR="-a HASSIO_SUPERVISOR_TAG=$SUPERVISOR_TAG -a HOMEASSISTANT_REPOSITORY=$HOMEASSISTANT_REPOSITORY"
|
||||
BARYS_ARGUMENTS_VAR="-a HASSIO_SUPERVISOR_TAG=$SUPERVISOR_TAG -a HOMEASSISTANT_REPOSITORY=$HOMEASSISTANT_REPOSITORY -a HASSIO_VERSION=$HASSIO_VERSION"
|
||||
|
||||
# Make sure shared directories are in place
|
||||
mkdir -p $DOWNLOAD_DIR
|
||||
|
@ -45,6 +45,9 @@ fi
|
||||
# Resin supervisor variables
|
||||
source /etc/resin-supervisor/supervisor.conf
|
||||
|
||||
# ResinOS variables
|
||||
source /etc/hassio.conf
|
||||
|
||||
# If config.json provides redefinitions for our vars let us rewrite their
|
||||
# runtime value
|
||||
if [ -f $CONFIG_PATH ]
|
||||
|
@ -2,6 +2,7 @@
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
SRC_URI += " \
|
||||
file://hassio.conf \
|
||||
file://resinhup.sh \
|
||||
file://resinhup.service \
|
||||
"
|
||||
@ -16,9 +17,13 @@ SYSTEMD_AUTO_ENABLE = "enable"
|
||||
FILES_${PN} += " \
|
||||
${systemd_unitdir} \
|
||||
${bindir} \
|
||||
${sysconfdir} \
|
||||
"
|
||||
|
||||
do_install_append() {
|
||||
install -m 0755 ${WORKDIR}/hassio.conf ${D}${sysconfdir}
|
||||
sed -i -e 's:@HASSIO_VERSION@:${HASSIO_VERSION}:g' ${D}${sysconfdir}/hassio.conf
|
||||
|
||||
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -c -m 0644 ${WORKDIR}/resinhup.service ${D}${systemd_unitdir}/system
|
||||
|
@ -0,0 +1 @@
|
||||
HASSIO_VERSION=%HASSIO_VERSION%
|
@ -11,6 +11,9 @@ DOCKER_REPO=pvizeli
|
||||
# Don't run anything before this source as it sets PATH here
|
||||
source /etc/profile
|
||||
|
||||
# load config
|
||||
source /usr/sbin/resin-vars
|
||||
|
||||
# Help function
|
||||
function help {
|
||||
cat << EOF
|
||||
@ -139,11 +142,11 @@ while [[ $# > 0 ]]; do
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
-t|--tag)
|
||||
-t|--resinhup-version)
|
||||
if [ -z "$2" ]; then
|
||||
log ERROR "\"$1\" argument needs a value."
|
||||
fi
|
||||
TAG=$2
|
||||
RESINHUP_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
--hostos-version)
|
||||
@ -192,7 +195,19 @@ done
|
||||
|
||||
# Check that HostOS version was provided
|
||||
if [ -z "$HOSTOS_VERSION" ]; then
|
||||
log ERROR "--hostos-version is required."
|
||||
if version=$(curl $ENDPOINT | jq -e -r '.hassio_version')
|
||||
HOSTOS_VERSION=version
|
||||
else
|
||||
log ERROR "--hostos-version is required."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z $RESINHUP_VERSION ]; then
|
||||
if version=$(curl $ENDPOINT | jq -e -r '.resinhub_version')
|
||||
HOSTOS_VERSION=version
|
||||
else
|
||||
log ERROR "--hostos-version is required."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Init log file
|
||||
@ -202,6 +217,12 @@ if [ "$LOG" == "yes" ]; then
|
||||
date >> $LOGFILE
|
||||
fi
|
||||
|
||||
# Check if update is needed
|
||||
if [ $HASSIO_VERSION == $HOSTOS_VERSION ]; then
|
||||
log "Version $HOSTOS_VERSION is already installed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Detect DATA_MOUNTPOINT
|
||||
if [ -d /mnt/data ]; then
|
||||
DATA_MOUNTPOINT=/mnt/data
|
||||
@ -215,20 +236,10 @@ fi
|
||||
runPreHacks
|
||||
|
||||
# Detect arch
|
||||
source /etc/resin-supervisor/supervisor.conf
|
||||
arch=$MACHINE
|
||||
if [ -z "$arch" ]; then
|
||||
log ERROR "Can't detect arch from /etc/resin-supervisor/supervisor.conf ."
|
||||
if [ -z "$MACHINE" ]; then
|
||||
log ERROR "Can't detect machine from resin-vars ."
|
||||
else
|
||||
log "Detected arch: $arch ."
|
||||
fi
|
||||
|
||||
# Detect slug
|
||||
slug=$MACHINE
|
||||
if [ -z $slug ]; then
|
||||
log ERROR "Can't detect slug from /etc/resin-supervisor/supervisor.conf ."
|
||||
else
|
||||
log "Detected slug: $slug ."
|
||||
log "Detected arch: $MACHINE ."
|
||||
fi
|
||||
|
||||
# We need to stop update-resin-supervisor.timer otherwise it might restart supervisor which
|
||||
@ -274,10 +285,10 @@ docker rm $(docker ps -a -q) > /dev/null 2>&1
|
||||
|
||||
# Pull resinhup and tag it accordingly
|
||||
log "Pulling resinhup..."
|
||||
docker pull $DOCKER_REPO/resinhup-$slug:$TAG
|
||||
docker pull $DOCKER_REPO/resinhup:$MACHINE-$RESINHUP_VERSION
|
||||
if [ $? -ne 0 ]; then
|
||||
tryup
|
||||
log ERROR "Could not pull $DOCKER_REPO/resinhup-$slug:$TAG ."
|
||||
log ERROR "Could not pull $DOCKER_REPO/resinhup:$MACHINE-$RESINHUP_VERSION ."
|
||||
fi
|
||||
|
||||
# Run resinhup
|
||||
@ -291,7 +302,7 @@ docker run --privileged --rm --net=host $RESINHUP_ENV \
|
||||
-v /:/host \
|
||||
-v /lib/modules:/lib/modules:ro \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
$DOCKER_REPO/resinhup-$slug:$TAG
|
||||
$DOCKER_REPO/resinhup:$MACHINE-$RESINHUP_VERSION
|
||||
RESINHUP_EXIT=$?
|
||||
# RESINHUP_EXIT
|
||||
# 0 - update done
|
||||
|
Loading…
x
Reference in New Issue
Block a user