1
0
Fork 0
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:
ljf 2021-03-04 17:07:37 +01:00
parent 5f3085aae3
commit d41defe761
9 changed files with 40 additions and 41 deletions

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
app=$1
# Adapt this script to different API 2.x vs 3.x # Adapt this script to different API 2.x vs 3.x
if yunohost -v | grep "version: 2." > /dev/null; then if yunohost -v | grep "version: 2." > /dev/null; then
ignore_apps="--ignore-apps" ignore_apps="--ignore-apps"
@ -14,34 +16,34 @@ filter_hooks() {
} }
# Backup system part conf # Backup system part conf
conf=$(yunohost app setting {{ app }} conf) conf=$(yunohost app setting $app conf)
if [ $conf -eq 1 ] if [ $conf -eq 1 ]
then 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 fi
# Backup system data # Backup system data
data=$(yunohost app setting {{ app }} data) data=$(yunohost app setting $app data)
if [ $data -eq 1 ] if [ $data -eq 1 ]
then 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 fi
# Backup all apps independently # Backup all apps independently
apps=$(yunohost app setting {{ app }} apps) apps=$(yunohost app setting $app apps)
for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do for application in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
backup_app=false backup_app=false
if [[ "$apps" = "all" ]]; then if [[ "$apps" = "all" ]]; then
backup_app=true backup_app=true
else else
for selected_app in $(echo $apps | tr "," " ");do for selected_app in $(echo $apps | tr "," " ");do
if [[ "$selected_app" == "$app" ]]; then if [[ "$selected_app" == "$application" ]]; then
backup_app=true backup_app=true
break break
fi fi
done done
fi fi
if [ "$backup_app" == "true" ];then 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 fi
done done

View file

@ -2,13 +2,13 @@
set -e set -e
BORG_PASSPHRASE="{{ passphrase }}" BORG_PASSPHRASE='__PASSPHRASE__'
if ssh-keygen -F "{{ server }}" >/dev/null ; then repo="__REPOSITORY__" #$4
BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=yes " if ssh-keygen -F "__SERVER__" >/dev/null ; then
BORG_RSH="ssh -i /root/.ssh/id___APP___ed25519 -oStrictHostKeyChecking=yes "
else else
BORG_RSH="ssh -i /root/.ssh/id_{{ app }}_ed25519 -oStrictHostKeyChecking=no " BORG_RSH="ssh -i /root/.ssh/id___APP___ed25519 -oStrictHostKeyChecking=no "
fi fi
repo="{{ repository }}" #$4
do_need_mount() { do_need_mount() {
true true

View file

@ -4,7 +4,7 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/local/bin/backup-with-__APP__ ExecStart=/usr/local/bin/backup-with-__APP__ __APP__
User=root User=root
Group=root Group=root

8
conf/systemd.timer Normal file
View file

@ -0,0 +1,8 @@
[Unit]
Description=Run backup __APP__ regularly
[Timer]
OnCalendar=__ON_CALENDAR__
[Install]
WantedBy=timers.target

View file

@ -1,8 +0,0 @@
[Unit]
Description=Run backup {{ app }} regularly
[Timer]
OnCalendar={{ on_calendar }}
[Install]
WantedBy=timers.target

View file

@ -51,20 +51,12 @@ ynh_save_args () {
if [ "$var" == "path_url" ]; then if [ "$var" == "path_url" ]; then
setting_var="path" setting_var="path"
fi fi
ynh_app_setting_set $app $setting_var ${!var} ynh_app_setting_set $app $setting_var "${!var}"
done 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 # Send an email to inform the administrator
# #
# usage: ynh_send_readme_to_admin app_message [recipients] # usage: ynh_send_readme_to_admin app_message [recipients]

View file

@ -44,6 +44,7 @@ ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
install_borg_with_pip install_borg_with_pip
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
@ -56,11 +57,11 @@ mkdir -p /usr/share/yunohost/backup_method
#================================================= #=================================================
# SETUP THE 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" 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" chmod u+x "/usr/local/bin/backup-with-$app"
if [ ! -z "$server" ]; then if [ ! -z "$server" ]; then
@ -109,7 +110,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# CONFIGURE SYSTEMD TIMER # 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 enable $app.timer --quiet
systemctl start $app.timer systemctl start $app.timer

View file

@ -50,16 +50,19 @@ ynh_restore
yunohost service add $app yunohost service add $app
systemctl enable $app.timer --quiet systemctl enable $app.timer --quiet
systemctl start $app.timer systemctl start $app.timer
#yunohost service add $app.timer
#yunohost service enable $app.timer
#yunohost service start $app.timer
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
systemctl enable $app.service --quiet 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 # END OF SCRIPT
#================================================= #=================================================

View file

@ -96,10 +96,11 @@ install_borg_with_pip
# SETUP THE BACKUP METHOD # SETUP THE BACKUP METHOD
#================================================= #=================================================
ynh_script_progression --message="Setting up backup method..." --weight=1 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" 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" chmod u+x "/usr/local/bin/backup-with-$app"
#================================================= #=================================================
@ -113,7 +114,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# CONFIGURE SYSTEMD TIMER # 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 enable $app.timer --quiet
systemctl start $app.timer systemctl start $app.timer