mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
commit
5a92327f15
4 changed files with 42 additions and 11 deletions
|
@ -1,12 +1,49 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# upgrade_homeassistant.sh - Simple shell script to upgrade homeassistant installed in a python environnement
|
||||||
|
#
|
||||||
|
|
||||||
|
# Uncomment to enable debugging to stderr (prints full client output and more)
|
||||||
|
DEBUG=0
|
||||||
|
|
||||||
# define usefull variables
|
# define usefull variables
|
||||||
app="homeassistant"
|
app="homeassistant"
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
|
|
||||||
local MY_PYTHON=$(readlink -e "$final_path/bin/python")
|
########## END OF CONFIGURATION ##########
|
||||||
|
|
||||||
|
|
||||||
|
########## SCRIPT CODE FOLLOWS, DON'T TOUCH! ##########
|
||||||
|
|
||||||
|
# Log messages to log file.
|
||||||
|
log() {
|
||||||
|
echo "$(date)\t$1" >> $LOG_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
has_sudo() {
|
||||||
|
local prompt
|
||||||
|
prompt=$(sudo -nv 2>&1)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "has sudo pass set"
|
||||||
|
elif echo $prompt | grep -q '^sudo:'; then
|
||||||
|
echo "has sudo needs pass"
|
||||||
|
else
|
||||||
|
echo "can't sudo"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reset log file.
|
||||||
|
if [ ! -z "$DEBUG" ]; then
|
||||||
|
LOG_FILE=$(cd -P -- "$(dirname -- "$0")" && pwd -P)"/upgrade_homeassistant.log"
|
||||||
|
[ -f "$LOG_FILE" ] && :> "$LOG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check User and permissions
|
||||||
|
[ ! -z "$DEBUG" ] && log "User '$(whoami)' is running that script and '$(has_sudo)'."
|
||||||
|
|
||||||
# create the virtual environment
|
# create the virtual environment
|
||||||
|
MY_PYTHON=$(readlink -e "$final_path/bin/python")
|
||||||
|
[ ! -z "$DEBUG" ] && log "Using pyhton '$MY_PYTHON'."
|
||||||
$MY_PYTHON -m venv "$final_path"
|
$MY_PYTHON -m venv "$final_path"
|
||||||
|
|
||||||
# activate the virtual environment
|
# activate the virtual environment
|
||||||
|
@ -23,3 +60,5 @@ pip install --upgrade $app
|
||||||
|
|
||||||
# restart homeassistant systemd service
|
# restart homeassistant systemd service
|
||||||
sudo systemctl restart $app@$app.service
|
sudo systemctl restart $app@$app.service
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -13,11 +13,3 @@ http:
|
||||||
|
|
||||||
# Apply default set of integrations
|
# Apply default set of integrations
|
||||||
default_config:
|
default_config:
|
||||||
|
|
||||||
# Switches
|
|
||||||
switch:
|
|
||||||
- platform: command_line
|
|
||||||
switches:
|
|
||||||
upgrade_homeassistant:
|
|
||||||
command_on: "bash -c /home/homeassistant/.homeassistant/bin/upgrade_homeassistant.sh"
|
|
||||||
friendly_name: Upgrade Home Assistant
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Home automation platform",
|
"en": "Home automation platform",
|
||||||
"fr": "Plateforme domotique"
|
"fr": "Plateforme domotique"
|
||||||
},
|
},
|
||||||
"version": "0.117.6~ynh1",
|
"version": "2021.1.5~ynh1",
|
||||||
"url": "https://github.com/home-assistant/home-assistant",
|
"url": "https://github.com/home-assistant/home-assistant",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Release to install
|
# Release to install
|
||||||
VERSION=2021.1.4
|
VERSION=2021.1.5
|
||||||
|
|
||||||
# Package dependencies
|
# Package dependencies
|
||||||
PKG_DEPENDENCIES="python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5"
|
PKG_DEPENDENCIES="python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5"
|
||||||
|
|
Loading…
Reference in a new issue