mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
[fix] Run borg with a specific user
This commit is contained in:
parent
b083a7731b
commit
a95d8002d5
6 changed files with 17 additions and 6 deletions
1
conf/sudoer
Normal file
1
conf/sudoer
Normal file
|
@ -0,0 +1 @@
|
|||
__APP__ ALL=(root) /usr/local/bin/backup-with-__APP__, /usr/local/bin/borg
|
|
@ -4,9 +4,9 @@ After=network.target
|
|||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/backup-with-__APP__ __APP__
|
||||
User=root
|
||||
Group=root
|
||||
ExecStart=/usr/bin/sudo /usr/local/bin/backup-with-__APP__ __APP__
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
|
||||
#[Install]
|
||||
#WantedBy=multi-user.target
|
||||
|
|
|
@ -28,6 +28,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
ynh_backup "/usr/local/bin/backup-with-$app"
|
||||
ynh_backup "/etc/sudoers.d/$app"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.timer"
|
||||
ynh_backup "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
|
|
@ -46,6 +46,14 @@ ynh_script_progression --message="Installing dependencies..."
|
|||
ynh_install_app_dependencies $pkg_dependencies
|
||||
install_borg_with_pip
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -64,6 +72,7 @@ chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|||
|
||||
ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
|
||||
if [ ! -z "$server" ]; then
|
||||
#=================================================
|
||||
|
@ -103,7 +112,7 @@ fi
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
|
|
@ -47,7 +47,6 @@ ynh_restore
|
|||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
yunohost service add $app
|
||||
systemctl enable $app.timer --quiet
|
||||
systemctl start $app.timer
|
||||
|
||||
|
|
|
@ -97,10 +97,11 @@ ynh_script_progression --message="Setting up backup method..." --weight=1
|
|||
ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
|
||||
ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue