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

116 lines
4 KiB
Text
Raw Normal View History

2022-02-22 13:59:54 +01:00
#!/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
2022-02-27 20:22:27 +01:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2022-07-14 02:33:15 +02:00
ynh_script_progression --message="Validating installation parameters..."
2022-02-27 20:22:27 +01:00
2022-07-14 02:33:15 +02:00
final_path="/etc/samba"
2022-02-25 12:52:27 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Storing installation settings..." --weight=1
2022-02-25 12:52:27 +01:00
2022-02-25 17:05:34 +01:00
ynh_app_setting_set --app=$app --key=directories --value=shared
2022-02-25 12:52:27 +01:00
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=''
2022-02-27 20:07:04 +01:00
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
2022-02-25 12:52:27 +01:00
2022-07-14 02:33:15 +02:00
#=================================================
# STANDARD MODIFICATIONS
2022-02-22 13:59:54 +01:00
#=================================================
2022-02-22 17:45:17 +01:00
# FIND AND OPEN A PORT
2022-02-22 13:59:54 +01:00
#=================================================
2022-07-14 02:33:15 +02:00
ynh_script_progression --message="Configuring firewall..."
2022-02-22 13:59:54 +01:00
2022-02-22 17:45:17 +01:00
ynh_exec_warn_less yunohost firewall allow Both 445 --no-upnp
2022-02-22 13:59:54 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Installing dependencies..." --weight=10
2022-02-22 13:59:54 +01:00
ynh_install_app_dependencies $pkg_dependencies
2022-02-27 20:07:04 +01:00
#=================================================
2022-07-14 02:33:15 +02:00
# SPECIFIC SETUP
2022-02-22 13:59:54 +01:00
#=================================================
# CREATE DATA DIRECTORY
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Creating a data directory..." --weight=1
2022-02-22 13:59:54 +01:00
2022-02-22 17:45:17 +01:00
datadir=/home/yunohost.app/samba
ynh_app_setting_set --app=samba --key=datadir --value=$datadir
2022-02-22 13:59:54 +01:00
2022-02-22 17:45:17 +01:00
mkdir -p $datadir/share
2022-02-22 13:59:54 +01:00
2022-02-22 17:45:17 +01:00
chmod 750 "$datadir/share"
chmod -R o-rwx "$datadir/share"
chown -R root:root "$datadir/share"
2022-07-19 09:58:02 +02:00
setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $datadir/share
2022-02-22 13:59:54 +01:00
#=================================================
# ADD A CONFIGURATION
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2022-02-22 13:59:54 +01:00
2022-02-27 20:07:04 +01:00
mkdir -p $final_path/smb.conf.d
ynh_add_config --template="global-smb.conf" --destination="$final_path/smb.conf.d/0-global.conf"
ynh_add_config --template="share-smb.conf" --destination="$final_path/smb.conf.d/share.conf"
2022-02-27 20:07:04 +01:00
cat > $final_path/smb.conf <<EOF
# =================================================
# 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
2022-02-22 17:45:17 +01:00
2022-07-14 02:33:15 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2022-02-22 17:45:17 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2022-07-14 02:33:15 +02:00
#=================================================
2022-05-07 18:28:07 +02:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2022-02-22 17:45:17 +01:00
2022-07-14 02:33:15 +02:00
yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports 445
2022-02-22 13:59:54 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=10
2022-02-22 13:59:54 +01:00
# Start a systemd service
ynh_systemd_action --service_name=smbd --action="start"
#=================================================
# END OF SCRIPT
#=================================================
2022-05-07 18:24:57 +02:00
ynh_script_progression --message="Installation of $app completed" --last