1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/timemachine_ynh.git synced 2024-09-03 20:26:33 +02:00
timemachine_ynh/scripts/install

129 lines
4.3 KiB
Text
Raw Normal View History

2022-06-15 09:54:44 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
2022-06-15 15:30:00 +02:00
source ynh_send_readme_to_admin__2
2022-06-15 09:54:44 +02:00
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_clean_setup () {
2022-07-13 04:01:56 +02:00
ynh_clean_check_starting
2022-06-15 09:54:44 +02:00
}
# Exit if an error occurs during the execution of the script
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_abort_if_errors
2022-06-15 09:54:44 +02:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2023-09-10 18:11:33 +02:00
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
#REMOVEME? password=$YNH_APP_ARG_PASSWORD
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2022-06-15 09:54:44 +02:00
2022-07-13 04:01:56 +02:00
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
2022-06-15 09:54:44 +02:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
#REMOVEME? ynh_app_setting_set --app=$app --key=password --value=$password
2022-06-15 09:54:44 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
2022-06-15 15:30:00 +02:00
# OPEN PORT 445
2022-06-15 09:54:44 +02:00
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Configuring firewall..." --weight=1
2022-06-15 15:30:00 +02:00
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP 445 # Allow SMB access
2022-06-15 09:54:44 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2022-06-15 09:54:44 +02:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
2022-06-15 09:54:44 +02:00
# Create a system user
2023-09-10 18:11:33 +02:00
#REMOVEME? ynh_system_user_create --username=$app
2022-06-15 09:54:44 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Creating a data directory..." --weight=1
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
#REMOVEME? data_dir=/home/yunohost.app/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
mkdir -p $data_dir
2022-06-15 09:54:44 +02:00
2023-09-10 18:11:33 +02:00
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app: "$data_dir"
2022-06-15 09:54:44 +02:00
#=================================================
# ADD A CONFIGURATION
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2022-06-15 09:54:44 +02:00
2022-06-15 15:30:00 +02:00
samba_sysadmin_setup
ynh_add_config --template="../conf/smb.conf" --destination="/etc/smb/smb.d/$app.conf"
ynh_add_config --template="../conf/avahi-samba.service" --destination="/etc/avahi/services/$app.service"
2022-06-15 09:54:44 +02:00
2022-07-13 04:01:56 +02:00
# Create a samba user
(echo "$password"; echo "$password") | ynh_exec_warn_less smbpasswd -s -a "$app"
2022-06-15 15:30:00 +02:00
# Update samba configuration
samba_sysadmin_update
2022-06-15 09:54:44 +02:00
2022-06-15 15:46:21 +02:00
# Check and Add
samba_sysadmin_add
2022-07-13 04:01:56 +02:00
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add smbd --needs_exposed_ports 445
2022-06-15 09:54:44 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-06-15 09:54:44 +02:00
2022-06-15 15:30:00 +02:00
ynh_exec_warn_less testparm -s
2022-06-15 09:54:44 +02:00
2022-06-15 15:30:00 +02:00
ynh_systemd_action --service_name=smbd --action="reload"
ynh_systemd_action --service_name=avahi-daemon --action="restart"
2022-06-15 09:54:44 +02:00
#=================================================
2022-06-15 15:30:00 +02:00
# SEND A README FOR THE ADMIN
2022-06-15 09:54:44 +02:00
#=================================================
2022-06-15 15:30:00 +02:00
ynh_script_progression --message="Sending a readme for the admin..."
2022-06-15 09:54:44 +02:00
2022-06-15 15:30:00 +02:00
ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients="$admin_mail" --type='install'
2022-06-15 09:54:44 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Installation of $app completed" --last