diff --git a/conf/systemd.service b/conf/systemd.service index 8f9fe92..8aabe6c 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,8 +5,8 @@ After=network-online.target [Service] Type=simple User=homeassistant -WorkingDirectory=/home/homeassistant/.homeassistant -ExecStart=/opt/yunohost/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant" --verbose +WorkingDirectory=/home/yunohost.app/homeassistant/.homeassistant +ExecStart=/opt/yunohost/homeassistant/bin/hass -c "/home/yunohost.app/homeassistant/.homeassistant" --verbose [Install] WantedBy=multi-user.target diff --git a/scripts/backup b/scripts/backup index b5a73b4..7a8b2bf 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,7 +14,7 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain) # definie useful vars final_path="/opt/yunohost/$app" -home_path="/home/$app" +home_path="/home/yunohost.app/$app" ynh_print_info --message="Storing the python version in settings..." # store python version diff --git a/scripts/install b/scripts/install index a369a79..288f1c4 100644 --- a/scripts/install +++ b/scripts/install @@ -16,8 +16,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC # definie useful vars final_path="/opt/yunohost/$app" -home_path="/home/$app" -data_path="/home/$app/.$app" +home_path="/home/yunohost.app/$app" path_url="/" # check domain/path availability @@ -45,7 +44,7 @@ cp "../conf/sudoers" "/etc/sudoers.d/$app" myynh_create_dir "$final_path" chown $app: "$final_path" ## create a directory for the datas of Home Assistant -myynh_create_dir "$data_path" +myynh_create_dir "$home_path/.$app" chown -R $app: "$home_path" # build (if needed) & install Pyhton @@ -58,15 +57,15 @@ myynh_install_homeassistant # set default configuration files and move all homeassistant_conf_files ynh_script_progression --message="Configuring the installation..." ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/homeassistant_conf_files/configuration.yaml" -cp -r "../conf/homeassistant_conf_files/." "$data_path/" -chown -R $app: "$data_path" -chmod -R +x "$data_path/bin/" +cp -r "../conf/homeassistant_conf_files/." "$home_path/.$app/" +chown -R $app: "$home_path/.$app" +chmod -R +x "$home_path/.$app/bin/" # setup up systemd service ynh_script_progression --message="Adding the dedicated service..." ynh_add_systemd_config --service="$app@$app" ## 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 "$home_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port # start systemd service 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 # enable logrotate -ynh_use_logrotate --logfile="$data_path/home-assistant.log" +ynh_use_logrotate --logfile="$home_path/.$app/home-assistant.log" # create a dedicated nginx config ynh_script_progression --message="Configuring nginx web server..." diff --git a/scripts/remove b/scripts/remove index 817e6b4..598d4cb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) # definie useful vars final_path="/opt/yunohost/$app" -home_path="/home/$app" +home_path="/home/yunohost.app/$app" # remove metapackage and its dependencies ynh_remove_app_dependencies diff --git a/scripts/restore b/scripts/restore index 42666e2..d7949cf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,8 +21,7 @@ python=$(ynh_app_setting_get --app="$app" --key=python) # definie useful vars final_path="/opt/yunohost/$app" -home_path="/home/$app" -data_path="/home/$app/.$app" +home_path="/home/yunohost.app/$app" path_url="/" ynh_script_progression --message="Validating recovery parameters..." @@ -55,7 +54,7 @@ myynh_install_dependencies --python="$python" ynh_script_progression --message="Restoring the dedicated service..." ynh_restore_file --origin_path="/etc/systemd/system/$app@$app.service" # 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 "$home_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port ynh_script_progression --message="Starting the Home Assistant server..." # add --verbose to service diff --git a/scripts/upgrade b/scripts/upgrade index 97eee49..2fce8c2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ fi # definie useful vars final_path="/opt/yunohost/$app" -data_path="/home/$app/.$app" +home_path="/home/yunohost.app/$app" # 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..." @@ -52,17 +52,23 @@ ynh_systemd_action --service_name="$app@$app" --action=stop ynh_script_progression --message="Installing Home Assistant in a virtual environment..." myynh_install_homeassistant +# move $home_path to new directory +if [ -d "$home_path" ] ; then + mv "/home/$app" "$home_path" + chown -R $app: "$home_path" +fi + # update script in bin ynh_script_progression --message="Updating YunoHost script used by homeassitant..." -cp -r "../conf/homeassistant_conf_files/bin/." "$data_path/bin/" -chown -R $app: "$data_path/bin" -chmod -R +x "$data_path/bin/" +cp -r "../conf/homeassistant_conf_files/bin/." "$home_path/.$app/bin/" +chown -R $app: "$home_path/.$app/bin" +chmod -R +x "$home_path/.$app/bin/" # setup up systemd service ynh_script_progression --message="Adding the dedicated service..." ynh_add_systemd_config --service="$app@$app" ## 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 "$home_path/.$app/home-assistant.log" --description "Home Assistant server" --needs_exposed_ports $port # start systemd service ynh_script_progression --message="Starting the Home Assistant server..." @@ -74,7 +80,7 @@ systemctl daemon-reload ynh_systemd_action --service_name="$app@$app" --action=restart # enable logrotate -ynh_use_logrotate --logfile="$data_path/home-assistant.log" --nonappend +ynh_use_logrotate --logfile="$home_path/.$app/home-assistant.log" --nonappend # create a dedicated nginx config ynh_script_progression --message="Configuring nginx web server..."