#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) admin=$(ynh_app_setting_get $app admin) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # CHECK THE PATH #================================================= # Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) #================================================= #check for matlink's version #================================================= #deprecated - not maintained for more than a year... #cat /etc/yunohost/apps/$app/status.json | grep "matlink" #if [[ $?==0 ]]; then #add missing info in settings # final_path=/var/www/$app # db_name=emailPoubelle # ynh_app_setting_set $app db_name $db_name # ynh_app_setting_set $app final_path $final_path #install geoip dependencies # ynh_install_app_dependencies $pkg_dependencies #install locale packages # for i in $lang ; do # ynh_replace_string "# $i" "$i" /etc/locale.gen # done # locale-gen #change folder locale => lang as per src2.0 # rm -rf $final_path/locale # mkdir -p $final_path/lang #add new index.php # cp ../conf/index_source.php $final_path/www/index.php #switch from previous (modified) conf.php to new one (emailpoubelle original) # cp ../src/conf-dist.php $final_path/conf-dist.new.php #insert domain in line 24, DB in line 31, DBUSER in line 32, etc. # rep=$(cat $final_path/conf.php | grep "^[^//]" | grep "define('DOMAIN',") # sed -i "24s/.*/${rep}/" $final_path/conf-dist.new.php # rep=$(cat $final_path/conf.php | grep "^[^//]" | grep "define('DB',") # sed -i "31s/.*/${rep}/" $final_path/conf-dist.new.php # rep=$(cat $final_path/conf.php | grep "^[^//]" | grep "define('DBUSER',") # sed -i "32s/.*/${rep}/" $final_path/conf-dist.new.php # rep=$(cat $final_path/conf.php | grep "^[^//]" | grep "define('DBPASS',") # sed -i "33s/.*/${rep}/" $final_path/conf-dist.new.php #replace old conf and process with install command # mv $final_path/conf.php $final_path/conf.php.old # mv $final_path/conf-dist.new.php $final_path/conf.php # ynh_replace_string "define('DB', 'sqlite:'" "//define('DB', 'sqlite:'" $final_path/conf.php # ynh_replace_string "define('ALIASLIMITBYMAIL" "//define('ALIASLIMITBYMAIL" $final_path/conf.php # #setting conf file not world-readable (dude, there is a plain-text password !) # sudo chmod o-r $final_path/conf.php #fi #================================================= # NGINX CONFIGURATION #================================================= #change nginx.conf as per https://forum.yunohost.org/t/need-help-on-nginx-conf-cannot-access-resources/6342 ynh_replace_string "alias $finalpath/www/ ;" "alias $finalpath/ ;" /etc/yunohost/$domain.d/$app.conf ynh_replace_string "index index.php;" "index www/ndex.php;" /etc/yunohost/$domain.d/$app.conf #correct template name in index.php ynh_replace_string "Template-exemple" "$domain" $final_path/www/index.php #mysqlpwd setting was implemented in ynh2 - check if saved and if not implement db_pass=$(ynh_app_setting_get $app mysqlpwd) if [ -z $db_pass]; then #c'est moche mais ça fera bien l'affaire - en deux lignes sinon pb en fonction du type de shell t=$(cat /var/www/$app/conf.php | grep DBPASS) db_pass=${t:26:24} ynh_app_setting_set $app mysqlpwd $db_pass fi # Copy source files ynh_print_info "Downloading sources to $final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" cp ../conf/index_source.php $final_path/www/index.php test -e $final_path/template-exemple if [[ ! $? -eq 0 ]]; then ln -s $final_path/www/template-exemple $final_path/template-exemple fi #Temporaire - mettre en config ln -s $final_path/lang/fr $final_path/lang/fr_FR ln -s $final_path/lang/it $final_path/lang/it_IT chown -R www-data:www-data $final_path #adding php-cli for cron #sudo apt-get update -qq #sudo apt-get install -yqq php5-cli #adding cronjob for removing expired email addresses #sudo echo "$cronline" | sudo tee -a /etc/cron.d/emailpoubelle #sudo chmod 644 /etc/cron.d/emailpoubelle #================================================= # RELOAD SERVICES #================================================= systemctl restart php7.0-fpm systemctl reload nginx systemctl reload postfix sudo yunohost app ssowatconf