mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
Move /opt/borg-env, /usr/local/bin/borg,backup-with-app to install_dir
This commit is contained in:
parent
838574f3ea
commit
ea3f6e3492
8 changed files with 19 additions and 42 deletions
|
@ -1 +1 @@
|
|||
__APP__ ALL=(root) NOPASSWD: /usr/local/bin/backup-with-__APP__, /usr/local/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test
|
||||
__APP__ ALL=(root) NOPASSWD: __INSTALL_DIR__/backup-with-__APP__, __INSTALL_DIR__/venv/bin/borg, /usr/bin/yunohost backup create *, /usr/bin/yunohost app setting *, /bin/ls, /usr/bin/test
|
||||
|
|
|
@ -4,7 +4,7 @@ After=network.target
|
|||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/sudo /usr/local/bin/backup-with-__APP__ __APP__
|
||||
ExecStart=/usr/bin/sudo __INSTALL_DIR__/backup-with-__APP__ __APP__
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
|
||||
|
|
|
@ -8,26 +8,14 @@
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Install borg with pip if borg is not here
|
||||
install_borg_with_pip () {
|
||||
BORG_VERSION=$(ynh_app_upstream_version)
|
||||
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
|
||||
venvpy="$install_dir/venv/bin/python3"
|
||||
|
||||
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
|
||||
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"
|
||||
}
|
||||
|
||||
_gen_and_save_public_key() {
|
||||
|
|
|
@ -17,7 +17,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
ynh_backup --src_path="/etc/systemd/system/$app.timer"
|
||||
|
||||
ynh_backup --src_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_backup --src_path="/usr/local/bin/backup-with-$app"
|
||||
ynh_backup --src_path="/etc/sudoers.d/$app"
|
||||
|
||||
ynh_backup --src_path="/root/.ssh/id_${app}_ed25519" --not_mandatory
|
||||
|
|
|
@ -61,9 +61,9 @@ mkdir -p /usr/share/yunohost/backup_method
|
|||
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_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
chown $app:$app "/usr/local/bin/backup-with-$app"
|
||||
ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app"
|
||||
chmod u+x "$install_dir/backup-with-$app"
|
||||
chown "$app:$app" "$install_dir/backup-with-$app"
|
||||
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
|
|
|
@ -29,16 +29,8 @@ systemctl disable $app.timer --quiet
|
|||
ynh_remove_systemd_config
|
||||
|
||||
ynh_secure_remove "/etc/systemd/system/$app.timer"
|
||||
ynh_secure_remove "/usr/local/bin/backup-with-$app"
|
||||
ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
# 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_script_progression --message="Removing borg..." --weight=1
|
||||
ynh_secure_remove "/opt/borg-env"
|
||||
ynh_secure_remove "/usr/local/bin/borg"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -34,10 +34,6 @@ mkdir -p /usr/share/yunohost/backup_method
|
|||
ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
ynh_restore_file --origin_path="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
chown $app:$app "/usr/local/bin/backup-with-$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
|
||||
|
|
|
@ -54,9 +54,11 @@ fi
|
|||
# Replace backports with pip
|
||||
[ ! -e " /etc/apt/sources.list.d/$app-stretch-backports.list" ] || rm -f /etc/apt/sources.list.d/$app-stretch-backports.list
|
||||
|
||||
# Reinstall borg if debian change of major version
|
||||
if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then
|
||||
ynh_secure_remove /opt/borg-env
|
||||
# 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-$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -84,9 +86,9 @@ mkdir -p /usr/share/yunohost/backup_method
|
|||
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_add_config --template="backup-with-borg" --destination="/usr/local/bin/backup-with-$app"
|
||||
chmod u+x "/usr/local/bin/backup-with-$app"
|
||||
chown $app:$app "/usr/local/bin/backup-with-$app"
|
||||
ynh_add_config --template="backup-with-borg" --destination="$install_dir/backup-with-$app"
|
||||
chmod u+x "$install_dir/backup-with-$app"
|
||||
chown "$app:$app" "$install_dir/backup-with-$app"
|
||||
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
|
|
Loading…
Add table
Reference in a new issue