mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
Fix
This commit is contained in:
parent
a432883fb0
commit
c979988cc2
6 changed files with 34 additions and 43 deletions
|
@ -32,7 +32,7 @@ data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||||
python=$(ynh_app_setting_get --app="$app" --key=python)
|
python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
|
|
@ -23,7 +23,7 @@ new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
|
@ -54,7 +54,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..."
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action=stop --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
|
@ -80,7 +80,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
|
@ -83,10 +83,10 @@ mynh_system_user_create
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a MySQL database..."
|
ynh_script_progression --message="Creating a MySQL database..."
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
db_user=$db_name
|
db_user="$db_name"
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$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
|
ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -95,11 +95,11 @@ ynh_script_progression --message="Setting up source files..."
|
||||||
|
|
||||||
# create a directory for the installation of Home Assistant
|
# create a directory for the installation of Home Assistant
|
||||||
myynh_create_dir "$final_path"
|
myynh_create_dir "$final_path"
|
||||||
chown -R $app: "$final_path"
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
# create a directory for the datas of Home Assistant
|
# create a directory for the datas of Home Assistant
|
||||||
myynh_create_dir "$data_path/.cache"
|
myynh_create_dir "$data_path/.cache"
|
||||||
chown -R $app: "$data_path"
|
chown -R "$app": "$data_path"
|
||||||
|
|
||||||
# installation in a virtual environment
|
# installation in a virtual environment
|
||||||
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
ynh_script_progression --message="Installing Home Assistant in a virtual environment..."
|
||||||
|
@ -165,13 +165,13 @@ yunohost service add "$app" --description="Home Assistant server" --log="$log_fi
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# start systemd service with --verbose
|
# start systemd service with --verbose
|
||||||
ynh_systemd_action --service_name="$app" --action="start" --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=3600
|
ynh_systemd_action --service_name="$app" --action=start --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=3600
|
||||||
|
|
||||||
# remove --verbose from systemd service
|
# remove --verbose from systemd service
|
||||||
ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app.service"
|
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"
|
ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
ynh_systemd_action --service_name="$app" --action="restart"
|
ynh_systemd_action --service_name="$app" --action=restart
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
|
@ -18,15 +18,15 @@ ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||||
python=$(ynh_app_setting_get --app="$app" --key=python)
|
python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
db_user=$db_name
|
db_user="$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -58,7 +58,7 @@ ynh_remove_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the MySQL database..."
|
ynh_script_progression --message="Removing the MySQL database..."
|
||||||
|
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_mysql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
|
@ -121,7 +121,7 @@ ynh_secure_remove --file="$(dirname "$log_file")"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
|
||||||
ynh_system_user_delete --username=$app
|
ynh_system_user_delete --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -37,8 +37,8 @@ data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
log_file=$(ynh_app_setting_get --app="$app" --key=log_file)
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||||
python=$(ynh_app_setting_get --app="$app" --key=python)
|
python=$(ynh_app_setting_get --app="$app" --key=python)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
db_user=$db_name
|
db_user="$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -93,9 +93,9 @@ myynh_install_dependencies --python="$python"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..."
|
ynh_script_progression --message="Restoring the MySQL database..."
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=mysqlpwd)
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
|
@ -112,7 +112,7 @@ ynh_restore_file --origin_path="$(dirname "$log_file")"
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service --quiet
|
systemctl enable "$app".service --quiet
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
@ -139,15 +139,7 @@ yunohost service add "$app" --description="Home Assistant server" --log="$log_fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# start systemd service with --verbose
|
ynh_systemd_action --service_name="$app" --action=start
|
||||||
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=3600
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -156,7 +148,6 @@ ynh_systemd_action --service_name="$app" --action=restart
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -43,7 +43,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..."
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action=stop --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -79,7 +79,7 @@ fi
|
||||||
if [ ! -d "$final_path" ]; then
|
if [ ! -d "$final_path" ]; then
|
||||||
# move $final_path to new directory
|
# move $final_path to new directory
|
||||||
mv "/opt/yunohost/$app" "$final_path"
|
mv "/opt/yunohost/$app" "$final_path"
|
||||||
chown -R $app: "$final_path"
|
chown -R "$app": "$final_path"
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$data_path" ]; then
|
if [ ! -d "$data_path" ]; then
|
||||||
# move $data_path to new directory
|
# move $data_path to new directory
|
||||||
|
@ -87,7 +87,7 @@ if [ ! -d "$data_path" ]; then
|
||||||
find "$data_path/.$app" -maxdepth 1 -mindepth 1 -exec mv {} "$data_path" \;
|
find "$data_path/.$app" -maxdepth 1 -mindepth 1 -exec mv {} "$data_path" \;
|
||||||
rmdir "$data_path/.$app"
|
rmdir "$data_path/.$app"
|
||||||
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path" --target_file="$data_path/configuration.yaml"
|
ynh_replace_string --match_string="/home/homeassistant/.homeassistant" --replace_string="$data_path" --target_file="$data_path/configuration.yaml"
|
||||||
chown -R $app: "$data_path"
|
chown -R "$app": "$data_path"
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$log_file" ]; then
|
if [ ! -f "$log_file" ]; then
|
||||||
# create a directory with its log file
|
# create a directory with its log file
|
||||||
|
@ -98,10 +98,10 @@ fi
|
||||||
# changes introduced in 2021.12.8~ynh1
|
# changes introduced in 2021.12.8~ynh1
|
||||||
if [ -z $(ynh_app_setting_get --app="$app" --key=db_name) ]; then
|
if [ -z $(ynh_app_setting_get --app="$app" --key=db_name) ]; then
|
||||||
# create a MySQL database
|
# create a MySQL database
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
db_user=$db_name
|
db_user="$db_name"
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$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
|
ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name"
|
||||||
db_pwd=$(ynh_app_setting_get --app="$app" --key=mysqlpwd)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=mysqlpwd)
|
||||||
if [ -z $(sed -n "/recorder:/=" configuration.yaml) ]; then
|
if [ -z $(sed -n "/recorder:/=" configuration.yaml) ]; then
|
||||||
sed -i "$ a recorder:" "$data_path/configuration.yaml"
|
sed -i "$ a recorder:" "$data_path/configuration.yaml"
|
||||||
|
@ -188,13 +188,13 @@ yunohost service add "$app" --description="Home Assistant server" --log="$log_fi
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# start systemd service with --verbose
|
# start systemd service with --verbose
|
||||||
ynh_systemd_action --service_name="$app" --action="start" --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=3600
|
ynh_systemd_action --service_name="$app" --action=start --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=3600
|
||||||
|
|
||||||
# remove --verbose from service
|
# remove --verbose from service
|
||||||
ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app.service"
|
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"
|
ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
ynh_systemd_action --service_name="$app" --action="restart"
|
ynh_systemd_action --service_name="$app" --action=restart
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue