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
|
|
|
|
|
2023-04-06 14:36:04 +02:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
password=$YNH_APP_ARG_PASSWORD
|
|
|
|
ynh_app_setting_set --app=$app --key=password --value=$password
|
|
|
|
|
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:48:27 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=15
|
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
|
|
|
|
|
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
|
|
|
|
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"
|
2023-04-06 13:48:27 +02:00
|
|
|
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 -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
|
2023-04-06 13:54:22 +02:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-01 16:49:03 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|