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:
parent
caa2d97288
commit
85e90e3e63
6 changed files with 61 additions and 68 deletions
|
@ -1,12 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
user_dir="$data_dir/$ssh_user"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PACKAGE CHECK BYPASSING...
|
# PACKAGE CHECK BYPASSING...
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
IS_PACKAGE_CHECK () {
|
IS_PACKAGE_CHECK () {
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
|
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
|
||||||
then
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -25,7 +25,7 @@ ynh_backup --src_path="$install_dir"
|
||||||
# BACKUP THE DATA 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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -37,21 +37,10 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
|
mkdir -p "$data_dir/$ssh_user"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# 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
|
# 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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/unix_quotas/unix_quotas.sh"
|
||||||
quotas_install
|
quotas_install
|
||||||
|
)
|
||||||
fi
|
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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
|
||||||
# Set fstab
|
# Set fstab
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/unix_quotas/unix_quotas.sh"
|
||||||
|
|
||||||
quotas_find_mount_point "$user_dir"
|
quotas_find_mount_point "$user_dir"
|
||||||
quotas_set_fstab "$quotas_mount_point"
|
quotas_set_fstab "$quotas_mount_point"
|
||||||
|
|
||||||
# Activate quotas
|
# Activate quotas
|
||||||
quotas_activate "$quotas_mount_point"
|
quotas_activate "$quotas_mount_point"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -101,7 +97,7 @@ fi
|
||||||
# ADD A LINK TO CHROOT_MANAGER
|
# 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
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -11,27 +11,22 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
|
||||||
# SOURCE LIBRARIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Load functions quotas_xxx
|
|
||||||
source "$install_dir/unix_quotas/unix_quotas.sh"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE QUOTAS OPTIONS IN FSTAB
|
# REMOVE QUOTAS OPTIONS IN FSTAB
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Remove quotas options in fstab" --weight=3
|
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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/unix_quotas/unix_quotas.sh"
|
||||||
|
|
||||||
quotas_find_mount_point "$user_dir"
|
quotas_find_mount_point "$user_dir"
|
||||||
quotas_clean_fstab "$quotas_mount_point"
|
quotas_clean_fstab "$quotas_mount_point"
|
||||||
|
|
||||||
# Deactivate quotas
|
# Deactivate quotas
|
||||||
quotas_deactivate "$quotas_mount_point"
|
quotas_deactivate "$quotas_mount_point"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -40,7 +35,7 @@ fi
|
||||||
ynh_script_progression --message="Remove the user with Chroot_manager" --weight=3
|
ynh_script_progression --message="Remove the user with Chroot_manager" --weight=3
|
||||||
|
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
"$install_dir/chroot_manager.sh" deluser --name $ssh_user
|
"$install_dir/chroot_manager.sh" deluser --name "$ssh_user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -49,7 +44,7 @@ fi
|
||||||
# DISCLAIMER
|
# 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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -24,17 +24,10 @@ ynh_restore_file --origin_path="$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
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
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
|
||||||
# SOURCE LIBRARIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Load functions ssh_chroot_xxx
|
|
||||||
source "$install_dir/ssh_chroot/ssh_chroot.sh"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL QUOTAS SYSTEM
|
# 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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/unix_quotas/unix_quotas.sh"
|
||||||
|
|
||||||
quotas_install
|
quotas_install
|
||||||
|
)
|
||||||
fi
|
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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
|
||||||
# Set fstab
|
# Set fstab
|
||||||
if ! IS_PACKAGE_CHECK; then
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/unix_quotas/unix_quotas.sh"
|
||||||
|
|
||||||
quotas_find_mount_point "$user_dir"
|
quotas_find_mount_point "$user_dir"
|
||||||
quotas_set_fstab "$quotas_mount_point"
|
quotas_set_fstab "$quotas_mount_point"
|
||||||
|
|
||||||
# Activate quotas
|
# Activate quotas
|
||||||
quotas_activate "$quotas_mount_point"
|
quotas_activate "$quotas_mount_point"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -65,29 +66,31 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Update the chroot directory" --weight=3
|
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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
|
||||||
# Build the chroot
|
# Build the chroot
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
if ! IS_PACKAGE_CHECK; then
|
||||||
|
(
|
||||||
|
source "$install_dir/ssh_chroot/ssh_chroot.sh"
|
||||||
|
|
||||||
ssh_chroot_set_directory "$user_dir"
|
ssh_chroot_set_directory "$user_dir"
|
||||||
|
|
||||||
# Copy some binaries in the chroot
|
# Copy some binaries in the chroot
|
||||||
ssh_chroot_standard_binaries "$user_dir"
|
ssh_chroot_standard_binaries "$user_dir"
|
||||||
ssh_chroot_copy_binary rsync "$user_dir"
|
ssh_chroot_copy_binary rsync "$user_dir"
|
||||||
|
|
||||||
# Set permissions
|
|
||||||
if ! IS_PACKAGE_CHECK; then
|
|
||||||
ssh_chroot_set_permissions "$user_dir" $ssh_user
|
ssh_chroot_set_permissions "$user_dir" $ssh_user
|
||||||
|
|
||||||
# Allow the user to use ssh
|
# Allow the user to use ssh
|
||||||
adduser $ssh_user ssh.app
|
adduser $ssh_user ssh.app
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE THE LINK TO CHROOT_MANAGER
|
# 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
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
|
|
@ -44,8 +44,6 @@ source "$install_dir/ssh_chroot/ssh_chroot.sh"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Update the chroot directory" --weight=3
|
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
|
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
|
||||||
# Build the chroot
|
# Build the chroot
|
||||||
ssh_chroot_set_directory "$user_dir"
|
ssh_chroot_set_directory "$user_dir"
|
||||||
|
@ -67,7 +65,7 @@ fi
|
||||||
# UPDATE THE LINK TO CHROOT_MANAGER
|
# 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
|
# Set permissions to app files
|
||||||
chown -R root: $install_dir
|
chown -R root: $install_dir
|
||||||
|
|
Loading…
Add table
Reference in a new issue