1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/samba_ynh.git synced 2024-09-03 20:16:27 +02:00

Merge pull request #17 from YunoHost-Apps/version-2

Version 2
This commit is contained in:
Alexandre Aubin 2023-12-03 03:58:21 +01:00 committed by GitHub
commit b7d862164c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 269 deletions

View file

@ -31,7 +31,7 @@ This package allows you to create directories reachable on a private network.
* Official app website: <https://www.samba.org/> * Official app website: <https://www.samba.org/>
* Official admin documentation: <https://www.samba.org/samba/docs/> * Official admin documentation: <https://www.samba.org/samba/docs/>
* Upstream app code repository: <https://git.samba.org/?p=samba.git;a=summary> * Upstream app code repository: <https://git.samba.org/?p=samba.git;a=summary>
* YunoHost documentation for this app: <https://yunohost.org/app_samba> * YunoHost Store: <https://apps.yunohost.org/app/samba>
* Report a bug: <https://github.com/YunoHost-Apps/samba_ynh/issues> * Report a bug: <https://github.com/YunoHost-Apps/samba_ynh/issues>
## Developer info ## Developer info

View file

@ -31,7 +31,7 @@ This package allows you to create directories reachable on a private network.
* Site officiel de lapp : <https://www.samba.org/> * Site officiel de lapp : <https://www.samba.org/>
* Documentation officielle de ladmin : <https://www.samba.org/samba/docs/> * Documentation officielle de ladmin : <https://www.samba.org/samba/docs/>
* Dépôt de code officiel de lapp : <https://git.samba.org/?p=samba.git;a=summary> * Dépôt de code officiel de lapp : <https://git.samba.org/?p=samba.git;a=summary>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_samba> * YunoHost Store: <https://apps.yunohost.org/app/samba>
* Signaler un bug : <https://github.com/YunoHost-Apps/samba_ynh/issues> * Signaler un bug : <https://github.com/YunoHost-Apps/samba_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs

View file

@ -1,20 +0,0 @@
;; Test complet
; Manifest
warning=1
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=0
setup_public=0
upgrade=1
# 4.9.5~ynh2
upgrade=1 from_commit=2e86319103d3b6031c78d51245b06dd47327e0c4
backup_restore=1
multi_instance=0
port_already_use=0
change_url=0
;;; Options
Email=
Notification=none

1
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1 @@
I understand this app is only for private network purpose and i should not install it on a server with a public IP or open the 445 port on my home router.

1
doc/PRE_INSTALL_fr.md Normal file
View file

@ -0,0 +1 @@
Je comprends que cette application est uniquement à des fins de réseau privé et que je ne dois pas l'installer sur un serveur avec une adresse IP publique ou ouvrir le port 445 sur mon routeur.

View file

@ -1,38 +0,0 @@
{
"name": "Samba",
"id": "samba",
"packaging_format": 1,
"description": {
"en": "Share directories on your private network thanks to SMB protocol",
"fr": "Partager des dossiers sur un réseau privé via le protocole SMB"
},
"version": "4.13.13~ynh1",
"url": "https://www.samba.org/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://www.samba.org/",
"admindoc": "https://www.samba.org/samba/docs/",
"code": "https://git.samba.org/?p=samba.git;a=summary"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Galette"
},
"requirements": {
"yunohost": ">= 11.2"
},
"multi_instance": false,
"services": [],
"arguments": {
"install": [
{
"name": "warning",
"type": "display_text",
"ask": {
"en": "I understand this app is only for private network purpose and i should not install it on a server with a public IP or open the 445 port on my home router.",
"fr": "Je comprends que cette application est uniquement à des fins de réseau privé et que je ne dois pas l'installer sur un serveur avec une adresse IP publique ou ouvrir le port 445 sur mon routeur."
}
}
]
}
}

51
manifest.toml Normal file
View file

