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 #23 from YunoHost-Apps/testing

Testing
This commit is contained in:
eric_G 2024-05-20 15:17:50 +02:00 committed by GitHub
commit 6b748631a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 200 additions and 69 deletions

View file

@ -1,6 +1,8 @@
# All available README files by language # All available README files by language
- [Read the README in English](README.md) - [Read the README in English](README.md)
- [Lee el README en español](README_es.md)
- [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md) - [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md) - [Le o README en galego](README_gl.md)
- [Leggi il “README” in italiano](README_it.md) - [阅读中文(简体)的 README](README_zh_Hans.md)

View file

@ -9,7 +9,7 @@ It shall NOT be edited by hand.
[![Install Samba with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=samba) [![Install Samba with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=samba)
*[Read this README is other languages.](./ALL_README.md)* *[Read this README in other languages.](./ALL_README.md)*
> *This package allows you to install Samba quickly and simply on a YunoHost server.* > *This package allows you to install Samba quickly and simply on a YunoHost server.*
> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* > *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*

49
README_es.md Normal file
View file

@ -0,0 +1,49 @@
<!--
Este archivo README esta generado automaticamente<https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
No se debe editar a mano.
-->
# Samba para Yunohost
[![Nivel de integración](https://dash.yunohost.org/integration/samba.svg)](https://dash.yunohost.org/appci/app/samba) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/samba.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/samba.maintain.svg)
[![Instalar Samba con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=samba)
*[Leer este README en otros idiomas.](./ALL_README.md)*
> *Este paquete le permite instalarSamba rapidamente y simplement en un servidor YunoHost.*
> *Si no tiene YunoHost, visita [the guide](https://yunohost.org/install) para aprender como instalarla.*
## Descripción general
This package allows you to create directories reachable on a private network.
### Features
- Create and name your directories;
- Configure permissions for your directories thanks to the yunohost permission view;
- Define readonly directories
**Versión actual:** 4.13.13~ynh2
## Documentaciones y recursos
- Sitio web oficial: <https://www.samba.org/>
- Documentación administrador oficial: <https://www.samba.org/samba/docs/>
- Repositorio del código fuente oficial de la aplicación : <https://git.samba.org/?p=samba.git;a=summary>
- Catálogo YunoHost: <https://apps.yunohost.org/app/samba>
- Reportar un error: <https://github.com/YunoHost-Apps/samba_ynh/issues>
## Información para desarrolladores
Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/samba_ynh/tree/testing
Para probar la rama `testing`, sigue asÍ:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
o
sudo yunohost app upgrade samba -u https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
```
**Mas informaciones sobre el empaquetado de aplicaciones:** <https://yunohost.org/packaging_apps>

49
README_eu.md Normal file
View file

@ -0,0 +1,49 @@
<!--
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
EZ editatu eskuz.
-->
# Samba YunoHost-erako
[![Integrazio maila](https://dash.yunohost.org/integration/samba.svg)](https://dash.yunohost.org/appci/app/samba) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/samba.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/samba.maintain.svg)
[![Instalatu Samba YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=samba)
*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
> *Pakete honek Samba YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
## Aurreikuspena
This package allows you to create directories reachable on a private network.
### Features
- Create and name your directories;
- Configure permissions for your directories thanks to the yunohost permission view;
- Define readonly directories
**Paketatutako bertsioa:** 4.13.13~ynh2
## Dokumentazioa eta baliabideak
- Aplikazioaren webgune ofiziala: <https://www.samba.org/>
- Administratzaileen dokumentazio ofiziala: <https://www.samba.org/samba/docs/>
- Jatorrizko aplikazioaren kode-gordailua: <https://git.samba.org/?p=samba.git;a=summary>
- YunoHost Denda: <https://apps.yunohost.org/app/samba>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/samba_ynh/issues>
## Garatzaileentzako informazioa
Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/samba_ynh/tree/testing).
`testing` abarra probatzeko, ondorengoa egin:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
edo
sudo yunohost app upgrade samba -u https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
```
**Informazio gehiago aplikazioaren paketatzeari buruz:** <https://yunohost.org/packaging_apps>

49
README_zh_Hans.md Normal file
View file

@ -0,0 +1,49 @@
<!--
注意:此 README 由 <https://github.com/YunoHost/apps/tree/master/tools/readme_generator> 自动生成
请勿手动编辑。
-->
# YunoHost 上的 Samba
[![集成程度](https://dash.yunohost.org/integration/samba.svg)](https://dash.yunohost.org/appci/app/samba) ![工作状态](https://ci-apps.yunohost.org/ci/badges/samba.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/samba.maintain.svg)
[![使用 YunoHost 安装 Samba](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=samba)
*[阅读此 README 的其它语言版本。](./ALL_README.md)*
> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Samba。*
> *如果您还没有 YunoHost请参阅[指南](https://yunohost.org/install)了解如何安装它。*
## 概况
This package allows you to create directories reachable on a private network.
### Features
- Create and name your directories;
- Configure permissions for your directories thanks to the yunohost permission view;
- Define readonly directories
**分发版本:** 4.13.13~ynh2
## 文档与资源
- 官方应用网站: <https://www.samba.org/>
- 官方管理文档: <https://www.samba.org/samba/docs/>
- 上游应用代码库: <https://git.samba.org/?p=samba.git;a=summary>
- YunoHost 商店: <https://apps.yunohost.org/app/samba>
- 报告 bug <https://github.com/YunoHost-Apps/samba_ynh/issues>
## 开发者信息
请向 [`testing` 分支](https://github.com/YunoHost-Apps/samba_ynh/tree/testing) 发送拉取请求。
如要尝试 `testing` 分支,请这样操作:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
sudo yunohost app upgrade samba -u https://github.com/YunoHost-Apps/samba_ynh/tree/testing --debug
```
**有关应用打包的更多信息:** <https://yunohost.org/packaging_apps>

View file

@ -2,7 +2,7 @@ version = "1.0"
[main] [main]
name = "shared directory" name = "shared directory"
services = ["samba"] services = ["smbd"]
[main.main] [main.main]
name = "" name = ""

View file

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
echo "${YNH_USER_PASSWORD} echo "${YNH_USER_PASSWORD}
${YNH_USER_PASSWORD} ${YNH_USER_PASSWORD}
" | sudo smbpasswd -a $YNH_USER_USERNAME " | smbpasswd -a $YNH_USER_USERNAME

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
user=$1 pdbedit -x -u $1

View file

@ -2,5 +2,5 @@
echo "${YNH_USER_PASSWORD} echo "${YNH_USER_PASSWORD}
${YNH_USER_PASSWORD} ${YNH_USER_PASSWORD}
" | sudo smbpasswd -a $YNH_USER_USERNAME " | smbpasswd -a $YNH_USER_USERNAME

View file

@ -18,40 +18,30 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors ynh_abort_if_errors
datadir=$(ynh_app_setting_get --app=$app --key=datadir) data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY # recreate the smb.conf from smb.conf.d
#================================================= #=================================================
get__readonly_dir() { write_smb_conf() {
local directories=$(ynh_app_setting_get $app directories) cat > $install_dir/smb.conf <<EOF
if [[ "$directories" == "" ]] # =================================================
then # DO NOT EDIT THIS FILE
echo "choices: []" # EDIT SUBPARTS IN /etc/samba/smb.conf.d
else # =================================================
echo "choices:"
for directory in $(echo $directories | sed "s/,/ /g") EOF
do cat $install_dir/smb.conf.d/*.conf >> $install_dir/smb.conf
echo " $directory: $directory"
done
fi
} }
get__unbrowseable() {
get__readonly_dir
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#================================================= #=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS # SPECIFIC SETTERS FOR TOML SHORT KEYS
#================================================= #=================================================
set__directories() { set__directories() {
mkdir -p $final_path/smb.conf.d mkdir -p $install_dir/smb.conf.d
#--------------------------------------------- #---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected # IMPORTANT: setter are trigger only if a change is detected
@ -64,20 +54,20 @@ set__directories() {
fi fi
# Create the directory # Create the directory
mkdir -p $datadir/$directory mkdir -p $data_dir/$directory
chmod 750 "$datadir/$directory" chmod 750 "$data_dir/$directory"
chmod -R o-rwx "$datadir/$directory" chmod -R o-rwx "$data_dir/$directory"
chown -R root:root "$datadir/$directory" chown -R root:root "$data_dir/$directory"
setfacl -R -m g:samba.$directory:rwx,d:g:samba.$directory:rwx $datadir/$directory setfacl -R -m g:samba.$directory:rwx,d:g:samba.$directory:rwx $data_dir/$directory
# Add the configuration in /etc/samba/smb.conf.d/ if its missing
# Add the configuration in /etc/samba/smb.conf if needed if [ ! -f "$install_dir/smb.conf.d/$directory.conf" ]; then
cat > $final_path/smb.conf.d/$directory.conf <<END cat > $install_dir/smb.conf.d/$directory.conf <<END
[$directory] [$directory]
comment = $directory comment = $directory
read only = no read only = no
path = $datadir/$directory path = $data_dir/$directory
guest ok = no guest ok = no
browsable = yes browsable = yes
valid users = @samba.$directory valid users = @samba.$directory
@ -88,58 +78,51 @@ set__directories() {
recycle:keeptree = yes recycle:keeptree = yes
recycle:versions = yes recycle:versions = yes
END END
fi
done done
# Remove configuration for unlisted directories # Remove configuration for unlisted directories
pushd $final_path/smb.conf.d for directory in $(find $install_dir/smb.conf.d/ -maxdepth 1 -type f -not -name '0-global.conf' -exec basename {} \;); do
for $directory in $(ls !(0-global).conf) if ! [[ "${directory%.conf}" =~ $(echo "^($(echo $directories | sed 's/,\| /|/g'))$") ]]; then
do ynh_secure_remove "$install_dir/smb.conf.d/$directory"
if ! [[ "${directory%.conf}" =~ $(echo "^($(echo $directories | sed s/ /|/g))$") ]]; then
ynh_secure_remove "$final_path/smb.conf.d/"
fi fi
done done
popd
cat > $final_path/smb.conf <<EOF write_smb_conf
# =================================================
# DO NOT EDIT THIS FILE
# EDIT SUBPARTS IN /etc/samba/smb.conf.d
# =================================================
EOF
cat $final_path/smb.conf.d/*.conf >> $final_path/smb.conf
#--------------------------------------------- #---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too # IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#--------------------------------------------- #---------------------------------------------
ynh_app_setting_set $app directories $directories ynh_app_setting_set $app directories "$directories"
} }
set__readonly_dir() { set__readonly_dir() {
local value local value
for directory in $directories; do for directory in $(echo $directories | sed "s/,/ /g"); do
value="no" value="no"
if [[ $directory =~ $(echo "^($(echo $readonly_dir | sed s/ /|/g))$") ]]; then if [[ -n "$readonly_dir" && $directory =~ $(echo "^($(echo $readonly_dir | sed 's/,\| /|/g'))$") ]]; then
value="yes" value="yes"
fi fi
ynh_write_var_in_file --file=$final_path/smb.conf.d/$directory.conf --key="read only" --value="$value" ynh_write_var_in_file --file=$install_dir/smb.conf.d/$directory.conf --key=read[[:space:]]only --value="$value"
done done
ynh_app_setting_set $app readonly_dir $readonly_dir ynh_app_setting_set $app readonly_dir "$readonly_dir"
write_smb_conf
} }
set__unbrowseable() { set__unbrowseable() {
local value local value
for directory in $directories; do for directory in $(echo $directories | sed "s/,/ /g"); do
value="yes" value="yes"
if [[ $directory =~ $(echo "^($(echo $unbrowseable | sed s/ /|/g))$") ]]; then if [[ -n "$unbrowseable" && $directory =~ $(echo "^($(echo $unbrowseable | sed 's/,\| /|/g'))$") ]]; then
value="no" value="no"
fi fi
ynh_write_var_in_file --file=$final_path/smb.conf.d/$directory.conf --key="browsable" --value="$value" ynh_write_var_in_file --file=$install_dir/smb.conf.d/$directory.conf --key="browsable" --value="$value"
done done
ynh_app_setting_set $app unbrowseable $unbrowseable ynh_app_setting_set $app unbrowseable "$unbrowseable"
write_smb_conf
} }
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=directories --value=shared ynh_app_setting_set --app=$app --key=directories --value=share
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=''