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

Remove DOWNWARD COMPATIBILITY

This commit is contained in:
ewilly 2022-05-07 21:20:22 +02:00
parent cdeed072a1
commit aa997e7f15

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
#=================================================