1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/samba_ynh.git synced 2024-09-03 20:16:27 +02:00
samba_ynh/scripts/install
2022-02-24 18:24:05 +01:00

93 lines
3.2 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
#=================================================
# 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"
ynh_add_config --template="post_user_create" --destination="/etc/yunohost/hooks.d/post_user_create/$app"
ynh_add_config --template="post_user_delete" --destination="/etc/yunohost/hooks.d/post_user_delete/$app"
ynh_add_config --template="post_user_update" --destination="/etc/yunohost/hooks.d/post_user_update/$app"
#================================================
# 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