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