1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/homeassistant_ynh.git synced 2024-09-03 19:26:16 +02:00

Merge pull request #96 from YunoHost-Apps/master

Merge master changes
This commit is contained in:
ewilly 2022-05-07 21:30:52 +02:00 committed by GitHub
commit 2dac06f305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 91 deletions

View file

@ -10,7 +10,6 @@
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=4eaade48e9bdccf56a53f09a269b2e5ba7621296
backup_restore=1
multi_instance=0
port_already_use=1
@ -18,6 +17,3 @@
;;; Options
Notification=all
;;; Upgrade options
; commit=4eaade48e9bdccf56a53f09a269b2e5ba7621296
name= Update to 2021.6.5 on 21/06/2021
manifest_arg=domain=DOMAIN&is_public=1&

View file

@ -162,7 +162,7 @@ myynh_set_permissions
ynh_script_progression --message="Integrating service in YunoHost..."
# add service in admin panel
yunohost service add $app --description="Home Assistant server" --log="$log_file" --needs_exposed_ports=$port
yunohost service add $app --description="Home Assistant server" --log="$log_file"
#=================================================
# START SYSTEMD SERVICE

View file

@ -91,16 +91,6 @@ ynh_script_progression --message="Removing dependencies..."
ynh_remove_app_dependencies
#=================================================
# CLOSE A 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
#=================================================
# SPECIFIC REMOVE
#=================================================

View file

@ -135,7 +135,7 @@ myynh_set_permissions
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Home Assistant server" --log="$log_file" --needs_exposed_ports=$port
yunohost service add $app --description="Home Assistant server" --log="$log_file"
#=================================================
# START SYSTEMD SERVICE

View file

@ -45,80 +45,6 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# changes introduce in
if [ -z $(ynh_app_setting_get --app=$app --key=final_path) ]
then
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
log_file="/var/log/$app/$app.log"
path_url="/"
ynh_app_setting_set --app=$app --key=final_path --value="$final_path"
ynh_app_setting_set --app=$app --key=data_path --value="$data_path"
ynh_app_setting_set --app=$app --key=log_file --value="$log_file"
ynh_app_setting_set --app=$app --key=path_url --value="$path_url"
else
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
log_file=$(ynh_app_setting_get --app=$app --key=log_file)
path_url=$(ynh_app_setting_get --app=$app --key=path_url)
python=$(ynh_app_setting_get --app=$app --key=python)
fi
# changes introduced in 2021.11.5~ynh1
if [ -f "/etc/systemd/system/$app@$app.service" ]
then
# remove old systemd service
if ynh_exec_warn_less yunohost service status "$app@$app" >/dev/null
then
yunohost service remove "$app@$app"
fi
ynh_remove_systemd_config --service="$app@$app"
fi
if [ ! -d "$final_path" ]
then
# move $final_path to new directory
mv "/opt/yunohost/$app" "$final_path"
chown -R $app: "$final_path"
fi
if [ ! -d "$data_path" ]
then
# move $data_path to new directory
mv "/""home""/$app" "$data_path"
find "$data_path/.$app" -maxdepth 1 -mindepth 1 -exec mv {} "$data_path" \;
rmdir "$data_path/.$app"
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path" --target_file="$data_path/configuration.yaml"
chown -R $app: "$data_path"
fi
if [ ! -f "$log_file" ]
then
# create a directory with its log file
myynh_create_dir "$(dirname "$log_file")"
touch "$log_file"
fi
# changes introduced in 2021.12.8~ynh1
if [ -z $(ynh_app_setting_get --app=$app --key=db_name) ]
then
# create a MySQL database
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
if [ -z $(sed -n "/recorder:/=" "$data_path/configuration.yaml") ]
then
sed -i "$ a recorder:" "$data_path/configuration.yaml"
sed -i "$ a \ db_url: mysql://$db_user:$db_pwd@127.0.0.1/$db_name?unix_socket=/var/run/mysqld/mysqld.sock&charset=utf8mb4" "$data_path/configuration.yaml"
else
sed -i "/recorder:/a \ db_url: mysql://$db_user:$db_pwd@127.0.0.1/$db_name?unix_socket=/var/run/mysqld/mysqld.sock&charset=utf8mb4" "$data_path/configuration.yaml"
fi
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -193,7 +119,7 @@ myynh_set_permissions
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Home Assistant server" --log="$log_file" --needs_exposed_ports=$port
yunohost service add $app --description="Home Assistant server" --log="$log_file"
#=================================================
# START SYSTEMD SERVICE