mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
commit
954857339f
20 changed files with 206 additions and 122 deletions
|
@ -6,4 +6,5 @@
|
|||
- [Lire le README en français](README_fr.md)
|
||||
- [Le o README en galego](README_gl.md)
|
||||
- [Baca README dalam bahasa bahasa Indonesia](README_id.md)
|
||||
- [Прочитать README на русский](README_ru.md)
|
||||
- [阅读中文(简体)的 README](README_zh_Hans.md)
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Shipped version:** 1.2.8~ynh1
|
||||
**Shipped version:** 1.2.8~ynh3
|
||||
## Documentation and resources
|
||||
|
||||
- Official app website: <https://www.borgbackup.org/>
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Versión actual:** 1.2.8~ynh1
|
||||
**Versión actual:** 1.2.8~ynh3
|
||||
## Documentaciones y recursos
|
||||
|
||||
- Sitio web oficial: <https://www.borgbackup.org/>
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Paketatutako bertsioa:** 1.2.8~ynh1
|
||||
**Paketatutako bertsioa:** 1.2.8~ynh3
|
||||
## Dokumentazioa eta baliabideak
|
||||
|
||||
- Aplikazioaren webgune ofiziala: <https://www.borgbackup.org/>
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Version incluse :** 1.2.8~ynh1
|
||||
**Version incluse :** 1.2.8~ynh3
|
||||
## Documentations et ressources
|
||||
|
||||
- Site officiel de l’app : <https://www.borgbackup.org/>
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Versión proporcionada:** 1.2.8~ynh1
|
||||
**Versión proporcionada:** 1.2.8~ynh3
|
||||
## Documentación e recursos
|
||||
|
||||
- Web oficial da app: <https://www.borgbackup.org/>
|
||||
|
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Versi terkirim:** 1.2.8~ynh1
|
||||
**Versi terkirim:** 1.2.8~ynh3
|
||||
## Dokumentasi dan sumber daya
|
||||
|
||||
- Website aplikasi resmi: <https://www.borgbackup.org/>
|
||||
|
|
45
README_ru.md
Normal file
45
README_ru.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
Важно: этот README был автоматически сгенерирован <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
|
||||
Он НЕ ДОЛЖЕН редактироваться вручную.
|
||||
-->
|
||||
|
||||
# Borg Server для YunoHost
|
||||
|
||||
[](https://ci-apps.yunohost.org/ci/apps/borgserver/)  
|
||||
|
||||
[](https://install-app.yunohost.org/?app=borgserver)
|
||||
|
||||
*[Прочтите этот README на других языках.](./ALL_README.md)*
|
||||
|
||||
> *Этот пакет позволяет Вам установить Borg Server быстро и просто на YunoHost-сервер.*
|
||||
> *Если у Вас нет YunoHost, пожалуйста, посмотрите [инструкцию](https://yunohost.org/install), чтобы узнать, как установить его.*
|
||||
|
||||
## Обзор
|
||||
|
||||
Setup a storage space to be used for backup using Borg
|
||||
|
||||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**Поставляемая версия:** 1.2.8~ynh3
|
||||
## Документация и ресурсы
|
||||
|
||||
- Официальный веб-сайт приложения: <https://www.borgbackup.org/>
|
||||
- Официальная документация администратора: <https://borgbackup.readthedocs.io/en/stable/>
|
||||
- Репозиторий кода главной ветки приложения: <https://github.com/borgbackup/borg>
|
||||
- Магазин YunoHost: <https://apps.yunohost.org/app/borgserver>
|
||||
- Сообщите об ошибке: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
|
||||
|
||||
## Информация для разработчиков
|
||||
|
||||
Пришлите Ваш запрос на слияние в [ветку `testing`](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
|
||||
|
||||
Чтобы попробовать ветку `testing`, пожалуйста, сделайте что-то вроде этого:
|
||||
|
||||
```bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
|
||||
или
|
||||
sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Больше информации о пакетировании приложений:** <https://yunohost.org/packaging_apps>
|
|
@ -21,7 +21,7 @@ Setup a storage space to be used for backup using Borg
|
|||
This app is the "server" part, meant to be installed on the machine providing the backup storage. It is designed to work in combination with the [borg 'client' app](https://apps.yunohost.org/app/borg) installed on a diffent machine.
|
||||
|
||||
|
||||
**分发版本:** 1.2.8~ynh1
|
||||
**分发版本:** 1.2.8~ynh3
|
||||
## 文档与资源
|
||||
|
||||
- 官方应用网站: <https://www.borgbackup.org/>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
0 9,20 * * * root : Monitor __SSH_USER__ backup ; ALERT_DELAY="$(grep '^alert_delay: ' /etc/yunohost/apps/__APP__/settings.yml | awk -F\' '{print $2}')"; [[ $(find /home/__SSH_USER__/backup/data -follow -mtime -${ALERT_DELAY} -ls | wc -l) > 0 ]] || ( echo "No file has been backuped in /home/__SSH_USER__ since ${ALERT_DELAY} days" | mail -s "[YNH] Backup missing : __SSH_USER__" $(grep '^alert_mails: ' /etc/yunohost/apps/__APP__/settings.yml | awk '{print $2}'))
|
2
conf/monitor-backup.cron
Normal file
2
conf/monitor-backup.cron
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Monitor __SSH_USER__ backup every day
|
||||
0 9,20 * * * root __INSTALL_DIR__/monitor-backup.sh
|
12
conf/monitor-backup.sh
Normal file
12
conf/monitor-backup.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ALERT_DELAY="$(grep '^alert_delay: ' /etc/yunohost/apps/__APP__/settings.yml | awk -F\' '{print $2}')"
|
||||
|
||||
|
||||
|
||||
if [[ $(find /home/__SSH_USER__/backup/data -follow -mtime -${ALERT_DELAY} -ls | wc -l) > 0 ]]; then
|
||||
:
|
||||
else
|
||||
echo "No file has been backuped in /home/__SSH_USER__ since ${ALERT_DELAY} days" \
|
||||
| mail -s "[YNH] Backup missing : __SSH_USER__" $(grep '^alert_mails: ' /etc/yunohost/apps/__APP__/settings.yml | awk '{print $2}')
|
||||
fi
|
|
@ -1,3 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||
|
||||
packaging_format = 2
|
||||
|
||||
id = "borgserver"
|
||||
|
@ -5,7 +7,7 @@ name = "Borg Server"
|
|||
description.en = "Offer backup storage to a friend"
|
||||
description.fr = "Offrez un espace de stockage à un⋅e ami⋅e"
|
||||
|
||||
version = "1.2.8~ynh1"
|
||||
version = "1.2.8~ynh3"
|
||||
|
||||
maintainers = ["ljf"]
|
||||
|
||||
|
@ -67,19 +69,23 @@ ram.runtime = "50M"
|
|||
autoupdate.strategy = "latest_github_release"
|
||||
autoupdate.upstream = "https://github.com/borgbackup/borg"
|
||||
|
||||
[resources.system_user]
|
||||
# Not really useful, but required for install_dir
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
|
||||
[resources.apt]
|
||||
packages = [
|
||||
"python3-pip",
|
||||
"python3-dev",
|
||||
"libacl1-dev",
|
||||
"libssl-dev",
|
||||
"liblz4-dev",
|
||||
"python3-jinja2",
|
||||
"python3-setuptools",
|
||||
"python3-venv",
|
||||
"virtualenv",
|
||||
"libacl1-dev",
|
||||
"libssl-dev",
|
||||
"liblz4-dev",
|
||||
"libfuse3-dev",
|
||||
"pkg-config",
|
||||
]
|
||||
|
|
|
@ -1,23 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
BORG_VERSION=1.2.8
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# Install borg with pip if borg is not here
|
||||
install_borg_with_pip () {
|
||||
if [ -d /opt/borg-env ]; then
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip list | grep "borgbackup *$BORG_VERSION" || ynh_secure_remove /opt/borg-env
|
||||
fi
|
||||
if [ ! -d /opt/borg-env ]; then
|
||||
python3 -m venv /opt/borg-env
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip install pip -U
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel -U
|
||||
ynh_print_info --message="Installing/compiling borg, this may take some time..."
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[pyfuse3]==$BORG_VERSION
|
||||
echo "#!/bin/bash
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg
|
||||
touch "/opt/borg-env/$(ynh_get_debian_release)"
|
||||
fi
|
||||
# We need this to be executable by other borg apps
|
||||
chmod a+x /usr/local/bin/borg
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
install_borg_with_pip() {
|
||||
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
|
||||
venvpy="$install_dir/venv/bin/python3"
|
||||
|
||||
ynh_exec_as "$app" "$venvpy" -m pip install --upgrade setuptools wheel
|
||||
|
||||
BORG_VERSION=$(ynh_app_upstream_version)
|
||||
ynh_exec_as "$app" "$venvpy" -m pip install borgbackup[pyfuse3]=="$BORG_VERSION"
|
||||
}
|
||||
|
||||
create_ssh_config() {
|
||||
ssh_dir=$1
|
||||
repository=$2
|
||||
extra=""
|
||||
if [[ -n "$quota" ]]; then
|
||||
extra="--storage-quota $quota"
|
||||
fi
|
||||
command="borg serve $extra --restrict-to-repository $repository"
|
||||
ssh_opts="command=\"$command\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc"
|
||||
|
||||
mkdir -p "$ssh_dir"
|
||||
touch "$ssh_dir/authorized_keys"
|
||||
echo "$ssh_opts $public_key" >> "$ssh_dir/authorized_keys"
|
||||
|
||||
chown -R "$ssh_user:$ssh_user" "$ssh_dir"
|
||||
chmod -R u=rwX,go=--- "$ssh_dir"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,17 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_backup "/home/$ssh_user/.ssh"
|
||||
ynh_backup "/home/$ssh_user/.nobackup"
|
||||
ynh_backup "/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/home/$ssh_user/.ssh"
|
||||
ynh_backup --src_path="/home/$ssh_user/.nobackup"
|
||||
|
||||
ynh_print_info --message="Borg backup repo in /home/$ssh_user/ won't be backup to avoid backup of backup loop issue."
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -12,48 +12,44 @@ 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
|
||||
# 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"
|
||||
ynh_system_user_exists --username="$ssh_user" && ynh_die --message="This user already exists"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
# INSTALL BORG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
ynh_script_progression --message="Installing Borg..."
|
||||
|
||||
install_borg_with_pip
|
||||
|
||||
#=================================================
|
||||
# AUTORIZE SSH FOR THIS USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSH public key for remote connexion..."
|
||||
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
|
||||
|
||||
home=/home/$ssh_user
|
||||
mkdir -p $home/.ssh
|
||||
chmod o=--- $home
|
||||
chown -R $ssh_user:$ssh_user $home
|
||||
touch $home/.ssh/authorized_keys
|
||||
extra="--storage-quota $quota"
|
||||
if [ "$quota" = "" ]; then
|
||||
extra=""
|
||||
fi
|
||||
echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
|
||||
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/.nobackup
|
||||
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" --destination="/etc/cron.d/$app"
|
||||
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
|
||||
|
|
|
@ -9,24 +9,13 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove borg if we are removing the last borg app on the system
|
||||
if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then
|
||||
ynh_secure_remove "/opt/borg-env"
|
||||
ynh_secure_remove "/usr/local/bin/borg"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE USER BUT KEEP FILES
|
||||
#=================================================
|
||||
# We keep files cause we don't know what the user want to do about
|
||||
# backups stored in the home directory
|
||||
|
||||
ynh_system_user_delete --username=$ssh_user
|
||||
ynh_system_user_delete --username="$ssh_user"
|
||||
|
||||
#=================================================
|
||||
# REMOVE CRON FILES
|
||||
|
|
|
@ -10,35 +10,31 @@ source ../settings/scripts/_common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling borg env..."
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
install_borg_with_pip
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# CREATE SSH USER USED BY BORG
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure SSH user exists with appropriate permissions..."
|
||||
ynh_script_progression --message="Restoring the user and SSH configuration..." --weight=1
|
||||
|
||||
ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
|
||||
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"
|
||||
|
||||
home=/home/$ssh_user
|
||||
mkdir -p $home/.ssh
|
||||
chmod o=--- $home
|
||||
extra="--storage-quota $quota"
|
||||
if [ "$quota" = "" ]; then
|
||||
extra=""
|
||||
fi
|
||||
echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
|
||||
chown -R $ssh_user:$ssh_user $home
|
||||
ynh_restore_file --origin_path="/home/$ssh_user/.ssh"
|
||||
ynh_restore_file --origin_path="/home/$ssh_user/.nobackup"
|
||||
|
||||
# Tweak to prevent the backup of the backup itself
|
||||
touch $home/.nobackup
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
|
||||
# Actual restore of ...?
|
||||
ynh_restore
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -9,24 +9,25 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN UPGRADE IS NEEDED
|
||||
#=================================================
|
||||
|
||||
ynh_check_app_version_changed
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Remove legacy stuff
|
||||
if [ -f "/etc/apt/sources.list.d/$app-stretch-backports.list" ]; then
|
||||
rm -f /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
install_borg_with_pip
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$app-stretch-backports.list"
|
||||
fi
|
||||
|
||||
if [ -f "/etc/yunohost/hooks.d/backup/17-data_home" ]; then
|
||||
ynh_secure_remove /etc/yunohost/hooks.d/backup/17-data_home
|
||||
ynh_secure_remove "/etc/yunohost/hooks.d/backup/17-data_home"
|
||||
fi
|
||||
|
||||
# Clear legacy stuff
|
||||
if [ -d /opt/borg-env ]; then
|
||||
ynh_secure_remove --file="/opt/borg-env"
|
||||
ynh_secure_remove --file="/usr/local/bin/borg"
|
||||
ynh_secure_remove --file="/usr/local/bin/backup-with-borg"
|
||||
fi
|
||||
|
||||
# Fix broken value ssh_user that mistakenly got replaced by the public key in previous versions...
|
||||
|
@ -34,30 +35,23 @@ fi
|
|||
if echo "$ssh_user" | grep -q ' '; then
|
||||
ssh_user=$(grep "$ssh_user" /home/*/.ssh/authorized_keys | grep borg | cut -d/ -f3)
|
||||
[ -n "$ssh_user" ] || ynh_die "Unable to retrieve ssh_user please fix /etc/yunohost/apps/$app/settings.yml manually :( !"
|
||||
ynh_app_setting_set --app=$app --key=ssh_user --value="$ssh_user"
|
||||
ynh_app_setting_set --app="$app" --key=ssh_user --value="$ssh_user"
|
||||
fi
|
||||
|
||||
if echo "$public_key" | grep -q -v ' '; then
|
||||
ynh_app_setting_set --app=$app --key=public_key --value="$(grep -Po 'no-user-rc \K.*$' /home/$ssh_user/.ssh/authorized_keys)"
|
||||
ynh_app_setting_set --app="$app" --key=public_key --value="$(grep -Po 'no-user-rc \K.*$' "/home/$ssh_user/.ssh/authorized_keys")"
|
||||
fi
|
||||
|
||||
# Alert delay and alert mail missing
|
||||
if [ -z "${alert_delay:-}" ]; then
|
||||
ynh_app_setting_set --app=$app --key=alert_delay --value=1
|
||||
ynh_app_setting_set --app=$app --key=alert_mails --value="root"
|
||||
fi
|
||||
|
||||
# Reinstall borg if debian change of major version
|
||||
if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then
|
||||
ynh_secure_remove /opt/borg-env
|
||||
ynh_app_setting_set --app="$app" --key=alert_delay --value="1"
|
||||
ynh_app_setting_set --app="$app" --key=alert_mails --value="root"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
# UPGRADE BORG
|
||||
#=================================================
|
||||
# Upgrade borgbackup
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading borgbackup..." --weight=1
|
||||
ynh_script_progression --message="Upgrading Borg..." --weight=1
|
||||
|
||||
install_borg_with_pip
|
||||
|
||||
|
@ -66,27 +60,24 @@ install_borg_with_pip
|
|||
#=================================================
|
||||
ynh_script_progression --message="Making sure SSH user exists with appropriate permissions..."
|
||||
|
||||
ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
|
||||
|
||||
home=/home/$ssh_user
|
||||
mkdir -p $home/.ssh
|
||||
chmod o=--- $home
|
||||
extra="--storage-quota $quota"
|
||||
if [ "$quota" = "" ]; then
|
||||
extra=""
|
||||
fi
|
||||
echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
|
||||
chown -R $ssh_user:$ssh_user $home
|
||||
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/.nobackup
|
||||
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" --destination="/etc/cron.d/$app"
|
||||
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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
|
||||
|
||||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
@ -7,3 +9,5 @@ test_format = 1.0
|
|||
args.alert_delay = 1
|
||||
args.alert_mails = "sam@domain.tld"
|
||||
args.quota = "1G"
|
||||
|
||||
test_upgrade_from.4c8c3cabad44a45e7df0d8ddd61a87889a3d4fa3.name = "Before refactoring"
|
||||
|
|
Loading…
Add table
Reference in a new issue