mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
54 lines
1.8 KiB
Bash
54 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# COMMON VARIABLES
|
|
#=================================================
|
|
# App package root directory should be the parent folder
|
|
PKG_DIR=$(cd ../; pwd)
|
|
BORG_VERSION=1.2.6
|
|
|
|
# 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 wheel
|
|
ynh_print_info --message="Installing/compiling borg, this may take some time..."
|
|
/opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[fuse]==$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
|
|
}
|
|
|
|
#=================================================
|
|
# COMMON HELPERS
|
|
#=================================================
|
|
ynh_export () {
|
|
local ynh_arg=""
|
|
for var in $@;
|
|
do
|
|
ynh_arg=$(echo "$var" | awk '{print toupper($0)}')
|
|
if [ "$var" == "path" ]; then
|
|
ynh_arg="PATH"
|
|
fi
|
|
#REMOVEME? ynh_arg="YNH_APP_ARG_$ynh_arg"
|
|
export $var="${!ynh_arg}"
|
|
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" ]; then
|
|
setting_var="path"
|
|
fi
|
|
ynh_app_setting_set $app $setting_var "${!var}"
|
|
done
|
|
}
|