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

Move data location

This commit is contained in:
ewilly 2021-11-14 14:50:33 +01:00
parent 4eaade48e9
commit b9e313f15a
6 changed files with 25 additions and 21 deletions

View file

@ -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

View file

@ -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

View file

@ -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..."

View file

@ -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

View file

@ -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

View file

@ -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..."