mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
60 lines
2 KiB
Text
60 lines
2 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
#=================================================
|
||
|
# GENERIC START
|
||
|
#=================================================
|
||
|
# IMPORT GENERIC HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
if [ ! -e _common.sh ]; then
|
||
|
# Get the _common.sh file if it's not in the current directory
|
||
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||
|
chmod a+rx _common.sh
|
||
|
fi
|
||
|
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
|
||
|
|
||
|
#=================================================
|
||
|
# LOAD SETTINGS
|
||
|
#=================================================
|
||
|
|
||
|
app=$YNH_APP_INSTANCE_NAME
|
||
|
|
||
|
export ssh_user=$(ynh_app_setting_get $app ssh_user)
|
||
|
export public_key=$(ynh_app_setting_get $app public_key)
|
||
|
|
||
|
#=================================================
|
||
|
# STORE SETTINGS FROM MANIFEST
|
||
|
#=================================================
|
||
|
ynh_install_app_dependencies $pkg_dependencies
|
||
|
pip3 install setuptools --upgrade
|
||
|
pip3 install borgbackup
|
||
|
|
||
|
#=================================================
|
||
|
# CREATE SSH USER USED BY BORG
|
||
|
#=================================================
|
||
|
adduser $ssh_user -s /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
|
||
|
echo "command=\"borg serve --restrict-to-path /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
|
||
|
|