mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
67 lines
2.2 KiB
Bash
Executable file
67 lines
2.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
export app=$YNH_APP_INSTANCE_NAME
|
|
|
|
# Retrieve arguments
|
|
ynh_export ssh_user public_key quota
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_save_args ssh_user public_key quota
|
|
|
|
#=================================================
|
|
# CONFIGURE BACKPORTS
|
|
#=================================================
|
|
# We need borg 1.1+ available only in backports
|
|
ynh_install_backports
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
ynh_package_install -t stretch-backports borgbackup
|
|
|
|
#=================================================
|
|
# CREATE SSH USER USED BY BORG
|
|
#=================================================
|
|
adduser $ssh_user --quiet --gecos ",,," --shell /bin/bash --disabled-password
|
|
|
|
#=================================================
|
|
# AUTORIZE SSH FOR THIS USER
|
|
#=================================================
|
|
home=/home/$ssh_user
|
|
mkdir -p /home/$ssh_user/.ssh
|
|
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
|
|
mkdir -p /etc/yunohost/hooks.d/backup
|
|
cp -f ../conf/17-data_home /etc/yunohost/hooks.d/backup/17-data_home
|
|
|