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

Apply example_ynh

This commit is contained in:
yalh76 2022-07-14 02:33:15 +02:00
parent 2e86319103
commit 9203985733
11 changed files with 131 additions and 36 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -9,7 +9,8 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
#upgrade=1 from_commit=CommitHash # 4.9.5~ynh2
upgrade=1 from_commit=2e86319103d3b6031c78d51245b06dd47327e0c4
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -6,7 +6,7 @@
"en": "App to share directories on your private network thanks to SMB protocol", "en": "App to share directories on your private network thanks to SMB protocol",
"fr": "Apllication pour partage des dossiers sur un reseaux privé via le protocole SMB" "fr": "Apllication pour partage des dossiers sur un reseaux privé via le protocole SMB"
}, },
"version": "4.9.5~ynh2", "version": "4.9.5~ynh3",
"url": "https://www.samba.org/", "url": "https://www.samba.org/",
"upstream": { "upstream": {
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
@ -29,7 +29,7 @@
"install": [ "install": [
{ {
"name": "warning", "name": "warning",
"type": "boolean", "type": "ask",
"help": { "help": {
"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.", "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 je ne dois pas l'installer sur un serveur avec une adresse IP publique ou ouvrir le port 445 sur mon routeur." "fr": "Je comprends que cette application est uniquement à des fins de réseau privé et je ne dois pas l'installer sur un serveur avec une adresse IP publique ou ouvrir le port 445 sur mon routeur."

View file

@ -23,17 +23,14 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
warning=$YNH_APP_ARG_WARNING warning=$YNH_APP_ARG_WARNING
final_path="/etc/samba"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
test $warning = "1" || ynh_die --message="You should validate the warning" ynh_script_progression --message="Validating installation parameters..."
#================================================= final_path="/etc/samba"
# STORE SETTINGS FROM MANIFEST
#================================================= test $warning = "1" || ynh_die --message="You should validate the warning"
ynh_script_progression --message="Storing installation settings..." --weight=1
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
@ -46,13 +43,15 @@ 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 ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -61,11 +60,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SETUP SSOWAT # SPECIFIC SETUP
#=================================================
ynh_permission_create --permission="share" --allowed=all_users
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
@ -99,12 +94,14 @@ ynh_add_config --template="share-smb.conf" --destination="$final_path/smb.conf.d
EOF EOF
cat $final_path/smb.conf.d/*.conf >> $final_path/smb.conf cat $final_path/smb.conf.d/*.conf >> $final_path/smb.conf
#================================================ #=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================ #=================================================
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" yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -114,6 +111,13 @@ ynh_script_progression --message="Starting a systemd service..." --weight=10
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=smbd --action="start" ynh_systemd_action --service_name=smbd --action="start"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
ynh_permission_create --permission="share" --allowed=all_users
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -16,8 +16,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE

View file

@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -37,12 +40,17 @@ unbrowseable=$(ynh_app_setting_get --app=$app --key=unbrowseable)
ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
#================================================= #=================================================
# FIND AND OPEN A PORT # STANDARD RESTORATION STEPS
#================================================= #=================================================
ynh_script_progression --message="Open 445 port..." --weight=1 # RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
@ -57,8 +65,6 @@ chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R root:root "$datadir" chown -R root:root "$datadir"
ynh_restore_file --origin_path="$final_path" --not_mandatory
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
@ -69,12 +75,20 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_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
#=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================ #=================================================
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" yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -19,6 +19,7 @@ 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)
@ -30,6 +31,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
@ -45,6 +47,11 @@ 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 # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -52,12 +59,14 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=12
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================ #=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================ #=================================================
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" yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -1,2 +0,0 @@
*~
*.sw[op]