mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
70 lines
2.3 KiB
Bash
Executable file
70 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
#REMOVEME? ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#REMOVEME? export ssh_user=$(ynh_app_setting_get $app ssh_user)
|
|
#REMOVEME? export public_key=$(ynh_app_setting_get $app public_key)
|
|
#REMOVEME? export quota=$(ynh_app_setting_get $app quota)
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
|
|
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
install_borg_with_pip
|
|
|
|
#=================================================
|
|
# CREATE SSH USER USED BY BORG
|
|
#=================================================
|
|
ynh_script_progression --message="Creating SSH user used by Borg..."
|
|
|
|
#REMOVEME? ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
|
|
|
|
#=================================================
|
|
# AUTORIZE SSH FOR THIS USER
|
|
#=================================================
|
|
|
|
home=/home/$ssh_user
|
|
mkdir -p /home/$ssh_user/.ssh
|
|
chmod o=--- /home/$ssh_user
|
|
chown -R $ssh_user:$ssh_user /home/$ssh_user
|
|
touch /home/$ssh_user/.ssh/authorized_keys
|
|
extra="--storage-quota $quota"
|
|
if [ "$quota" = "" ]; then
|
|
extra=""
|
|
fi
|
|
echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
|
|
|
|
#=================================================
|
|
# AVOID BACKUP OF BACKUP
|
|
#=================================================
|
|
|
|
touch $home/.nobackup
|
|
ynh_restore
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|