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
Éric Gaspar 4bae195eca Upgrade to V.1.1.14 (#29)
* Upgrade to v. 1.1.14

* Fix linter warnings

* Small typos

Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
2021-04-11 17:28:37 +02:00

78 lines
2.5 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
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
ynh_system_user_exists --username=$ssh_user && ynh_die --message="This user already exists"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_save_args ssh_user public_key quota
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
install_borg_with_pip
#=================================================
# CREATE SSH USER USED BY BORG
#=================================================
ynh_script_progression --message="Creat 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
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last