2018-11-18 16:00:35 +01:00
|
|
|
#!/bin/bash
|
2018-11-20 23:57:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2018-11-24 00:08:25 +01:00
|
|
|
source _common.sh
|
2018-11-20 23:57:22 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2018-11-23 23:43:40 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_abort_if_errors
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
#REMOVEME? path=$YNH_APP_ARG_PATH
|
|
|
|
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
|
|
|
|
#REMOVEME? password=$YNH_APP_ARG_PASSWORD
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2018-11-23 23:43:40 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
|
2018-11-23 23:43:40 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? install_dir=/var/www/$app
|
|
|
|
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2018-11-20 23:50:48 +01:00
|
|
|
# Register (book) web path
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
2018-11-24 00:26:38 +01:00
|
|
|
|
2018-11-23 23:43:40 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=password --value=$password
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2018-11-24 14:19:37 +01:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
2018-11-24 14:19:37 +01:00
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
2019-05-21 00:20:22 +02:00
|
|
|
|
2018-11-23 19:03:57 +01:00
|
|
|
#install locale (nginx will restart at the end of the install)
|
2018-11-24 11:52:31 +01:00
|
|
|
for i in $lang ; do
|
2022-06-10 20:52:48 +02:00
|
|
|
ynh_replace_string --match_string="# $i" --replace_string="$i" --target_file="/etc/locale.gen"
|
2018-11-23 19:03:57 +01:00
|
|
|
done
|
2019-05-21 00:20:22 +02:00
|
|
|
|
2018-11-24 01:23:27 +01:00
|
|
|
locale-gen
|
|
|
|
|
2018-11-24 14:19:37 +01:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Configuring system user..."
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
# Create a system user
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..."
|
2019-03-04 21:10:34 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
|
|
#REMOVEME? db_user=$db_name
|
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-11-01 16:49:03 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
2019-03-04 21:10:34 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-06 13:42:27 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
ynh_add_config --template="../conf/index_source.php" --destination="$install_dir/www/index.php"
|
|
|
|
#REMOVEME? ynh_secure_remove --file="$install_dir/www/admin.php"
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
ln -s $install_dir/lib $install_dir/www/lib
|
2018-11-22 21:39:07 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
ynh_add_config --template="../conf/conf-dist.php" --destination="$install_dir/conf.php"
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
chmod 400 "$install_dir/conf.php"
|
|
|
|
chown $app:$app "$install_dir/conf.php"
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
# Setting postfix to use virtual aliases file
|
2019-03-04 21:10:34 +01:00
|
|
|
# Add postfix configuration hook and regen postfix conf
|
|
|
|
cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/
|
2020-11-01 16:49:03 +01:00
|
|
|
yunohost tools regen-conf postfix
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
# Create the virtual aliases file
|
2023-04-06 13:42:27 +02:00
|
|
|
touch $install_dir/var/virtual
|
|
|
|
postmap $install_dir/var/virtual
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
# Create an alias for deleted junk adresses
|
2019-04-13 15:11:19 +02:00
|
|
|
cp /etc/aliases /etc/aliases.emailpoubelle.bak #backup it
|
|
|
|
echo "devnull:/dev/null" | tee -a /etc/aliases
|
|
|
|
newaliases
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_systemd_action --service_name=postfix --action=reload
|
2018-11-18 16:00:35 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
# Adding cronjob for removing expired email addresses
|
|
|
|
ynh_add_config --template="../conf/emailpoubelle.cron" --destination="/etc/cron.d/$app"
|
2020-02-22 18:35:27 +01:00
|
|
|
chown root:root /etc/cron.d/$app
|
2019-04-13 15:11:19 +02:00
|
|
|
chmod 644 /etc/cron.d/$app
|
2018-11-23 23:29:21 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2019-03-04 21:10:34 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Configuring permissions..."
|
2019-03-04 21:10:34 +01:00
|
|
|
|
|
|
|
# Make app public if necessary
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? if [ $is_public -eq 1 ]
|
2018-11-18 16:00:35 +01:00
|
|
|
then
|
2022-06-08 03:24:51 +02:00
|
|
|
# Everyone can access the app.
|
|
|
|
# The "main" permission is automatically created before the install script.
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
2018-11-18 16:00:35 +01:00
|
|
|
fi
|
|
|
|
|
2019-05-21 00:20:22 +02:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
# RELOAD NGINX
|
2019-05-21 00:20:22 +02:00
|
|
|
#=================================================
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-01 16:49:03 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|