From cb40e4e59c9b7360811b82e965e3136cafb7bd6f Mon Sep 17 00:00:00 2001 From: ewilly Date: Tue, 7 Dec 2021 21:11:30 +0100 Subject: [PATCH] Fix --- conf/homeassistant_conf_files/bin/upgrade_homeassistant.sh | 5 +++-- scripts/_common.sh | 4 ++-- scripts/install | 2 +- scripts/upgrade | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/conf/homeassistant_conf_files/bin/upgrade_homeassistant.sh b/conf/homeassistant_conf_files/bin/upgrade_homeassistant.sh index 1de83bb..36e08c5 100755 --- a/conf/homeassistant_conf_files/bin/upgrade_homeassistant.sh +++ b/conf/homeassistant_conf_files/bin/upgrade_homeassistant.sh @@ -9,6 +9,7 @@ DEBUG=0 # define usefull variables app="homeassistant" final_path="/var/www/$app" +data_path="/home/yunohost.app/$app" ########## END OF CONFIGURATION ########## @@ -50,10 +51,10 @@ $MY_PYTHON -m venv "$final_path" source "$final_path/bin/activate" # install last version of wheel -pip --no-cache-dir install --upgrade wheel +pip --cache-dir "$data_path/.cache" install --upgrade wheel # upgrade homeassistant python package -pip --no-cache-dir install --upgrade $app +pip --cache-dir "$data_path/.cache" install --upgrade $app # restart homeassistant systemd service sudo systemctl restart $app.service diff --git a/scripts/_common.sh b/scripts/_common.sh index 8e8e0bd..98af024 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -131,9 +131,9 @@ myynh_install_homeassistant () { && echo 'activate the virtual environment' \ && source "$final_path/bin/activate" \ && echo 'install last version of wheel' \ - && pip --no-cache-dir install --upgrade wheel \ + && pip --cache-dir "$data_path/.cache" install --upgrade wheel \ && echo 'install Home Assistant' \ - && pip --no-cache-dir install --upgrade $app==$VERSION \ + && pip --cache-dir "$data_path/.cache" install --upgrade $app==$VERSION \ " } diff --git a/scripts/install b/scripts/install index 5348086..a5ad85f 100644 --- a/scripts/install +++ b/scripts/install @@ -51,7 +51,7 @@ myynh_create_dir "$(dirname "$log_file")" touch "$log_file" # create a directory for the datas of Home Assistant -myynh_create_dir "$data_path" +myynh_create_dir "$data_path/.cache" # build (if needed) & install Pyhton ynh_script_progression --message="Installing dependencies..." diff --git a/scripts/upgrade b/scripts/upgrade index 2a87702..681a6e5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,10 +57,10 @@ if [ ! -d "$final_path" ]; then mv "/opt/yunohost/$app" "$final_path" fi if [ ! -d "$data_path" ]; then - # remove pip cache - ynh_secure_remove --file="/home/homeassistant/.cache" # move $data_path to new directory mv "/""home""/$app" "$data_path" + mv "$data_path/.$app/." "$data_path" + rmdir "$data_path/.$app" ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path" --target_file="$data_path/configuration.yaml" fi if [ ! -f "$log_file" ]; then