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

Update syntax

This commit is contained in:
ewilly 2020-08-12 22:22:59 +02:00
parent 82198d4e6c
commit e67e2ffde5
6 changed files with 34 additions and 43 deletions

View file

@ -14,7 +14,7 @@
"email": "ewilly@ewilly.fr" "email": "ewilly@ewilly.fr"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.1" "yunohost": ">= 3.7"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [

View file

@ -10,15 +10,15 @@ ynh_abort_if_errors
# retrieve arguments # retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
# definie useful vars # definie useful vars
final_path="/opt/yunohost/$app" final_path="/opt/yunohost/$app"
home_path="/home/$app" home_path="/home/$app"
# backup source & conf files # backup source & conf files
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
ynh_backup "$home_path" ynh_backup --src_path="$home_path"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/sudoers.d/$app" ynh_backup --src_path="/etc/sudoers.d/$app"
ynh_backup "/etc/systemd/system/$app@$app.service" ynh_backup --src_path="/etc/systemd/system/$app@$app.service"

View file

@ -29,7 +29,6 @@ ynh_install_app_dependencies "$PKG_DEPENDENCIES"
# save app settings # save app settings
ynh_script_progression --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set $app domain "$domain" ynh_app_setting_set $app domain "$domain"
ynh_app_setting_set $app is_public $is_public
# find a free port & open it # find a free port & open it
ynh_script_progression --message="Looking for a free port and opening it..." ynh_script_progression --message="Looking for a free port and opening it..."
@ -90,12 +89,7 @@ ynh_add_nginx_config
ynh_system_reload --service_name=nginx ynh_system_reload --service_name=nginx
# unprotect app access if public (needed for Android app to work) # unprotect app access if public (needed for Android app to work)
ynh_script_progression --message="Configuring SSOwat..." ynh_script_progression --message="Configuring permissions..."
[ $is_public -eq 1 ] && ynh_app_setting_set $app unprotected_uris "/" [ $is_public -eq 1 ] && ynh_permission_update --permission "main" --add "visitors"
# alert about administrator creator
message="Your installation is not yet secure : please, IMMEDIATELY go to $domain in order to create the admin user of Home Assistant."
ynh_script_progression --message="$message"
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -7,8 +7,8 @@ source /usr/share/yunohost/helpers
# retrieve arguments # retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
# definie useful vars # definie useful vars
final_path="/opt/yunohost/$app" final_path="/opt/yunohost/$app"
@ -18,13 +18,13 @@ home_path="/home/$app"
ynh_remove_app_dependencies ynh_remove_app_dependencies
# remove the app directory securely # remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
# remove the dedicated nginx config # remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
# remove a directory securely # remove a directory securely
ynh_secure_remove "$home_path" ynh_secure_remove --file="$home_path"
# remove service from admin panel # remove service from admin panel
if yunohost service status | grep -q "$app@$app" if yunohost service status | grep -q "$app@$app"
@ -35,13 +35,13 @@ fi
# remove systemd service # remove systemd service
ynh_system_reload --service_name="$app@$app" --action=stop ynh_system_reload --service_name="$app@$app" --action=stop
ynh_system_reload --service_name="$app@$app" --action=disable ynh_system_reload --service_name="$app@$app" --action=disable
ynh_secure_remove "/etc/systemd/system/$app.service" ynh_secure_remove --file="/etc/systemd/system/$app.service"
# close port # close port
ynh_exec_fully_quiet yunohost firewall disallow TCP $port ynh_exec_fully_quiet yunohost firewall disallow TCP $port
# delete a system user # delete a system user
ynh_system_user_delete "$app" ynh_system_user_delete --username=$app
# remove sudoers file # remove sudoers file
ynh_secure_remove "/etc/sudoers.d/$app" ynh_secure_remove "/etc/sudoers.d/$app"

View file

@ -12,8 +12,8 @@ ynh_abort_if_errors
# retrieve arguments # retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get "$app" port) port=$(ynh_app_setting_get --app=$app --key=port)
# definie useful vars # definie useful vars
final_path="/opt/yunohost/$app" final_path="/opt/yunohost/$app"
@ -28,29 +28,20 @@ ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not ava
ynh_install_app_dependencies "$PKG_DEPENDENCIES" ynh_install_app_dependencies "$PKG_DEPENDENCIES"
# restore dedicated system user # restore dedicated system user
ynh_system_user_exists "$app" && ynh_die "User $app is not available" ynh_system_user_create --username="$app"
ynh_system_user_create "$app"
# restore conf files # restore conf files
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "/etc/sudoers.d/$app" ynh_restore_file --origin_path="/etc/sudoers.d/$app"
ynh_restore_file "/etc/systemd/system/$app@$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app@$app.service"
# restore source # restore source
if [ ! -d "$final_path" ]; then ynh_restore_file --origin_path="$final_path"
ynh_restore_file "$final_path"
else
ynh_die "There is already a directory: $final_path"
fi
# restore data # restore data
if [ ! -d "$home_path" ]; then ynh_restore_file --origin_path="$home_path"
ynh_restore_file "$home_path" chown -R $app: "$home_path"
chown -R $app: "$home_path" chmod -R +x "$home_path/.homeassistant/bin"
chmod -R +x "$home_path/.homeassistant/bin"
else
ynh_die "$home_path already exists and will not be overwritten"
fi
# restore port # restore port
[ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port" [ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"

View file

@ -8,9 +8,15 @@ ynh_abort_if_errors
# retrieve arguments # retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
is_public=$(ynh_app_setting_get $app is_public)
# Cleaning legacy permissions
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
if [ -n "$is_public" ]; then
ynh_app_setting_delete --app=$app --key=is_public
ynh_app_setting_delete --app=$app --key=unprotected_uris
fi
# definie useful vars # definie useful vars
final_path="/opt/yunohost/$app" final_path="/opt/yunohost/$app"