@ -0,0 +1,51 @@
packaging_format = 2
id = "samba"
name = "Samba"
description.en = "Share directories on your private network thanks to SMB protocol"
description.fr = "Partager des dossiers sur un réseau privé via le protocole SMB"
version = "4.13.13~ynh1"
maintainers = ["Galette"]
[upstream]
license = "AGPL-3.0-only"
website = "https://www.samba.org/"
admindoc = "https://www.samba.org/samba/docs/"
code = "https://git.samba.org/?p=samba.git;a=summary"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[resources]
[resources.system_user]
[resources.install_dir]
dir = "/etc/samba"
[resources.ports]
main.default = 445
main.exposed = "Both"
[resources.data_dir]
subdirs = ["share"]
[resources.permissions]
share.show_tile = false
share.allowed = "all_users"
[resources.apt]
packages = "samba"

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="samba"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -10,24 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# 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)
domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -37,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,26 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path="/etc/samba"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
@ -38,66 +18,34 @@ ynh_app_setting_set --app=$app --key=directories --value=shared
ynh_app_setting_set --app=$app --key=advanced --value=0 ynh_app_setting_set --app=$app --key=advanced --value=0
ynh_app_setting_set --app=$app --key=readonly_dir --value='' ynh_app_setting_set --app=$app --key=readonly_dir --value=''
ynh_app_setting_set --app=$app --key=unbrowseable --value='' ynh_app_setting_set --app=$app --key=unbrowseable --value=''
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# We define the permission in advance to be able to use the group
# in unix permission
ynh_permission_create --permission="share" --allowed=all_users
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1 ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/samba chmod 750 "$data_dir/share"
ynh_app_setting_set --app=samba --key=datadir --value=$datadir chmod -R o-rwx "$data_dir/share"
chown -R root:root "$data_dir/share"
mkdir -p $datadir/share setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $data_dir/share
chmod 750 "$datadir/share"
chmod -R o-rwx "$datadir/share"
chown -R root:root "$datadir/share"
setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $datadir/share
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
mkdir -p $final_path/smb.conf.d mkdir -p $install_dir/smb.conf.d
ynh_add_config --template="global-smb.conf" --destination="$final_path/smb.conf.d/0-global.conf" ynh_add_config --template="global-smb.conf" --destination="$install_dir/smb.conf.d/0-global.conf"
ynh_add_config --template="share-smb.conf" --destination="$final_path/smb.conf.d/share.conf" ynh_add_config --template="share-smb.conf" --destination="$install_dir/smb.conf.d/share.conf"
cat > $final_path/smb.conf <<EOF cat > $install_dir/smb.conf <<EOF
# ================================================= # =================================================
# DO NOT EDIT THIS FILE # DO NOT EDIT THIS FILE
# EDIT SUBPARTS IN /etc/samba/smb.conf.d # EDIT SUBPARTS IN /etc/samba/smb.conf.d
# ================================================= # =================================================
EOF EOF
cat $final_path/smb.conf.d/*.conf >> $final_path/smb.conf cat $install_dir/smb.conf.d/*.conf >> $install_dir/smb.conf
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -106,7 +54,7 @@ cat $final_path/smb.conf.d/*.conf >> $final_path/smb.conf
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445 yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -9,16 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# 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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -32,26 +22,6 @@ then
yunohost service remove smbd yunohost service remove smbd
fi fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=2
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=10
ynh_secure_remove --file="$datadir"
ynh_secure_remove --file="$final_path"
fi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,35 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
directories=$(ynh_app_setting_get --app=$app --key=directories)
advanced=$(ynh_app_setting_get --app=$app --key=advanced)
readonly_dir=$(ynh_app_setting_get --app=$app --key=readonly_dir)
unbrowseable=$(ynh_app_setting_get --app=$app --key=unbrowseable)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
@ -46,42 +17,18 @@ ynh_script_progression --message="Validating restoration parameters..." --weight
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chown -R root:root "$install_dir"
chmod -R o-rwx "$final_path"
chown -R root:root "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
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="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R root:root "$datadir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Open 445 port..." --weight=1
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
chown -R root:root "$data_dir"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
@ -89,7 +36,7 @@ ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here # Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445 yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -9,35 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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 () {
ynh_clean_check_starting
# 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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -47,18 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=4
ynh_systemd_action --service_name=smbd --action="stop" ynh_systemd_action --service_name=smbd --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=12
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -67,7 +32,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here # Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445 yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

7
tests.toml Normal file
View file

@ -0,0 +1,7 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------