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

Cleanup, use $data_dir

This commit is contained in:
Salamandar 2023-12-11 11:21:30 +01:00 committed by Salamandar
parent c6c7fe602d
commit d720fe3025
6 changed files with 61 additions and 68 deletions

View file

@ -1,16 +1,17 @@
#!/bin/bash
user_dir="$data_dir/$ssh_user"
#=================================================
# PACKAGE CHECK BYPASSING...
#=================================================
IS_PACKAGE_CHECK () {
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
then
return 0
else
return 1
fi
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
return 0
else
return 1
fi
}
#=================================================

View file

@ -25,7 +25,7 @@ ynh_backup --src_path="$install_dir"
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="/home/yunohost.app/ssh_chroot_directories/$ssh_user" --is_big
ynh_backup --src_path="$data_dir/$ssh_user" --is_big
#=================================================
# END OF SCRIPT

View file

@ -37,21 +37,10 @@ ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
mkdir -p "$data_dir/$ssh_user"
#=================================================
# SPECIFIC SETUP
#=================================================
# SOURCE LIBRARIES
#=================================================
# Load functions quotas_xxx
source "$install_dir/unix_quotas/unix_quotas.sh"
#=================================================
# CREATE DIRECTORY FOR THIS USER
#=================================================
mkdir "$data_dir/$ssh_user"
#=================================================
# INSTALL QUOTAS SYSTEM
#=================================================
@ -59,7 +48,10 @@ ynh_script_progression --message="Install quotas system" --weight=3
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
quotas_install
(
source "$install_dir/unix_quotas/unix_quotas.sh"
quotas_install
)
fi
#=================================================
@ -70,11 +62,15 @@ ynh_script_progression --message="Configure fstab to support quotas" --weight=3
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
# Set fstab
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
(
source "$install_dir/unix_quotas/unix_quotas.sh"
# Activate quotas
quotas_activate "$quotas_mount_point"
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
)
fi
#=================================================
@ -101,7 +97,7 @@ fi
# ADD A LINK TO CHROOT_MANAGER
#=================================================
ln -sf "$install_dir/chroot_manager.sh" /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf "$install_dir/chroot_manager.sh" "$data_dir/chroot_manager"
#=================================================
# GENERIC FINALIZATION

View file

@ -11,27 +11,22 @@ source /usr/share/yunohost/helpers
#=================================================
# SPECIFIC REMOVE
#=================================================
# SOURCE LIBRARIES
#=================================================
# Load functions quotas_xxx
source "$install_dir/unix_quotas/unix_quotas.sh"
#=================================================
# REMOVE QUOTAS OPTIONS IN FSTAB
#=================================================
ynh_script_progression --message="Remove quotas options in fstab" --weight=3
user_dir="/home/yunohost.app/ssh_chroot_directories/$ssh_user"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_clean_fstab "$quotas_mount_point"
(
source "$install_dir/unix_quotas/unix_quotas.sh"
# Deactivate quotas
quotas_deactivate "$quotas_mount_point"
quotas_find_mount_point "$user_dir"
quotas_clean_fstab "$quotas_mount_point"
# Deactivate quotas
quotas_deactivate "$quotas_mount_point"
)
fi
#=================================================
@ -40,7 +35,7 @@ fi
ynh_script_progression --message="Remove the user with Chroot_manager" --weight=3
if ! IS_PACKAGE_CHECK; then
"$install_dir/chroot_manager.sh" deluser --name $ssh_user
"$install_dir/chroot_manager.sh" deluser --name "$ssh_user"
fi
#=================================================
@ -49,7 +44,7 @@ fi
# DISCLAIMER
#=================================================
ynh_print_info --message="The directory /home/yunohost.app/ssh_chroot_directories hasn't been removed."
ynh_print_info --message="The directory $data_dir hasn't been removed."
#=================================================
# END OF SCRIPT

View file

@ -24,17 +24,10 @@ ynh_restore_file --origin_path="$install_dir"
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="/home/yunohost.app/ssh_chroot_directories/$ssh_user" --not_mandatory
ynh_restore_file --origin_path="$data_dir/$ssh_user" --not_mandatory
#=================================================
# SPECIFIC RESTORATION
#=================================================
# SOURCE LIBRARIES
#=================================================
# Load functions ssh_chroot_xxx
source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
# INSTALL QUOTAS SYSTEM
#=================================================
@ -42,7 +35,11 @@ ynh_script_progression --message="Install quotas system" --weight=3
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
quotas_install
(
source "$install_dir/unix_quotas/unix_quotas.sh"
quotas_install
)
fi
#=================================================
@ -53,11 +50,15 @@ ynh_script_progression --message="Configure fstab to support quotas" --weight=3
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
# Set fstab
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
(
source "$install_dir/unix_quotas/unix_quotas.sh"
# Activate quotas
quotas_activate "$quotas_mount_point"
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
)
fi
#=================================================
@ -65,29 +66,31 @@ fi
#=================================================
ynh_script_progression --message="Update the chroot directory" --weight=3
user_dir="/home/yunohost.app/ssh_chroot_directories/$ssh_user"
# 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
(
source "$install_dir/ssh_chroot/ssh_chroot.sh"
# Allow the user to use ssh
adduser $ssh_user ssh.app
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"
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 /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf "$install_dir/chroot_manager.sh" "$data_dir/chroot_manager"
#=================================================
# SECURE FILES AND DIRECTORIES

View file

@ -44,8 +44,6 @@ source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
ynh_script_progression --message="Update the chroot directory" --weight=3
user_dir="/home/yunohost.app/ssh_chroot_directories/$ssh_user"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
# Build the chroot
ssh_chroot_set_directory "$user_dir"
@ -67,7 +65,7 @@ fi
# UPDATE THE LINK TO CHROOT_MANAGER
#=================================================
ln -sf $install_dir/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf $install_dir/chroot_manager.sh "$data_dir/chroot_manager"
# Set permissions to app files
chown -R root: $install_dir