1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borgserver_ynh.git synced 2024-09-03 20:36:20 +02:00
borgserver_ynh/scripts/install

60 lines
1.9 KiB
Text
Raw Normal View History

#!/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
2018-06-21 17:08:18 +02:00
ynh_export ssh_user public_key quota
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2018-06-21 17:08:18 +02:00
ynh_save_args ssh_user public_key quota
2018-08-31 01:11:12 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies $pkg_dependencies
2019-05-21 17:05:24 +02:00
install_borg_with_pip
#=================================================
# CREATE SSH USER USED BY BORG
#=================================================
2018-06-21 15:38:59 +02:00
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
2018-06-21 17:08:18 +02:00
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