2018-06-14 02:13:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
|
|
|
# App package root directory should be the parent folder
|
|
|
|
PKG_DIR=$(cd ../; pwd)
|
2021-04-08 20:20:10 +02:00
|
|
|
BORG_VERSION=1.1.16
|
2018-06-14 02:13:59 +02:00
|
|
|
|
2021-04-08 20:20:10 +02:00
|
|
|
pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python3-jinja2 python3-setuptools python3-venv python-virtualenv virtualenv libfuse-dev pkg-config"
|
2018-06-14 02:13:59 +02:00
|
|
|
|
2019-05-21 17:05:24 +02:00
|
|
|
# Install borg with pip if borg is not here
|
|
|
|
install_borg_with_pip () {
|
2021-04-08 20:20:10 +02:00
|
|
|
if [ -d /opt/borg-env ]; then
|
|
|
|
/opt/borg-env/bin/python /opt/borg-env/bin/pip list | grep "Version: $BORG_VERSION" || ynh_secure_remove /opt/borg-env
|
|
|
|
fi
|
2019-05-21 17:05:24 +02:00
|
|
|
if [ ! -d /opt/borg-env ]; then
|
2021-01-11 00:34:05 +01:00
|
|
|
python3 -m venv /opt/borg-env
|
2021-04-08 20:20:10 +02:00
|
|
|
/opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel
|
2021-04-11 18:55:48 +02:00
|
|
|
ynh_print_info --message="Installing/compiling borg, this may take some time..."
|
2021-04-08 20:20:10 +02:00
|
|
|
/opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[fuse]==$BORG_VERSION
|
2019-05-21 17:05:24 +02:00
|
|
|
echo "#!/bin/bash
|
|
|
|
/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg
|
2021-04-08 20:20:10 +02:00
|
|
|
touch "/opt/borg-env/$(ynh_get_debian_release)"
|
2019-05-21 17:05:24 +02:00
|
|
|
fi
|
2021-04-08 20:20:10 +02:00
|
|
|
# We need this to be executable by other borg apps
|
|
|
|
chmod a+x /usr/local/bin/borg
|
2019-05-21 17:05:24 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 02:13:59 +02:00
|
|
|
#=================================================
|
|
|
|
# COMMON HELPERS
|
|
|
|
#=================================================
|
|
|
|
ynh_export () {
|
|
|
|
local ynh_arg=""
|
|
|
|
for var in $@;
|
|
|
|
do
|
2020-02-27 18:22:07 +01:00
|
|
|
ynh_arg=$(echo "$var" | awk '{print toupper($0)}')
|
2018-06-14 02:13:59 +02:00
|
|
|
if [ "$var" == "path_url" ]; then
|
|
|
|
ynh_arg="PATH"
|
|
|
|
fi
|
|
|
|
ynh_arg="YNH_APP_ARG_$ynh_arg"
|
2018-06-21 15:38:59 +02:00
|
|
|
export $var="${!ynh_arg}"
|
2018-06-14 02:13:59 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
# Save listed var in YunoHost app settings
|
|
|
|
# usage: ynh_save_args VARNAME1 [VARNAME2 [...]]
|
|
|
|
ynh_save_args () {
|
|
|
|
for var in $@;
|
|
|
|
do
|
|
|
|
local setting_var="$var"
|
|
|
|
if [ "$var" == "path_url" ]; then
|
|
|
|
setting_var="path"
|
|
|
|
fi
|
2020-02-27 18:22:07 +01:00
|
|
|
ynh_app_setting_set $app $setting_var "${!var}"
|
2018-06-14 02:13:59 +02:00
|
|
|
done
|
|
|
|
}
|