mirror of
https://github.com/YunoHost-Apps/samba_ynh.git
synced 2024-09-03 20:16:27 +02:00
100 lines
3.4 KiB
Bash
Executable file
100 lines
3.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
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
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
|
|
|
ynh_app_setting_set --app=$app --key=directory --value=shared
|
|
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=unbrowseable --value=''
|
|
|
|
#=================================================
|
|
# FIND AND OPEN A PORT
|
|
#=================================================
|
|
|
|
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
|
|
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
#=================================================
|
|
# CREATE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
|
|
|
datadir=/home/yunohost.app/samba
|
|
ynh_app_setting_set --app=samba --key=datadir --value=$datadir
|
|
|
|
mkdir -p $datadir/share
|
|
|
|
chmod 750 "$datadir/share"
|
|
chmod -R o-rwx "$datadir/share"
|
|
chown -R root:root "$datadir/share"
|
|
setfacl -R -m g:all_users:rwx,d:g:all_users:rwx $datadir/share
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
|
|
|
ynh_add_config --template="smb.conf" --destination="/etc/samba/smb.conf"
|
|
|
|
#================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#================================================
|
|
|
|
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name=smbd --action="start"
|
|
|
|
#=================================================
|
|
# SETUP SSOWAT
|
|
#=================================================
|
|
|
|
ynh_permission_create --permission="share" --allowed=all_users
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --time --last
|