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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 03:03:22 +02:00 committed by Alexandre Aubin
parent 86908f9e96
commit 113f347967
7 changed files with 40 additions and 99 deletions

View file

@ -16,7 +16,8 @@ license = "GPL-3.0"
code = "https://github.com/maniackcrudelis/ssh_chroot"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = "not_relevant"

View file

@ -7,7 +7,7 @@ user_dir="$data_dir/$ssh_user"
#=================================================
IS_PACKAGE_CHECK () {
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
if ynh_in_ci_tests; then
return 0
else
return 1
@ -17,7 +17,3 @@ IS_PACKAGE_CHECK () {
#=================================================
# FUTUR OFFICIAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -1,34 +1,25 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir/$ssh_user" --is_big
ynh_backup "$data_dir/$ssh_user"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,24 +1,18 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
ynh_script_progression "Validating installation parameters..."
# Correct user name
# An unix user name can contains only :alnum: and . - _
# Replace all other characters by _
ssh_user=${ssh_user//[^[:alnum:].\-_]/_}
ynh_app_setting_set --app="$app" --key=ssh_user --value="$ssh_user"
ynh_app_setting_set --key=ssh_user --value="$ssh_user"
if ynh_system_user_exists "$ssh_user"; then
ynh_die "This user already exist!"
@ -28,12 +22,10 @@ if test -z "$password" && test -z "$pub_key"; then
ynh_die "You can't left empty both password and public key. Please fill at least one of them."
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir"
@ -44,7 +36,7 @@ mkdir -p "$data_dir/$ssh_user"
#=================================================
# INSTALL QUOTAS SYSTEM
#=================================================
ynh_script_progression --message="Install quotas system" --weight=3
ynh_script_progression "Install quotas system"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
@ -57,7 +49,7 @@ fi
#=================================================
# CONFIGURE FSTAB TO SUPPORT QUOTAS
#=================================================
ynh_script_progression --message="Configure fstab to support quotas" --weight=3
ynh_script_progression "Configure fstab to support quotas"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
# Set fstab
@ -76,7 +68,7 @@ fi
#=================================================
# CREATE THE USER WITH CHROOT_MANAGER
#=================================================
ynh_script_progression --message="Create the user with Chroot_manager" --weight=5
ynh_script_progression "Create the user with Chroot_manager"
chroot_manager_args=()
@ -99,15 +91,12 @@ fi
ln -sf "$install_dir/chroot_manager.sh" "$data_dir/chroot_manager"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root: "$install_dir"
#=================================================
# DISCLAIMER
#=================================================
@ -122,7 +111,7 @@ fi
#=================================================
# Not really settings, but required for POST_INSTALL.md
ynh_app_setting_set --app="$app" --key="domain" --value="$(yunohost domain list --json | jq -r '.["main"]')"
ynh_app_setting_set --app="$app" --key="ssh_port" --value="$(grep "^Port " /etc/ssh/sshd_config | awk '{print $2}')"
ynh_app_setting_set --key="domain" --value="$(yunohost domain list --json | jq -r '.["main"]')"
ynh_app_setting_set --key="ssh_port" --value="$(grep "^Port " /etc/ssh/sshd_config | awk '{print $2}')"
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -14,7 +8,7 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE QUOTAS OPTIONS IN FSTAB
#=================================================
ynh_script_progression --message="Remove quotas options in fstab" --weight=3
ynh_script_progression "Remove quotas options in fstab"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
@ -32,22 +26,20 @@ fi
#=================================================
# REMOVE THE USER WITH CHROOT_MANAGER
#=================================================
ynh_script_progression --message="Remove the user with Chroot_manager" --weight=3
ynh_script_progression "Remove the user with Chroot_manager"
if ! IS_PACKAGE_CHECK; then
"$install_dir/chroot_manager.sh" deluser --name "$ssh_user"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# DISCLAIMER
#=================================================
ynh_print_info --message="The directory $data_dir hasn't been removed."
ynh_print_info "The directory $data_dir hasn't been removed."
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -15,23 +9,23 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
ynh_restore "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir/$ssh_user" --not_mandatory
ynh_restore "$data_dir/$ssh_user" || true
#=================================================
# SPECIFIC RESTORATION
#=================================================
# INSTALL QUOTAS SYSTEM
#=================================================
ynh_script_progression --message="Install quotas system" --weight=3
ynh_script_progression "Install quotas system"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
if ! IS_PACKAGE_CHECK; then
@ -45,7 +39,7 @@ fi
#=================================================
# CONFIGURE FSTAB TO SUPPORT QUOTAS
#=================================================
ynh_script_progression --message="Configure fstab to support quotas" --weight=3
ynh_script_progression "Configure fstab to support quotas"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/unix_quotas/unix_quotas.sh
# Set fstab
@ -64,7 +58,7 @@ fi
#=================================================
# UPDATE THE CHROOT DIRECTORY
#=================================================
ynh_script_progression --message="Update the chroot directory" --weight=3
ynh_script_progression "Update the chroot directory"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
# Build the chroot
@ -97,17 +91,13 @@ ln -sf "$install_dir/chroot_manager.sh" "$data_dir/chroot_manager"
#=================================================
# Set permissions to app files
chown -R root: $install_dir
#=================================================
# GENERIC FINALIZATION
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root: $install_dir
#=================================================
# END OF SCRIPT
#=================================================
# Not really settings, but required for POST_INSTALL.md
ynh_app_setting_set --app="$app" --key="domain" --value="$(yunohost domain list --json | jq -r '.["main"]')"
ynh_app_setting_set --app="$app" --key="ssh_port" --value="$(grep "^Port " /etc/ssh/sshd_config | awk '{print $2}')"
ynh_app_setting_set --key="domain" --value="$(yunohost domain list --json | jq -r '.["main"]')"
ynh_app_setting_set --key="ssh_port" --value="$(grep "^Port " /etc/ssh/sshd_config | awk '{print $2}')"
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,37 +1,23 @@
#!/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
ynh_script_progression "Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SOURCE LIBRARIES
#=================================================
@ -42,7 +28,7 @@ source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
# UPDATE THE CHROOT DIRECTORY
#=================================================
ynh_script_progression --message="Update the chroot directory" --weight=3
ynh_script_progression "Update the chroot directory"
# https://github.com/maniackcrudelis/ssh_chroot/blob/master/ssh_chroot/ssh_chroot.sh
# Build the chroot
@ -68,19 +54,15 @@ fi
ln -sf $install_dir/chroot_manager.sh "$data_dir/chroot_manager"
# Set permissions to app files
chown -R root: $install_dir
#=================================================
# GENERIC FINALIZATION
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root: $install_dir
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $install_dir
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root: $install_dir
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"