2018-06-14 02:13:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2020-02-27 17:49:59 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
|
|
#=================================================
|
2024-08-12 13:03:41 +02:00
|
|
|
# Here is a small hack to avoid multi install CI test to fail due
|
2021-04-10 11:35:53 +02:00
|
|
|
# to same ssh_user provided
|
2023-12-04 21:31:34 +01:00
|
|
|
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] && [[ "$YNH_APP_INSTANCE_NUMBER" != "1" ]] ; then
|
2021-04-10 11:35:53 +02:00
|
|
|
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
|
|
|
|
fi
|
2023-12-04 21:31:34 +01:00
|
|
|
|
2024-08-12 13:03:41 +02:00
|
|
|
ynh_system_user_exists --username="$ssh_user" && ynh_die --message="This user already exists"
|
2020-02-27 17:49:59 +01:00
|
|
|
|
2018-08-31 01:11:12 +02:00
|
|
|
#=================================================
|
2024-08-12 13:03:41 +02:00
|
|
|
# INSTALL BORG
|
2018-06-14 02:13:59 +02:00
|
|
|
#=================================================
|
2024-08-12 13:03:41 +02:00
|
|
|
ynh_script_progression --message="Installing Borg..."
|
2021-01-11 00:36:16 +01:00
|
|
|
|
2019-05-21 17:05:24 +02:00
|
|
|
install_borg_with_pip
|
2018-06-14 02:13:59 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# AUTORIZE SSH FOR THIS USER
|
|
|
|
#=================================================
|
2024-08-12 13:03:41 +02:00
|
|
|
ynh_script_progression --message="Configuring user and SSH public key for remote connexion..."
|
2021-01-11 00:36:16 +01:00
|
|
|
|
2024-08-12 13:03:41 +02:00
|
|
|
ynh_system_user_create --username="$ssh_user" --home_dir="/home/$ssh_user" --use_shell --groups ssh.app
|
2021-01-11 00:36:16 +01:00
|
|
|
|
2023-12-04 20:31:10 +01:00
|
|
|
# Tweak to prevent the backup of the backup itself
|
2024-08-12 13:03:41 +02:00
|
|
|
touch "/home/$ssh_user/.nobackup"
|
|
|
|
|
|
|
|
create_ssh_config "/home/$ssh_user/.ssh" "/home/$ssh_user/backup"
|
2018-06-14 02:13:59 +02:00
|
|
|
|
2021-04-08 20:20:10 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP CRON
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring cron to monitor backup..."
|
2023-10-25 21:57:09 +02:00
|
|
|
|
2024-08-12 13:03:41 +02:00
|
|
|
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"
|
2021-04-08 20:20:10 +02:00
|
|
|
|
2021-01-11 00:36:16 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|