mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
58 lines
2.1 KiB
Bash
Executable file
58 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
#=================================================
|
|
# Here is a small hack to avoid multi install CI test to fail due
|
|
# to same ssh_user provided
|
|
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] && [[ "$YNH_APP_INSTANCE_NUMBER" != "1" ]] ; then
|
|
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
|
|
fi
|
|
|
|
ynh_system_user_exists --username="$ssh_user" && ynh_die --message="This user already exists"
|
|
|
|
#=================================================
|
|
# INSTALL BORG
|
|
#=================================================
|
|
ynh_script_progression --message="Installing Borg..."
|
|
|
|
install_borg_with_pip
|
|
|
|
#=================================================
|
|
# AUTORIZE SSH FOR THIS USER
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring user and SSH public key for remote connexion..."
|
|
|
|
ynh_system_user_create --username="$ssh_user" --home_dir="/home/$ssh_user" --use_shell --groups ssh.app
|
|
mkdir -p "/home/$ssh_user"
|
|
chmod 700 "/home/$ssh_user"
|
|
chown "$ssh_user" "/home/$ssh_user"
|
|
|
|
# Tweak to prevent the backup of the backup itself
|
|
touch "/home/$ssh_user/.nobackup"
|
|
|
|
create_ssh_config "/home/$ssh_user/.ssh" "/home/$ssh_user/backup"
|
|
|
|
#=================================================
|
|
# SETUP CRON
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring cron to monitor backup..."
|
|
|
|
ynh_add_config --template="monitor-backup.cron" --destination="/etc/cron.d/$app"
|
|
ynh_add_config --template="monitor-backup.sh" --destination="$install_dir/monitor-backup.sh"
|
|
chmod +x "$install_dir/monitor-backup.sh"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|