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

Grant user to manage its own systemd service

This commit is contained in:
ewilly 2018-12-18 07:30:30 +01:00
parent c1c1213e8e
commit 88bbd43e81
6 changed files with 18 additions and 0 deletions

5
conf/sudoers Normal file
View file

@ -0,0 +1,5 @@
# Grant sudo permissions to the user to manage his own systemd service
homeassistant ALL=(ALL) NOPASSWD: /bin/systemctl stop homeassistant@homeassistant.service
homeassistant ALL=(ALL) NOPASSWD: /bin/systemctl start homeassistant@homeassistant.service
homeassistant ALL=(ALL) NOPASSWD: /bin/systemctl restart homeassistant@homeassistant.service
homeassistant ALL=(ALL) NOPASSWD: /bin/systemctl status homeassistant@homeassistant.service

View file

@ -20,4 +20,5 @@ home_path="/home/$app"
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"

View file

@ -36,6 +36,10 @@ ynh_exec_fully_quiet yunohost firewall allow TCP $port
# create a dedicated system user
ynh_system_user_create $app
# grant sudo permissions to the user to manage his own systemd service
myynh_create_dir "/etc/sudoers.d"
cp "../sudoers" "/etc/sudoers.d/$app"
# create a directory for the installation of Home Assistant
myynh_create_dir "$final_path"
chown $app: "$final_path"

View file

@ -42,3 +42,6 @@ ynh_exec_fully_quiet yunohost firewall disallow TCP $port
# delete a system user
ynh_system_user_delete "$app"
# remove sudoers file
ynh_secure_remove "/etc/sudoers.d/$app"

View file

@ -33,6 +33,7 @@ ynh_system_user_create "$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"
# restore source

View file

@ -23,6 +23,10 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
}
fi
# grant sudo permissions to the user to manage his own systemd service
myynh_create_dir "/etc/sudoers.d"
cp "../sudoers" "/etc/sudoers.d/$app"
# add required packages
ynh_install_app_dependencies "$PKG_DEPENDENCIES"