mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
Some fix
This commit is contained in:
parent
e38131f939
commit
c16ccacc12
8 changed files with 93 additions and 72 deletions
|
@ -1,9 +1,7 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1
|
||||||
; Actions
|
|
||||||
is_public=1|0
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -12,12 +10,14 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=b07405d0f885f28764031dd80d27af84a90007b1
|
upgrade=1 from_commit=4eaade48e9bdccf56a53f09a269b2e5ba7621296
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
port_already_use=1
|
port_already_use=1
|
||||||
change_url=1
|
change_url=1
|
||||||
actions=0
|
|
||||||
config_panel=0
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Notification=all
|
Notification=all
|
||||||
|
;;; Upgrade options
|
||||||
|
; commit=4eaade48e9bdccf56a53f09a269b2e5ba7621296
|
||||||
|
name= Update to 2021.6.5 on 21/06/2021
|
||||||
|
manifest_arg=domain=DOMAIN&is_public=1&
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
"version": "2021.11.4~ynh1",
|
"version": "2021.11.4~ynh1",
|
||||||
"url": "https://github.com/home-assistant/home-assistant",
|
"url": "https://github.com/home-assistant/home-assistant",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache-2.0",
|
||||||
"website": "https://www.home-assistant.io",
|
"website": "https://www.home-assistant.io",
|
||||||
"demo": "https://demo.home-assistant.io",
|
"demo": "https://demo.home-assistant.io",
|
||||||
"admindoc": "https://www.home-assistant.io/docs/"
|
"admindoc": "https://www.home-assistant.io/docs/"
|
||||||
},
|
},
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache-2.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "ewilly",
|
"name": "ewilly",
|
||||||
"email": "ewilly@ewilly.fr"
|
"email": "ewilly@ewilly.fr"
|
||||||
|
@ -35,6 +35,10 @@
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
"help": {
|
||||||
|
"en": "If not public, Smartphone app will not work",
|
||||||
|
"fr": "Dans le cas contraire, l'application sur Smartphone ne fonctionnera pas"
|
||||||
|
},
|
||||||
"default": true
|
"default": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -137,7 +137,12 @@ myynh_install_dependencies () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install/Upgrade Homeassistant in virtual environement
|
# Install/Upgrade Homeassistant in virtual environement
|
||||||
|
# | arg: -p, --path= - the parent path of cache directory
|
||||||
myynh_install_homeassistant () {
|
myynh_install_homeassistant () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=u
|
||||||
|
local -A args_array=( [p]=path= )
|
||||||
|
local path
|
||||||
exec_as $app -H -s /bin/bash -c " \
|
exec_as $app -H -s /bin/bash -c " \
|
||||||
echo 'create the virtual environment' \
|
echo 'create the virtual environment' \
|
||||||
&& $MY_PYTHON -m venv "$final_path" \
|
&& $MY_PYTHON -m venv "$final_path" \
|
||||||
|
|
|
@ -14,28 +14,28 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
home_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
|
|
||||||
ynh_print_info --message="Storing the python version in settings..."
|
ynh_print_info --message="Storing the python version in settings..."
|
||||||
# store python version
|
# store python version
|
||||||
python=$(cat "$final_path/bin/python3" --version | cut -d ' ' -f 2)
|
python=$(cat "$final_path/bin/python3" --version | cut -d ' ' -f 2)
|
||||||
ynh_app_setting_set --app="$app" --key=python --value="$python"
|
ynh_app_setting_set --app="$app" --key=python --value="$python"
|
||||||
|
|
||||||
# stop systemd service
|
# stop systemd service to avoid dump in database
|
||||||
ynh_script_progression --message="Stoping service..."
|
ynh_print_info --message="Stoping service..."
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=stop --line_match="Stopped Home Assistant" --log_path="systemd" --timeout=3600
|
ynh_systemd_action --service_name="$app@$app" --action=stop --line_match="Stopped Home Assistant" --log_path="systemd" --timeout=3600
|
||||||
|
|
||||||
# backup source & conf files
|
# backup source & conf files
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$final_path"
|
||||||
ynh_backup --src_path="$home_path"
|
ynh_backup --src_path="$data_path"
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/sudoers.d/$app"
|
ynh_backup --src_path="/etc/sudoers.d/$app"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app@$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app@$app.service"
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
# restart systemd service
|
# restart systemd service
|
||||||
ynh_script_progression --message="Restarting the Home Assistant server..."
|
ynh_print_info --message="Restarting the Home Assistant server..."
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=restart
|
ynh_systemd_action --service_name="$app@$app" --action=restart
|
||||||
|
|
||||||
ynh_print_info --message="Backup of $app completed"
|
ynh_print_info --message="Backup of $app completed"
|
||||||
|
|
|
@ -16,8 +16,8 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
home_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path="$home_path/.$app"
|
data_path/.$app="$data_path/.$app"
|
||||||
path_url="/"
|
path_url="/"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
|
@ -48,31 +48,31 @@ myynh_create_dir "$final_path"
|
||||||
chown $app: "$final_path"
|
chown $app: "$final_path"
|
||||||
|
|
||||||
# create a directory for the datas of Home Assistant
|
# create a directory for the datas of Home Assistant
|
||||||
myynh_create_dir "$data_path"
|
myynh_create_dir "$data_path/.$app"
|
||||||
chown -R $app: "$home_path"
|
chown -R $app: "$data_path"
|
||||||
|
|
||||||
# build (if needed) & install Pyhton
|
# build (if needed) & install Pyhton
|
||||||
myynh_install_dependencies --python="$PY_REQUIRED_VERSION"
|
myynh_install_dependencies --python="$PY_REQUIRED_VERSION"
|
||||||
|
|
||||||
# installation in a virtual environment
|
# installation in a virtual environment
|
||||||
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
||||||
myynh_install_homeassistant "$home_path"
|
myynh_install_homeassistant --path="$data_path"
|
||||||
|
|
||||||
# set default configuration files and move all homeassistant_conf_files
|
# set default configuration files and move all homeassistant_conf_files
|
||||||
ynh_script_progression --message="Configuring the installation..."
|
ynh_script_progression --message="Configuring the installation..."
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/homeassistant_conf_files/configuration.yaml"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/homeassistant_conf_files/configuration.yaml"
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path" --target_file="../conf/homeassistant_conf_files/configuration.yaml"
|
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path/.$app" --target_file="../conf/homeassistant_conf_files/configuration.yaml"
|
||||||
cp -r "../conf/homeassistant_conf_files/." "$data_path/"
|
cp -r "../conf/homeassistant_conf_files/." "$data_path/.$app/"
|
||||||
chown -R $app: "$data_path"
|
chown -R $app: "$data_path/.$app"
|
||||||
chmod -R +x "$data_path/bin/"
|
chmod -R +x "$data_path/.$app/bin/"
|
||||||
|
|
||||||
# setup up systemd service
|
# setup up systemd service
|
||||||
ynh_script_progression --message="Adding the dedicated service..."
|
ynh_script_progression --message="Adding the dedicated service..."
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path" --target_file="../conf/systemd.service"
|
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path/.$app" --target_file="../conf/systemd.service"
|
||||||
ynh_add_systemd_config --service="$app@$app"
|
ynh_add_systemd_config --service="$app@$app"
|
||||||
|
|
||||||
## add service in admin panel
|
## add service in admin panel
|
||||||
yunohost service add "$app@$app" --log "$data_path/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
yunohost service add "$app@$app" --log "$data_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
||||||
|
|
||||||
# start systemd service
|
# start systemd service
|
||||||
ynh_script_progression --message="Starting the Home Assistant server..."
|
ynh_script_progression --message="Starting the Home Assistant server..."
|
||||||
|
@ -85,7 +85,7 @@ systemctl daemon-reload
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=restart
|
ynh_systemd_action --service_name="$app@$app" --action=restart
|
||||||
|
|
||||||
# enable logrotate
|
# enable logrotate
|
||||||
ynh_use_logrotate --logfile="$data_path/home-assistant.log"
|
ynh_use_logrotate --logfile="$data_path/.$app/home-assistant.log"
|
||||||
|
|
||||||
# create a dedicated nginx config
|
# create a dedicated nginx config
|
||||||
ynh_script_progression --message="Configuring nginx web server..."
|
ynh_script_progression --message="Configuring nginx web server..."
|
||||||
|
|
|
@ -12,38 +12,52 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
home_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
|
|
||||||
# remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
# remove systemd service
|
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=stop --line_match="Stopped Home Assistant" --log_path="systemd" --timeout=3600
|
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=disable
|
|
||||||
ynh_secure_remove --file="/etc/systemd/system/$app@$app.service"
|
|
||||||
|
|
||||||
# remove the app directory securely
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
# remove the dedicated nginx config
|
|
||||||
ynh_remove_nginx_config
|
|
||||||
|
|
||||||
# remove a directory securely
|
|
||||||
ynh_secure_remove --file="$home_path"
|
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status "$app@$app" >/dev/null 2>&1 ; then
|
if ynh_exec_warn_less yunohost service status "$app@$app" >/dev/null ; then
|
||||||
|
ynh_script_progression --message="Removing $app service integration..."
|
||||||
yunohost service remove "$app@$app"
|
yunohost service remove "$app@$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove logrotate config
|
# remove systemd service
|
||||||
|
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||||
|
ynh_remove_systemd_config --service="$app@$app"
|
||||||
|
|
||||||
|
# remove the app-specific logrotate config
|
||||||
|
ynh_script_progression --message="Removing logrotate configuration..."
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
# close port
|
# remove metapackage and its dependencies
|
||||||
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
|
ynh_script_progression --message="Removing dependencies..."
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
# delete a system user
|
# remove the app directory securely
|
||||||
ynh_system_user_delete --username="$app"
|
ynh_script_progression --message="Removing app main directory..."
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
# remove a directory securelyif --purge option is used
|
||||||
|
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] ; then
|
||||||
|
ynh_script_progression --message="Removing app data directory..."
|
||||||
|
ynh_secure_remove --file="$data_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove the dedicated nginx config
|
||||||
|
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
# close port
|
||||||
|
if yunohost firewall list | grep -q "\- $port$" ; then
|
||||||
|
ynh_script_progression --message="Closing port $port..."
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
|
fi
|
||||||
|
|
||||||
# remove sudoers file
|
# remove sudoers file
|
||||||
|
ynh_script_progression --message="Removing various files..."
|
||||||
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
||||||
|
|
||||||
|
# delete a system user
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
ynh_system_user_delete --username="$app"
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -21,8 +21,7 @@ python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
home_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path="$home_path/.$app"
|
|
||||||
path_url="/"
|
path_url="/"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
|
@ -45,9 +44,9 @@ chown -R $app: "$final_path"
|
||||||
|
|
||||||
# restore data
|
# restore data
|
||||||
ynh_script_progression --message="Restoring the data..."
|
ynh_script_progression --message="Restoring the data..."
|
||||||
ynh_restore_file --origin_path="$home_path"
|
ynh_restore_file --origin_path="$data_path"
|
||||||
chown -R $app: "$home_path"
|
chown -R $app: "$data_path"
|
||||||
chmod -R +x "$data_path/bin"
|
chmod -R +x "$data_path/.$app/bin"
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_script_progression --message="Restoring the packages dependencies..."
|
ynh_script_progression --message="Restoring the packages dependencies..."
|
||||||
|
@ -58,7 +57,7 @@ ynh_script_progression --message="Restoring the dedicated service..."
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app@$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app@$app.service"
|
||||||
|
|
||||||
# add service in admin panel
|
# add service in admin panel
|
||||||
yunohost service add "$app@$app" --log "$data_path/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
yunohost service add "$app@$app" --log "$data_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
||||||
|
|
||||||
# restart the app
|
# restart the app
|
||||||
ynh_script_progression --message="Starting the Home Assistant server..."
|
ynh_script_progression --message="Starting the Home Assistant server..."
|
||||||
|
|
|
@ -16,8 +16,7 @@ port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
final_path="/opt/yunohost/$app"
|
||||||
home_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path="$home_path/.$app"
|
|
||||||
|
|
||||||
# use prior backup and restore on error only if backup feature exists on installed instance
|
# use prior backup and restore on error only if backup feature exists on installed instance
|
||||||
ynh_script_progression --message="Creating backup in case of failure..."
|
ynh_script_progression --message="Creating backup in case of failure..."
|
||||||
|
@ -29,12 +28,12 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# move $home_path to new directory
|
# move $data_path to new directory
|
||||||
ynh_script_progression --message="Moving existing datas to new location..."
|
ynh_script_progression --message="Moving existing datas to new location..."
|
||||||
if [ ! -d "$home_path" ] ; then
|
if [ ! -d "$data_path" ] ; then
|
||||||
mv "/home/$app" "$home_path"
|
mv "/home/$app" "$data_path"
|
||||||
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path" --target_file="$data_path/configuration.yaml"
|
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path/.$app" --target_file="$data_path/.$app/configuration.yaml"
|
||||||
chown -R $app: "$home_path"
|
chown -R $app: "$data_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# grant sudo permissions to the user to manage his own systemd service
|
# grant sudo permissions to the user to manage his own systemd service
|
||||||
|
@ -50,21 +49,21 @@ ynh_systemd_action --service_name="$app@$app" --action=stop --line_match="Stoppe
|
||||||
|
|
||||||
# installation in a virtual environment
|
# installation in a virtual environment
|
||||||
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
||||||
myynh_install_homeassistant "$home_path"
|
myynh_install_homeassistant --path="$data_path"
|
||||||
|
|
||||||
# update script in bin
|
# update script in bin
|
||||||
ynh_script_progression --message="Updating YunoHost script used by homeassitant..."
|
ynh_script_progression --message="Updating YunoHost script used by homeassitant..."
|
||||||
cp -r "../conf/homeassistant_conf_files/bin/." "$data_path/bin/"
|
cp -r "../conf/homeassistant_conf_files/bin/." "$data_path/.$app/bin/"
|
||||||
chown -R $app: "$data_path/bin"
|
chown -R $app: "$data_path/.$app/bin"
|
||||||
chmod -R +x "$data_path/bin/"
|
chmod -R +x "$data_path/.$app/bin/"
|
||||||
|
|
||||||
# setup up systemd service
|
# setup up systemd service
|
||||||
ynh_script_progression --message="Adding the dedicated service..."
|
ynh_script_progression --message="Adding the dedicated service..."
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path" --target_file="../conf/systemd.service"
|
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path/.$app" --target_file="../conf/systemd.service"
|
||||||
ynh_add_systemd_config --service="$app@$app"
|
ynh_add_systemd_config --service="$app@$app"
|
||||||
|
|
||||||
# add service in admin panel
|
# add service in admin panel
|
||||||
yunohost service add "$app@$app" --log "$data_path/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
yunohost service add "$app@$app" --log "$data_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port
|
||||||
|
|
||||||
# start systemd service
|
# start systemd service
|
||||||
ynh_script_progression --message="Starting the Home Assistant server..."
|
ynh_script_progression --message="Starting the Home Assistant server..."
|
||||||
|
@ -78,7 +77,7 @@ systemctl daemon-reload
|
||||||
ynh_systemd_action --service_name="$app@$app" --action=restart
|
ynh_systemd_action --service_name="$app@$app" --action=restart
|
||||||
|
|
||||||
# enable logrotate
|
# enable logrotate
|
||||||
ynh_use_logrotate --logfile="$data_path/home-assistant.log" --nonappend
|
ynh_use_logrotate --logfile="$data_path/.$app/home-assistant.log" --nonappend
|
||||||
|
|
||||||
# create a dedicated nginx config
|
# create a dedicated nginx config
|
||||||
ynh_script_progression --message="Configuring nginx web server..."
|
ynh_script_progression --message="Configuring nginx web server..."
|
||||||
|
|
Loading…
Add table
Reference in a new issue