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:
parent
82198d4e6c
commit
e67e2ffde5
6 changed files with 34 additions and 43 deletions
|
@ -14,7 +14,7 @@
|
|||
"email": "ewilly@ewilly.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.1"
|
||||
"yunohost": ">= 3.7"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -10,15 +10,15 @@ ynh_abort_if_errors
|
|||
|
||||
# retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
# definie useful vars
|
||||
final_path="/opt/yunohost/$app"
|
||||
home_path="/home/$app"
|
||||
|
||||
# backup source & conf files
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup "$home_path"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/sudoers.d/$app"
|
||||
ynh_backup "/etc/systemd/system/$app@$app.service"
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$home_path"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/sudoers.d/$app"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app@$app.service"
|
||||
|
|
|
@ -29,7 +29,6 @@ ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
|||
# save app settings
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set $app domain "$domain"
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
# find a free port & open 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
|
||||
|
||||
# unprotect app access if public (needed for Android app to work)
|
||||
ynh_script_progression --message="Configuring SSOwat..."
|
||||
[ $is_public -eq 1 ] && ynh_app_setting_set $app unprotected_uris "/"
|
||||
|
||||
# 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="Configuring permissions..."
|
||||
[ $is_public -eq 1 ] && ynh_permission_update --permission "main" --add "visitors"
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -7,8 +7,8 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
# definie useful vars
|
||||
final_path="/opt/yunohost/$app"
|
||||
|
@ -18,13 +18,13 @@ home_path="/home/$app"
|
|||
ynh_remove_app_dependencies
|
||||
|
||||
# remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
# remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# remove a directory securely
|
||||
ynh_secure_remove "$home_path"
|
||||
ynh_secure_remove --file="$home_path"
|
||||
|
||||
# remove service from admin panel
|
||||
if yunohost service status | grep -q "$app@$app"
|
||||
|
@ -35,13 +35,13 @@ fi
|
|||
# remove systemd service
|
||||
ynh_system_reload --service_name="$app@$app" --action=stop
|
||||
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
|
||||
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
|
||||
|
||||
# delete a system user
|
||||
ynh_system_user_delete "$app"
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
# remove sudoers file
|
||||
ynh_secure_remove "/etc/sudoers.d/$app"
|
||||
|
|
|
@ -12,8 +12,8 @@ ynh_abort_if_errors
|
|||
|
||||
# retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
# definie useful vars
|
||||
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"
|
||||
|
||||
# restore dedicated system user
|
||||
ynh_system_user_exists "$app" && ynh_die "User $app is not available"
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create --username="$app"
|
||||
|
||||
# restore conf files
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file "/etc/sudoers.d/$app"
|
||||
ynh_restore_file "/etc/systemd/system/$app@$app.service"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app@$app.service"
|
||||
|
||||
# restore source
|
||||
if [ ! -d "$final_path" ]; then
|
||||
ynh_restore_file "$final_path"
|
||||
else
|
||||
ynh_die "There is already a directory: $final_path"
|
||||
fi
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
# restore data
|
||||
if [ ! -d "$home_path" ]; then
|
||||
ynh_restore_file "$home_path"
|
||||
chown -R $app: "$home_path"
|
||||
chmod -R +x "$home_path/.homeassistant/bin"
|
||||
else
|
||||
ynh_die "$home_path already exists and will not be overwritten"
|
||||
fi
|
||||
ynh_restore_file --origin_path="$home_path"
|
||||
chown -R $app: "$home_path"
|
||||
chmod -R +x "$home_path/.homeassistant/bin"
|
||||
|
||||
# restore port
|
||||
[ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
|
||||
|
|
|
@ -8,9 +8,15 @@ ynh_abort_if_errors
|
|||
|
||||
# retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
# 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
|
||||
final_path="/opt/yunohost/$app"
|
||||
|
|
Loading…
Reference in a new issue