mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
debug
This commit is contained in:
parent
f1972ff3cf
commit
3843c6b23a
6 changed files with 41 additions and 29 deletions
|
@ -79,7 +79,6 @@ myynh_install_dependencies () {
|
|||
ynh_handle_getopts_args "$@"
|
||||
|
||||
# Install main dependencies from apt
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
ynh_install_app_dependencies "${PKG_DEPENDENCIES}"
|
||||
|
||||
# Check python version from APT
|
||||
|
@ -96,20 +95,20 @@ myynh_install_dependencies () {
|
|||
# Compare version
|
||||
if [ $(myynh_version_compare $PY_APT_VERSION $python) -le 1 ]; then
|
||||
# APT >= Required
|
||||
ynh_script_progression --message="Using provided python3..."
|
||||
ynh_print_info --message="Using provided python3..."
|
||||
MY_PYTHON="python3"
|
||||
else
|
||||
# Either python already built or to build
|
||||
ynh_script_progression --message="Installing additional dependencies..."
|
||||
ynh_print_info --message="Installing additional dependencies..."
|
||||
PKG_DEPENDENCIES="${PKG_DEPENDENCIES} tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libbz2-dev libexpat1-dev liblzma-dev wget tar"
|
||||
ynh_install_app_dependencies "${PKG_DEPENDENCIES}"
|
||||
if [ $(myynh_version_compare $PY_BUILT_VERSION $python) -le 1 ]; then
|
||||
# Built >= Required
|
||||
ynh_script_progression --message="Using already used python3 built version..."
|
||||
ynh_print_info --message="Using already used python3 built version..."
|
||||
MY_PYTHON="/usr/local/bin/python${PY_BUILT_VERSION:0:3}"
|
||||
else
|
||||
# APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin
|
||||
ynh_script_progression --message="Building python (may take a while)..."
|
||||
ynh_print_info --message="Building python (may take a while)..."
|
||||
# Store current direcotry
|
||||
local MY_DIR=$(pwd)
|
||||
# Download
|
||||
|
|
|
@ -16,11 +16,6 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|||
final_path="/opt/yunohost/$app"
|
||||
data_path="/home/yunohost.app/$app"
|
||||
|
||||
ynh_print_info --message="Storing the python version in settings..."
|
||||
# store python version
|
||||
python=$(cat "$final_path/bin/python3" --version | cut -d ' ' -f 2)
|
||||
ynh_app_setting_set --app="$app" --key=python --value="$python"
|
||||
|
||||
# backup source & conf files
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
|
|
@ -48,9 +48,9 @@ myynh_create_dir "$final_path"
|
|||
chown $app: "$final_path"
|
||||
|
||||
# create a directory with its log file
|
||||
myynh_create_dir "/var/log/$app"
|
||||
touch "/var/log/$app/$app.log"
|
||||
chown $app: "/var/log/$app/$app.log"
|
||||
myynh_create_dir "$(dirname "$log_file")"
|
||||
touch "$log_file"
|
||||
chown $app: "$log_file"
|
||||
|
||||
# create a directory for the datas of Home Assistant
|
||||
myynh_create_dir "$data_path/.$app"
|
||||
|
@ -58,6 +58,7 @@ myynh_create_dir "$data_path/.cache"
|
|||
chown -R $app: "$data_path"
|
||||
|
||||
# build (if needed) & install Pyhton
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
myynh_install_dependencies --python="$PY_REQUIRED_VERSION"
|
||||
|
||||
# installation in a virtual environment
|
||||
|
@ -74,7 +75,6 @@ chmod -R +x "$data_path/.$app/bin/"
|
|||
|
||||
# setup up systemd service
|
||||
ynh_script_progression --message="Adding the dedicated service..."
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path/.$app" --target_file="../conf/systemd.service"
|
||||
ynh_add_systemd_config --service="$app"
|
||||
|
||||
## add service in admin panel
|
||||
|
|
|
@ -13,6 +13,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
|||
# definie useful vars
|
||||
final_path="/opt/yunohost/$app"
|
||||
data_path="/home/yunohost.app/$app"
|
||||
log_file="/var/log/$app/$app.log"
|
||||
|
||||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null ; then
|
||||
|
@ -52,9 +53,11 @@ if yunohost firewall list | grep -q "\- $port$" ; then
|
|||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
# remove sudoers file
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
# remove sudoers file
|
||||
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="$(dirname "$log_file")"
|
||||
|
||||
# delete a system user
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
|
|
@ -67,10 +67,10 @@ sed --in-place "/ExecStart/s/$/ --verbose/" "/etc/systemd/system/$app.service"
|
|||
ynh_systemd_action --service_name="$app" --action=start --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=900
|
||||
|
||||
# remove --verbose from service and restart
|
||||
#ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app.service"
|
||||
#ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
||||
#systemctl daemon-reload
|
||||
#ynh_systemd_action --service_name="$app" --action=restart
|
||||
ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app.service"
|
||||
ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
||||
systemctl daemon-reload
|
||||
ynh_systemd_action --service_name="$app" --action=restart
|
||||
|
||||
# restore logrotate
|
||||
ynh_script_progression --message="Restoring logrotate..."
|
||||
|
@ -81,6 +81,6 @@ ynh_script_progression --message="Restoring nginx web server..."
|
|||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
ynh_local_curl "/"
|
||||
sleep 10s #Only necessary for CI test otherwise curl failed to nginx page
|
||||
|
||||
ynh_script_progression --message="Recovery of $app completed" --last
|
||||
|
|
|
@ -18,6 +18,7 @@ port=$(ynh_app_setting_get --app="$app" --key=port)
|
|||
final_path="/opt/yunohost/$app"
|
||||
data_path="/home/yunohost.app/$app"
|
||||
log_file="/var/log/$app/$app.log"
|
||||
path_url="/"
|
||||
|
||||
# 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..."
|
||||
|
@ -29,25 +30,40 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
|||
}
|
||||
fi
|
||||
|
||||
# move $data_path to new directory
|
||||
ynh_script_progression --message="Moving existing datas to new location..."
|
||||
if [ ! -d "$data_path" ] ; then
|
||||
mv "/""home""/$app" "$data_path"
|
||||
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path/.$app" --target_file="$data_path/.$app/configuration.yaml"
|
||||
chown -R $app: "$data_path"
|
||||
fi
|
||||
|
||||
# grant sudo permissions to the user to manage his own systemd service
|
||||
ynh_script_progression --message="Creating dedicated user, rights and folders..."
|
||||
ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app"
|
||||
|
||||
# build (if needed) & install Pyhton
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
myynh_install_dependencies --python="$PY_REQUIRED_VERSION"
|
||||
|
||||
# stop systemd service
|
||||
ynh_script_progression --message="Stoping service..."
|
||||
ynh_systemd_action --service_name="$app" --action=stop --line_match="Stopped Home Assistant" --log_path="$log_file" --timeout=300
|
||||
|
||||
# migrate to new app architecture
|
||||
ynh_script_progression --message="If needed, migrating to new app architecture..."
|
||||
if [ ! -d "$data_path" ]; then
|
||||
# move $data_path to new directory
|
||||
mv "/""home""/$app" "$data_path"
|
||||
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path/.$app" --target_file="$data_path/.$app/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"
|
||||
chown $app: "$log_file"
|
||||
fi
|
||||
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
|
||||
|
||||
# installation in a virtual environment
|
||||
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
||||
ynh_exec_fully_quiet myynh_install_homeassistant --path="$data_path"
|
||||
|
@ -60,7 +76,6 @@ chmod -R +x "$data_path/.$app/bin/"
|
|||
|
||||
# setup up systemd service
|
||||
ynh_script_progression --message="Adding the dedicated service..."
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$data_path/.$app" --target_file="../conf/systemd.service"
|
||||
ynh_add_systemd_config --service="$app"
|
||||
|
||||
# add service in admin panel
|
||||
|
|
Loading…
Reference in a new issue