Skip to content

Commit

Permalink
Merge pull request #376 from YunoHost-Apps/master-promotion
Browse files Browse the repository at this point in the history
Upgrade master from testing
  • Loading branch information
ewilly committed Sep 16, 2024
2 parents 9d87a0d + cbe92ab commit 8351531
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 258 deletions.
1 change: 1 addition & 0 deletions ALL_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
- [Baca README dalam bahasa bahasa Indonesia](README_id.md)
- [Lees de README in het Nederlands](README_nl.md)
- [Прочитать README на русский](README_ru.md)
- [阅读中文(简体)的 README](README_zh_Hans.md)
2 changes: 1 addition & 1 deletion README_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Home Assistant is an open source home automation that puts local control and pri

## Información para desarrolladores

Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/homeassistant_ynh/tree/testing
Por favor enviar sus correcciones a la [rama `testing`](https://github.com/YunoHost-Apps/homeassistant_ynh/tree/testing).

Para probar la rama `testing`, sigue asÍ:

Expand Down
59 changes: 59 additions & 0 deletions README_nl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
NB: Deze README is automatisch gegenereerd door <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
Hij mag NIET handmatig aangepast worden.
-->

# Home Assistant voor Yunohost

[![Integratieniveau](https://dash.yunohost.org/integration/homeassistant.svg)](https://ci-apps.yunohost.org/ci/apps/homeassistant/) ![Mate van functioneren](https://ci-apps.yunohost.org/ci/badges/homeassistant.status.svg) ![Onderhoudsstatus](https://ci-apps.yunohost.org/ci/badges/homeassistant.maintain.svg)

[![Home Assistant met Yunohost installeren](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=homeassistant)

*[Deze README in een andere taal lezen.](./ALL_README.md)*

> *Met dit pakket kun je Home Assistant snel en eenvoudig op een YunoHost-server installeren.*
> *Als je nog geen YunoHost hebt, lees dan [de installatiehandleiding](https://yunohost.org/install), om te zien hoe je 'm installeert.*
## Overzicht

Home Assistant is an open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server.

### Features

- Works with over 1000 brands ;
- Powerful automations ;
- Extend your system with add-ons ;
- All your smart home data stays local ;
- Companion Mobile Apps ;
- Home Energy Management."


**Geleverde versie:** 2024.9.1~ynh1

**Demo:** <https://demo.home-assistant.io>

## Schermafdrukken

![Schermafdrukken van Home Assistant](./doc/screenshots/screenshot1.png)

## Documentatie en bronnen

- Officiele website van de app: <https://www.home-assistant.io>
- Officiele beheerdersdocumentatie: <https://www.home-assistant.io/docs/>
- Upstream app codedepot: <https://github.com/home-assistant/core>
- YunoHost-store: <https://apps.yunohost.org/app/homeassistant>
- Meld een bug: <https://github.com/YunoHost-Apps/homeassistant_ynh/issues>

## Ontwikkelaarsinformatie

Stuur je pull request alsjeblieft naar de [`testing`-branch](https://github.com/YunoHost-Apps/homeassistant_ynh/tree/testing).

Om de `testing`-branch uit te proberen, ga als volgt te werk:

```bash
sudo yunohost app install https://github.com/YunoHost-Apps/homeassistant_ynh/tree/testing --debug
of
sudo yunohost app upgrade homeassistant -u https://github.com/YunoHost-Apps/homeassistant_ynh/tree/testing --debug
```

**Verdere informatie over app-packaging:** <https://yunohost.org/packaging_apps>
3 changes: 2 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ code = "https://github.com/home-assistant/core"
cpe = "cpe:2.3:a:home-assistant:home-assistant"

[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64"]
multi_instance = false
ldap = true
Expand Down
99 changes: 49 additions & 50 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

# App version
## yq is not a dependencie of yunohost package so tomlq command is not available
## (see https://github.com/YunoHost/yunohost/blob/dev/debian/control)
app_version=$(cat ../manifest.toml 2>/dev/null \
| grep 'version = ' | cut -d '=' -f 2 \
| grep '^version = ' | cut -d '=' -f 2 \
| cut -d '~' -f 1 | tr -d ' "') #2024.2.5

# Python required version
Expand All @@ -24,10 +24,6 @@ py_required_version=$(curl -Ls https://www.python.org/ftp/python/ \
# Fail2ban
failregex="^%(__prefix_line)s.*\[homeassistant.components.http.ban\] Login attempt or request with invalid authentication from.* \(<HOST>\).* Requested URL: ./auth/.*"

#=================================================
# PERSONAL HELPERS
#=================================================

# Check if directory/file already exists (path in argument)
myynh_check_path () {
[ -z "$1" ] && ynh_die "No argument supplied"
Expand All @@ -50,13 +46,13 @@ myynh_install_python () {
local python
# Manage arguments with getopts
ynh_handle_getopts_args "$@"

# Check python version from APT
local py_apt_version=$(python3 --version | cut -d ' ' -f 2)

# Usefull variables
local python_major=${python%.*}

# Check existing built version of python in /usr/local/bin
if [ -e "/usr/local/bin/python$python_major" ]
then
Expand All @@ -65,107 +61,110 @@ myynh_install_python () {
else
local py_built_version=0
fi

# Compare version
if $(dpkg --compare-versions $py_apt_version ge $python)
then
# APT >= Required
ynh_print_info --message="Using provided python3..."
ynh_print_info "Using provided python3..."

py_app_version="python3"

else
# Either python already built or to build
# Either python already built or to build

if $(dpkg --compare-versions $py_built_version ge $python)
then
# Built >= Required
ynh_print_info --message="Using already used python3 built version..."
ynh_print_info "Using already used python3 built version..."

py_app_version="/usr/local/bin/python${py_built_version%.*}"

else
# APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin
ynh_print_info --message="Building python (may take a while)..."

# Store current direcotry
ynh_print_info "Building python (may take a while)..."

# Store current direcotry

local MY_DIR=$(pwd)

# Create a temp direcotry
tmpdir="$(mktemp --directory)"
cd "$tmpdir"

# Download
wget --output-document="Python-$python.tar.xz" \
"https://www.python.org/ftp/python/$python/Python-$python.tar.xz" 2>&1

# Extract
tar xf "Python-$python.tar.xz"

# Install
cd "Python-$python"
./configure --enable-optimizations
ynh_exec_warn_less make -j4
ynh_exec_warn_less make altinstall
ynh_hide_warnings make -j4
ynh_hide_warnings make altinstall

# Go back to working directory
cd "$MY_DIR"

# Clean
ynh_secure_remove "$tmpdir"
ynh_safe_rm "$tmpdir"

# Set version
py_app_version="/usr/local/bin/python$python_major"
fi
fi
# Save python version in settings
ynh_app_setting_set --app=$app --key=python --value="$python"
# Save python version in settings

ynh_app_setting_set --key=python --value="$python"
}

# Install/Upgrade Homeassistant in virtual environement
myynh_install_homeassistant () {
# Requirements
pip_required=$(curl -Ls https://pypi.org/pypi/$app/$app_version/json | jq -r '.info.requires_dist[]' | grep 'pip') #pip (<23.1,>=21.0)

# Create the virtual environment
ynh_exec_as $app $py_app_version -m venv --without-pip "$install_dir"
ynh_exec_as_app $py_app_version -m venv --without-pip "$install_dir"

# Run source in a 'sub shell'
(
# activate the virtual environment
set +o nounset
source "$install_dir/bin/activate"
set -o nounset

# add pip
ynh_exec_as $app "$install_dir/bin/python3" -m ensurepip
ynh_exec_as_app "$install_dir/bin/python3" -m ensurepip

# install last version of pip
ynh_exec_warn_less ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$pip_required"
ynh_hide_warnings ynh_exec_as_app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$pip_required"

# install last version of wheel
ynh_exec_warn_less ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade wheel
ynh_hide_warnings ynh_exec_as_app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade wheel

# install last version of setuptools
ynh_exec_warn_less ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade setuptools
ynh_hide_warnings ynh_exec_as_app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade setuptools

# install last version of mysqlclient
ynh_exec_warn_less ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade mysqlclient
ynh_hide_warnings ynh_exec_as_app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade mysqlclient

# install Home Assistant
ynh_exec_warn_less ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$app==$app_version"
ynh_hide_warnings ynh_exec_as_app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$app==$app_version"
)
}

# Upgrade the virtual environment directory
myynh_upgrade_venv_directory () {

# Remove old python links before recreating them
if [ -e "$install_dir/bin/" ]
then
find "$install_dir/bin/" -type l -name 'python*' \
-exec bash -c 'rm --force "$1"' _ {} \;
fi

# Remove old python directories before recreating them
if [ -e "$install_dir/lib/" ]
then
Expand All @@ -179,19 +178,19 @@ myynh_upgrade_venv_directory () {
-not -path "*/python${py_required_version%.*}" \
-exec bash -c 'rm --force --recursive "$1"' _ {} \;
fi

# Upgrade the virtual environment directory
ynh_exec_as $app $py_app_version -m venv --upgrade "$install_dir"
ynh_exec_as_app $py_app_version -m venv --upgrade "$install_dir"
}

# Set permissions
myynh_set_permissions () {
chown -R $app: "$install_dir"
chmod 750 "$install_dir"
chmod u=rwX,g=rX,o= "$install_dir"
chmod -R o-rwx "$install_dir"

chown -R $app: "$data_dir"
chmod 750 "$data_dir"
chmod u=rwX,g=rX,o= "$data_dir"
chmod -R o-rwx "$data_dir"
[ -e "$data_dir/bin/" ] && chmod -R +x "$data_dir/bin/"

Expand Down
36 changes: 13 additions & 23 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,65 @@
# yunohost backup create -n "homeassistant-test" --apps homeassistant
# yunohost backup delete homeassistant-test

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================

ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."

#=================================================
# BACKUP THE APP MAIN DIR
#=================================================

ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"

#=================================================
# BACKUP THE DATA DIR
#=================================================

ynh_backup --src_path="$data_dir" --is_big
ynh_backup "$data_dir"

#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================

ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"

#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================

ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"

#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================

ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"

#=================================================
# BACKUP SYSTEMD
#=================================================

ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"

#=================================================
# BACKUP VARIOUS FILES
#=================================================

ynh_backup --src_path="/etc/sudoers.d/$app"
ynh_backup --src_path="$(dirname "$log_file")"
ynh_backup "/etc/sudoers.d/$app"
ynh_backup "$(dirname "$log_file")"

#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database=$db_name > db.sql
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db > db.sql

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
Loading

0 comments on commit 8351531

Please sign in to comment.