1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh.git synced 2024-09-03 20:26:26 +02:00
ssh_chroot_dir_ynh/scripts/upgrade

86 lines
2.5 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SOURCE LIBRARIES
#=================================================
# Load functions ssh_chroot_xxx
source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
# UPDATE THE CHROOT DIRECTORY
#=================================================
ynh_script_progression --message="Update the chroot directory" --weight=3
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
# Build the chroot
ssh_chroot_set_directory "$user_dir"
# Copy some binaries in the chroot
ssh_chroot_standard_binaries "$user_dir"
ssh_chroot_copy_binary rsync "$user_dir"
# Set permissions
if ! IS_PACKAGE_CHECK
then
ssh_chroot_set_permissions "$user_dir" $ssh_user
# Allow the user to use ssh
adduser $ssh_user ssh.app
fi
#=================================================
# UPDATE THE LINK TO CHROOT_MANAGER
#=================================================
ln -sf $install_dir/chroot_manager.sh "$data_dir/chroot_manager"
# Set permissions to app files
chown -R root: $install_dir
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $install_dir
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last