mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
[fix] Support more char in passphrase
This commit is contained in:
parent
5f3085aae3
commit
d41defe761
9 changed files with 40 additions and 41 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=$1
|
||||
|
||||
# Adapt this script to different API 2.x vs 3.x
|
||||
if yunohost -v | grep "version: 2." > /dev/null; then
|
||||
ignore_apps="--ignore-apps"
|
||||
|
@ -14,34 +16,34 @@ filter_hooks() {
|
|||
}
|
||||
|
||||
# Backup system part conf
|
||||
conf=$(yunohost app setting {{ app }} conf)
|
||||
conf=$(yunohost app setting $app conf)
|
||||
if [ $conf -eq 1 ]
|
||||
then
|
||||
yunohost backup create $ignore_apps -n auto_conf --method {{ app }}_app --system $(filter_hooks conf)
|
||||
yunohost backup create $ignore_apps -n auto_conf --method $app_app --system $(filter_hooks conf)
|
||||
fi
|
||||
|
||||
# Backup system data
|
||||
data=$(yunohost app setting {{ app }} data)
|
||||
data=$(yunohost app setting $app data)
|
||||
if [ $data -eq 1 ]
|
||||
then
|
||||
yunohost backup create $ignore_apps -n auto_data --method {{ app }}_app --system $(filter_hooks data)
|
||||
yunohost backup create $ignore_apps -n auto_data --method $app_app --system $(filter_hooks data)
|
||||
fi
|
||||
|
||||
# Backup all apps independently
|
||||
apps=$(yunohost app setting {{ app }} apps)
|
||||
for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
|
||||
apps=$(yunohost app setting $app apps)
|
||||
for application in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
|
||||
backup_app=false
|
||||
if [[ "$apps" = "all" ]]; then
|
||||
backup_app=true
|
||||
else
|
||||
for selected_app in $(echo $apps | tr "," " ");do
|
||||
if [[ "$selected_app" == "$app" ]]; then
|
||||
if [[ "$selected_app" == "$application" ]]; then
|
||||
backup_app=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$backup_app" == "true" ];then
|
||||
yunohost backup create $ignore_system -n auto_$app --method {{ app }}_app --apps $app
|
||||
yunohost backup create $ignore_system -n auto_$application --method $app_app --apps $app
|
||||
fi
|
||||
done
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
set -e
|
||||
|
||||
BORG_PASSPHRASE="{{ passphrase }}"
|
||||
if ssh-keygen -F "{{ server }}" >/dev/null ; then
|
||||
BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=yes "
|
||||
BORG_PASSPHRASE='__PASSPHRASE__'
|
||||
repo="__REPOSITORY__" #$4
|
||||
if ssh-keygen -F "__SERVER__" >/dev/null ; then
|
||||
BORG_RSH="ssh -i /root/.ssh/id___APP___ed25519 -oStrictHostKeyChecking=yes "
|
||||
else
|
||||
BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=no "
|
||||
BORG_RSH="ssh -i /root/.ssh/id___APP___ed25519 -oStrictHostKeyChecking=no "
|
||||
fi
|
||||
repo="{{ repository }}" #$4
|
||||
|
||||
do_need_mount() {
|
||||
true
|
|
@ -4,7 +4,7 @@ After=network.target
|
|||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/backup-with-__APP__
|
||||
ExecStart=/usr/local/bin/backup-with-__APP__ __APP__
|
||||
User=root
|
||||
Group=root
|
||||
|
||||
|
|
8
conf/systemd.timer
Normal file
8
conf/systemd.timer
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Run backup __APP__ regularly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=__ON_CALENDAR__
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -1,8 +0,0 @@
|
|||
[Unit]
|
||||
Description=Run backup {{ app }} regularly
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ on_calendar }}
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -51,20 +51,12 @@ ynh_save_args () {
|
|||
if [ "$var" == "path_url" ]; then
|
||||
setting_var="path"
|
||||
fi
|
||||
ynh_app_setting_set $app $setting_var ${!var}
|
||||
ynh_app_setting_set $app $setting_var "${!var}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
ynh_configure () {
|
||||
ynh_backup_if_checksum_is_different $2
|
||||
ynh_render_template "${PKG_DIR}/conf/$1.j2" "$2"
|
||||
ynh_store_file_checksum $2
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Send an email to inform the administrator
|
||||
#
|
||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||
|
|
|
@ -44,6 +44,7 @@ ynh_script_progression --message="Installing dependencies..."
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
install_borg_with_pip
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -56,11 +57,11 @@ mkdir -p /usr/share/yunohost/backup_method
|
|||
#=================================================
|
||||
# SETUP THE BACKUP METHOD
|
||||
#=================================================
|
||||
ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
|
||||
ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app"
|
||||
ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
|
||||
if [ ! -z "$server" ]; then
|
||||
|
@ -109,7 +110,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# CONFIGURE SYSTEMD TIMER
|
||||
#=================================================
|
||||
ynh_configure systemd.timer "/etc/systemd/system/$app.timer"
|
||||
ynh_add_config --template="systemd.timer" --destination="/etc/systemd/system/$app.timer"
|
||||
systemctl enable $app.timer --quiet
|
||||
systemctl start $app.timer
|
||||
|
||||
|
|
|
@ -50,16 +50,19 @@ ynh_restore
|
|||
yunohost service add $app
|
||||
systemctl enable $app.timer --quiet
|
||||
systemctl start $app.timer
|
||||
#yunohost service add $app.timer
|
||||
#yunohost service enable $app.timer
|
||||
#yunohost service start $app.timer
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Deduplicating backup program"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -96,10 +96,11 @@ install_borg_with_pip
|
|||
# SETUP THE BACKUP METHOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up backup method..." --weight=1
|
||||
ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_add_config --template="backup_method" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app"
|
||||
|
||||
ynh_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
|
||||
#=================================================
|
||||
|
@ -113,7 +114,7 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
# CONFIGURE SYSTEMD TIMER
|
||||
#=================================================
|
||||
ynh_configure systemd.timer "/etc/systemd/system/$app.timer"
|
||||
ynh_add_config --template="systemd.timer" --destination="/etc/systemd/system/$app.timer"
|
||||
systemctl enable $app.timer --quiet
|
||||
systemctl start $app.timer
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue