diff --git a/scripts/install b/scripts/install index d5ad9a6..97a16ca 100644 --- a/scripts/install +++ b/scripts/install @@ -39,10 +39,6 @@ ynh_app_setting_set --app="$app" --key=data_path --value="$data_path" ynh_app_setting_set --app="$app" --key=log_file --value="$log_file" ynh_app_setting_set --app="$app" --key=path_url --value="$path_url" -# grant sudo permissions to the user to manage his own systemd service -myynh_create_dir "/etc/sudoers.d" -ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app" - # create a dedicated system user ynh_script_progression --message="Creating dedicated user, rights and folders..." ynh_system_user_create --username="$app" @@ -78,6 +74,11 @@ cp -r "../conf/homeassistant_conf_files/." "$data_path/.$app/" chown -R $app: "$data_path/.$app" chmod -R +x "$data_path/.$app/bin/" +# grant sudo permissions to the user to manage his own systemd service +myynh_create_dir "/etc/sudoers.d" +ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app" +chown -R root: "/etc/sudoers.d/$app" + # setup up systemd service ynh_script_progression --message="Adding the dedicated service..." ynh_replace_string --match_string="__DATAPATH__" --replace_string="$data_path" --target_file="../conf/systemd.service" diff --git a/scripts/upgrade b/scripts/upgrade index 1aead03..bfce734 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,10 +42,6 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then } 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" @@ -92,6 +88,11 @@ ynh_replace_string --match_string="__DATAPATH__" --replace_string="$data_path" - ynh_replace_string --match_string="__LOGFILE__" --replace_string="$log_file" --target_file="../conf/systemd.service" ynh_add_systemd_config +# 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" +chown -R root: "/etc/sudoers.d/$app" + # add service in admin panel yunohost service add "$app" --log "$log_file" --description "Home Assistant server" --needs_exposed_ports $port