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

manifest v2

This commit is contained in:
Salamandar 2023-12-08 23:42:37 +01:00 committed by Salamandar
parent 117a8b2b0c
commit ffc4c16572
9 changed files with 130 additions and 281 deletions

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/maniackcrudelis/ssh_chroot/archive/v1.3.tar.gz
SOURCE_SUM=d44b51f8d838fc9f929e6048b825c8f74d52f6a254764527bce1ed4a4c558652
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,82 +0,0 @@
{
"name": "ssh chroot directory",
"id": "ssh_chroot_dir",
"packaging_format": 1,
"description": {
"en": "SSH chroot directories with quotas disk",
"fr": "Dossier SSH en chroot avec gestion de quotas"
},
"version": "1.3~ynh2",
"url": "https://github.com/maniackcrudelis/ssh_chroot",
"upstream": {
"license": "GPL-3.0",
"code": "https://github.com/maniackcrudelis/ssh_chroot"
},
"license": "GPL-3.0",
"maintainer": {
"name": "",
"email": ""
},
"previous_maintainers": [{
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": true,
"services": [
],
"arguments": {
"install": [
{
"name": "ssh_user",
"type": "string",
"ask": {
"en": "Choose an new user for this directory",
"fr": "Choisissez un nouvel utilisateur pour ce dossier"
},
"help": {
"en": "It must be a new user, it will be created for this purpose.",
"fr": "Ce doit être un nouvel utilisateur, il sera créé pour cet usage."
},
"example": "johndoe"
},
{
"name": "password",
"type": "password",
"help": {
"en": "OPTIONAL. It's better to use a public ssh key instead. See below.",
"fr": "OPTIONNEL. Il est préférable d'utiliser une clé publique. Voir ci-dessous."
},
"optional": true
},
{
"name": "pub_key",
"type": "string",
"ask": {
"en": "Give the public ssh key",
"fr": "Donnez une clé publique ssh"
},
"help": {
"en": "OPTIONAL. You can use a password instead, but a ssh public key is more secure. Ask to your beneficiary for his public key.",
"fr": "OPTIONNEL. Vous pouvez utiliser un mot de passe à la place, mais une clé ssh publique est plus sécurisée. Demandez à votre bénéficiaire sa clé publique."
},
"optional": true
},
{
"name": "size",
"type": "string",
"ask": {
"en": "Choose the maximum space allowed to this user",
"fr": "Choississez l'espace maximum à allouer à cet utilisateur"
},
"help": {
"en": "Default Ko, Use M, G or T to specified another unit.",
"fr": "Ko par défaut, utilisez M, G ou T pour indiquer une autre unité."
},
"default": "10G"
}
]
}
}

73
manifest.toml Normal file
View file

@ -0,0 +1,73 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "ssh_chroot_dir"
name = "ssh chroot directory"
description.en = "SSH chroot directories with quotas disk"
description.fr = "Dossier SSH en chroot avec gestion de quotas"
version = "1.3~ynh2"
maintainers = []
[upstream]
license = "GPL-3.0"
code = "https://github.com/maniackcrudelis/ssh_chroot"
[integration]
yunohost = ">= 11.0.9"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
sso = "not_relevant"
disk = "5M"
ram.build = "0M"
ram.runtime = "0M"
[install]
[install.ssh_user]
ask.en = "Choose a new user for this directory"
ask.fr = "Choisissez un nouvel utilisateur pour ce dossier"
help.en = "It must be a new user, it will be created for this purpose."
help.fr = "Ce doit être un nouvel utilisateur, il sera créé pour cet usage."
type = "string"
example = "johndoe"
[install.password]
# this is a generic question - ask strings are automatically handled by Yunohost's core
help.en = "OPTIONAL. It's better to use a public ssh key instead. See below."
help.fr = "OPTIONNEL. Il est préférable d'utiliser une clé publique. Voir ci-dessous."
type = "password"
optional = true
[install.pub_key]
ask.en = "Give the public ssh key"
ask.fr = "Donnez une clé publique ssh"
help.en = "OPTIONAL. You can use a password instead, but a ssh public key is more secure. Ask to your beneficiary for his public key."
help.fr = "OPTIONNEL. Vous pouvez utiliser un mot de passe à la place, mais une clé ssh publique est plus sécurisée. Demandez à votre bénéficiaire sa clé publique."
type = "string"
optional = true
[install.size]
ask.en = "Choose the maximum space allowed to this user"
ask.fr = "Choississez l'espace maximum à allouer à cet utilisateur"
help.en = "Default Ko, Use M, G or T to specified another unit."
help.fr = "Ko par défaut, utilisez M, G ou T pour indiquer une autre unité."
type = "string"
default = "10G"
[resources]
[resources.sources.main]
url = "https://github.com/maniackcrudelis/ssh_chroot/archive/v1.3.tar.gz"
sha256 = "d44b51f8d838fc9f929e6048b825c8f74d52f6a254764527bce1ed4a4c558652"
autoupdate.strategy = "latest_github_release"
autoupdate.asset = "*.tar.gz"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]

View file

@ -44,7 +44,7 @@ ynh_send_readme_to_admin() {
type="${type:-install}"
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
@ -212,7 +212,7 @@ ynh_app_changelog () {
sed -i '/Merge branch .* into/d' changelog
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# If a html email is required. Apply html to the changelog.

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR

View file

@ -9,27 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ssh_user=$YNH_APP_ARG_SSH_USER
password=${YNH_APP_ARG_PASSWORD:-}
pub_key=${YNH_APP_ARG_PUB_KEY:-}
size=$YNH_APP_ARG_SIZE
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@ -39,24 +18,15 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
# 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_system_user_exists $ssh_user && ynh_die "This user already exist"
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
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."
if ynh_system_user_exists "$ssh_user"; then
ynh_die "This user already exist!"
fi
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=ssh_user --value=$ssh_user
ynh_app_setting_set --app=$app --key=size --value=$size
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
@ -65,9 +35,7 @@ ynh_app_setting_set --app=$app --key=size --value=$size
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir"
#=================================================
# SPECIFIC SETUP
@ -76,14 +44,13 @@ ynh_setup_source --dest_dir="$final_path"
#=================================================
# Load functions quotas_xxx
source "$final_path/unix_quotas/unix_quotas.sh"
source "$install_dir/unix_quotas/unix_quotas.sh"
#=================================================
# CREATE DIRECTORY FOR THIS USER
#=================================================
user_dir="/home/yunohost.app/ssh_chroot_directories/$ssh_user"
mkdir -p "$user_dir"
mkdir "$data_dir/$ssh_user"
#=================================================
# INSTALL QUOTAS SYSTEM
@ -92,7 +59,7 @@ 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
quotas_install
fi
#=================================================
@ -102,13 +69,12 @@ 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"
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
fi
#=================================================
@ -116,34 +82,26 @@ fi
#=================================================
ynh_script_progression --message="Create the user with Chroot_manager" --weight=5
add_password=""
if [ -n "$password" ]
then
auth_opt="--password"
auth_value="$password"
chroot_manager_args=()
if [ -n "$pub_key" ]; then
chroot_manager_args+=( --sshkey "$pub_key" )
elif [ -n "$password" ]; then
chroot_manager_args+=( --password "$password" )
fi
add_sshkey=""
if [ -n "$pub_key" ]
then
ynh_app_setting_set $app pub_key $pub_key
auth_opt="--sshkey"
auth_value="$pub_key"
fi
if ! IS_PACKAGE_CHECK; then
"$install_dir/chroot_manager.sh" adduser --name "$ssh_user" "${chroot_manager_args[@]}" --directory "$user_dir" --quota "$size"
if ! IS_PACKAGE_CHECK
then
$final_path/chroot_manager.sh adduser --name $ssh_user $auth_opt "$auth_value" --directory "$user_dir" --quota $size
# Allow the user to use ssh
adduser $ssh_user ssh.app
# Allow the user to use ssh
adduser "$ssh_user" ssh.app
fi
#=================================================
# ADD A LINK TO CHROOT_MANAGER
#=================================================
ln -sf $final_path/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf "$install_dir/chroot_manager.sh" /home/yunohost.app/ssh_chroot_directories/chroot_manager
#=================================================
# GENERIC FINALIZATION
@ -152,7 +110,7 @@ ln -sf $final_path/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/c
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R root: "$install_dir"
#=================================================
# DISCLAIMER
@ -167,7 +125,7 @@ To use this directory, connect to 'ssh $ssh_user@$domain -p $ssh_port' via a ter
if grep --quiet "^AllowUsers" /etc/ssh/sshd_config
then
ynh_print_warn "
ynh_print_warn "
Be carreful, your ssh configuration contains an AllowUsers option. You should probably add the user $ssh_user to this line."
fi

View file

@ -9,16 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# SPECIFIC REMOVE
#=================================================
@ -26,7 +16,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# Load functions quotas_xxx
source "$final_path/unix_quotas/unix_quotas.sh"
source "$install_dir/unix_quotas/unix_quotas.sh"
#=================================================
# REMOVE QUOTAS OPTIONS IN FSTAB
@ -36,13 +26,12 @@ 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"
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_clean_fstab "$quotas_mount_point"
# Deactivate quotas
quotas_deactivate "$quotas_mount_point"
# Deactivate quotas
quotas_deactivate "$quotas_mount_point"
fi
#=================================================
@ -51,17 +40,9 @@ fi
ynh_script_progression --message="Remove the user with Chroot_manager" --weight=3
if ! IS_PACKAGE_CHECK; then
$final_path/chroot_manager.sh deluser --name $ssh_user
"$install_dir/chroot_manager.sh" deluser --name $ssh_user
fi
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Remove app main directory" --weight=1
# Remove the app directory securely
ynh_secure_remove "$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -10,34 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
@ -45,7 +17,7 @@ test ! -d $final_path \
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
@ -61,7 +33,7 @@ ynh_restore_file --origin_path="/home/yunohost.app/ssh_chroot_directories/$ssh_u
#=================================================
# Load functions ssh_chroot_xxx
source "$final_path/ssh_chroot/ssh_chroot.sh"
source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
# INSTALL QUOTAS SYSTEM
@ -70,7 +42,7 @@ 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
quotas_install
fi
#=================================================
@ -80,13 +52,12 @@ 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"
if ! IS_PACKAGE_CHECK; then
quotas_find_mount_point "$user_dir"
quotas_set_fstab "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
# Activate quotas
quotas_activate "$quotas_mount_point"
fi
#=================================================
@ -105,26 +76,25 @@ 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
if ! IS_PACKAGE_CHECK; then
ssh_chroot_set_permissions "$user_dir" $ssh_user
# Allow the user to use ssh
adduser $ssh_user ssh.app
# Allow the user to use ssh
adduser $ssh_user ssh.app
fi
#=================================================
# UPDATE THE LINK TO CHROOT_MANAGER
#=================================================
ln -sf $final_path/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf $install_dir/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R root: $install_dir
#=================================================
# GENERIC FINALIZATION

View file

@ -9,16 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK VERSION
#=================================================
@ -26,20 +16,6 @@ ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -51,7 +27,7 @@ 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="$final_path"
ynh_setup_source --dest_dir="$install_dir"
fi
#=================================================
@ -61,7 +37,7 @@ fi
#=================================================
# Load functions ssh_chroot_xxx
source "$final_path/ssh_chroot/ssh_chroot.sh"
source "$install_dir/ssh_chroot/ssh_chroot.sh"
#=================================================
# UPDATE THE CHROOT DIRECTORY
@ -91,10 +67,10 @@ fi
# UPDATE THE LINK TO CHROOT_MANAGER
#=================================================
ln -sf $final_path/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
ln -sf $install_dir/chroot_manager.sh /home/yunohost.app/ssh_chroot_directories/chroot_manager
# Set permissions to app files
chown -R root: $final_path
chown -R root: $install_dir
#=================================================
# GENERIC FINALIZATION
@ -103,7 +79,7 @@ chown -R root: $final_path
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R root: $install_dir
#=================================================
# SEND A README FOR THE ADMIN