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:
parent
c1c1213e8e
commit
88bbd43e81
6 changed files with 18 additions and 0 deletions
5
conf/sudoers
Normal file
5
conf/sudoers
Normal 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
|
|
@ -20,4 +20,5 @@ home_path="/home/$app"
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
ynh_backup "$home_path"
|
ynh_backup "$home_path"
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
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 "/etc/systemd/system/$app@$app.service"
|
||||||
|
|
|
@ -36,6 +36,10 @@ ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
||||||
# create a dedicated system user
|
# create a dedicated system user
|
||||||
ynh_system_user_create $app
|
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
|
# create a directory for the installation of Home Assistant
|
||||||
myynh_create_dir "$final_path"
|
myynh_create_dir "$final_path"
|
||||||
chown $app: "$final_path"
|
chown $app: "$final_path"
|
||||||
|
|
|
@ -42,3 +42,6 @@ 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 "$app"
|
||||||
|
|
||||||
|
# remove sudoers file
|
||||||
|
ynh_secure_remove "/etc/sudoers.d/$app"
|
||||||
|
|
|
@ -33,6 +33,7 @@ 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 "/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 "/etc/systemd/system/$app@$app.service"
|
||||||
|
|
||||||
# restore source
|
# restore source
|
||||||
|
|
|
@ -23,6 +23,10 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
||||||
}
|
}
|
||||||
fi
|
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
|
# add required packages
|
||||||
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue