diff --git a/README.md b/README.md index ee726f7..626cc62 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,31 @@ + + # Friendica for YunoHost [![Integration level](https://dash.yunohost.org/integration/friendica.svg)](https://dash.yunohost.org/appci/app/friendica) ![](https://ci-apps.yunohost.org/ci/badges/friendica.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/friendica.maintain.svg) -[![Install Friendica with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=friendica) +[![Install Friendica with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=friendica) +*[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Friendica quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to learn how to install and enjoy it.* +> *This package allows you to install Friendica quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Friendica is a software to create a distributed social network. It is part of the federation of servers that are running with Friendica, Diaspora and Hubzilla which are compatible to each other. -**Version:** 2021.04 +Social Communication Server -Current snapshot in *sources*: +**Shipped version:** 2021.07~ynh1 -* https://github.com/friendica/friendica: 2021.04 -* https://github.com/friendica/friendica-addons: 2021.04 +**Demo:** https://demo.example.com -**Warning:** It's advised to use Barracuda as MySQL DB file format for your Friendica database. +## Screenshots -## Friendica -[Friendica](http://friendi.ca/) is a decentralised communications platform that integrates social communication. Our platform links to independent social projects and corporate services. +![](./doc/screenshots/friendica-vier-profile.png) -Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on **Friendica**, **Mastodon**, **Diaspora**, **GnuSocial**, **Pleroma**, or **Hubzilla**, regardless where each user profile is hosted. - -![](https://raw.githubusercontent.com/friendica/friendica/develop/images/screenshots/friendica-frio-green-profle-1.png) - -## This app claims following features: -- [ ] Ldap integration(Ldap is broken in the latest version.[See this](https://github.com/friendica/friendica/issues/4140#issuecomment-731579013)) -- [X] Multi-instance -- [ ] Add php.log in the root folder for debugging php, with logrotate applied on it (can be accesssed by **admin->logs** and entering the **php.log**). -- [ ] Fail2Ban +## Disclaimers / important information ## Installation @@ -47,28 +42,23 @@ Use the YunoHost admin panel to install Friendica by entering the GitHub repo ad https://github.com/YunoHost-Apps/friendica_ynh -## User with ldap admin rights +## User with LDAP admin rights **For admin rights**: When installation is complete, you will need to visit your domain page and login with the **admin account username and password** which was entered at the time of installation process. You can then create your profile and access the admin panel. **For normal YunoHost users :** Normal LDAP users can login through Ldap authentication and create there profiles. -#### Supported architectures +## Documentation and resources -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/friendica%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/friendica/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/friendica%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/friendica/) +* Official app website: http://friendi.ca +* Official user documentation: https://wiki.friendi.ca/ +* Official admin documentation: https://github.com/friendica/friendica/wiki +* Upstream app code repository: https://github.com/friendica/friendica +* YunoHost documentation for this app: https://yunohost.org/app_friendica +* Report a bug: https://github.com/YunoHost-Apps/friendica_ynh/issues -## Links +## Developer info - * Report a bug: https://github.com/YunoHost-Apps/friendica_ynh/issues - * App website: http://friendi.ca/ - * Upstream app repository: https://github.com/friendica/friendica - * YunoHost website: https://yunohost.org/ - ---- - -## Developers info - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/friendica_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/friendica_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -76,3 +66,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/friendica_ynh/tree/te or sudo yunohost app upgrade friendica -u https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..2c92c94 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,66 @@ +# Friendica pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/friendica.svg)](https://dash.yunohost.org/appci/app/friendica) ![](https://ci-apps.yunohost.org/ci/badges/friendica.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/friendica.maintain.svg) +[![Installer Friendica avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=friendica) + +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* + +> *Ce package vous permet d'installer Friendica rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +## Vue d'ensemble + +Serveur de Communication Social + +**Version incluse :** 2021.07~ynh1 + +**Démo :** https://demo.example.com + +## Captures d'écran + +![](./doc/screenshots/friendica-vier-profile.png) + +## Avertissements / informations importantes + +## Installation + +### Enregistrez un nouveau domaine et ajoutez-le à YunoHost + +Avant l'installation, lisez les [instructions d'installation de Friendica](https://github.com/friendica/friendica/blob/develop/doc/Install.md) pour obtenir des informations importantes sur l'installation. + +- Domaine dédié (doit être installé sous la racine Web comme **https://friendica.example.com/** et non **https://example.com/friendica/** ) + +- Friendica nécessite des certificats SSL approuvés par le navigateur. + +### Installer Friendica +Utilisez le panneau d'administration YunoHost pour installer Friendica en saisissant l'adresse du dépôt GitHub dans l'URL de l'application personnalisée : + +https://github.com/YunoHost-Apps/friendica_ynh + +## Utilisateur avec des droits d'administrateur LDAP +**Pour les droits d'administrateur** : une fois l'installation terminée, vous devrez visiter la page de votre domaine et vous connecter avec le **nom d'utilisateur et le mot de passe du compte administrateur** qui ont été saisis au moment du processus d'installation. Vous pouvez ensuite créer votre profil et accéder au panneau d'administration. + + **Pour les utilisateurs normaux de YunoHost :** Les utilisateurs LDAP normaux peuvent se connecter via l'authentification LDAP et y créer des profils. + +## Documentations et ressources + +* Site officiel de l'app : http://friendi.ca +* Documentation officielle utilisateur : https://wiki.friendi.ca/ +* Documentation officielle de l'admin : https://github.com/friendica/friendica/wiki +* Dépôt de code officiel de l'app : https://github.com/friendica/friendica +* Documentation YunoHost pour cette app : https://yunohost.org/app_friendica +* Signaler un bug : https://github.com/YunoHost-Apps/friendica_ynh/issues + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/friendica_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug +ou +sudo yunohost app upgrade friendica -u https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug +``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index d073319..e997f71 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - admin="john" (USER) + domain="domain.tld" + admin="john" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -10,11 +10,14 @@ setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=b3642c110f0e927ba36ee32e738a81e6afce958f7ackup_restore=1 + upgrade=1 from_commit=41c39d47e4e398339b7d6a4167ca2198dae998e3 backup_restore=1 multi_instance=1 - port_already_use=0 change_url=0 - ;;; Options - Email="" - Notification=change +;;; Options +Email= +Notification=none +;;; Upgrade options + ; commit=41c39d47e4e398339b7d6a4167ca2198dae998e3 + name=Merge pull request #50 from YunoHost-Apps/2021.04 + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/conf.php b/conf/conf.php deleted file mode 100644 index d6d8569..0000000 --- a/conf/conf.php +++ /dev/null @@ -1,8 +0,0 @@ - -$a->config['system']['addon'] = 'ldapauth'; - -$a->config['ldapauth']['ldap_server'] = 'localhost'; -$a->config['ldapauth']['ldap_searchdn'] = 'ou=users,dc=yunohost,dc=org'; -$a->config['ldapauth']['ldap_userattr'] = 'uid'; -$a->config['ldapauth']['ldap_autocreateaccount'] = 'true'; -$a->config['ldapauth']['ldap_autocreateaccount_emailattribute'] = 'mail'; diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..f401a8f --- /dev/null +++ b/conf/cron @@ -0,0 +1,2 @@ +# Run poller periodically to update Friendica +*/10 * * * * __APP__ cd __FINALPATH__; /usr/bin/php__PHPVERSION__ bin/worker.php diff --git a/conf/htconfig.php b/conf/htconfig.php deleted file mode 100644 index 30f157e..0000000 --- a/conf/htconfig.php +++ /dev/null @@ -1,112 +0,0 @@ -config['system']['db_charset'] = "utf8mb4"; - -// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". -// It can be changed later and only applies to timestamps for anonymous viewers. - -$default_timezone = 'America/Los_Angeles'; - -// Default system language - -$a->config['system']['language'] = 'en'; - -// What is your site name? - -$a->config['sitename'] = "YunoHost Friendica Social Network"; - -// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. -// Be certain to create your own personal account before setting -// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on -// the registration page. REGISTER_APPROVE requires you set 'admin_email' -// to the email address of an already registered person who can authorise -// and/or approve/deny the request. - -// In order to perform system administration via the admin panel, admin_email -// must precisely match the email address of the person logged in. - -$a->config['register_policy'] = REGISTER_CLOSEDS; -$a->config['register_text'] = ''; -$a->config['admin_email'] = '__ADMIN_EMAIL__'; - -// Maximum size of an imported message, 0 is unlimited - -$a->config['max_import_size'] = 200000; - -// maximum size of uploaded photos - -$a->config['system']['maximagesize'] = 800000; - -// Location of PHP command line processor - -$a->config['php_path'] = 'php'; - -// Server-to-server private message encryption (RINO) is allowed by default. -// set to 0 to disable, 1 to enable - -$a->config['system']['rino_encrypt'] = 1; - -// allowed themes (change this from admin panel after installation) - -$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; - -// default system theme - -$a->config['system']['theme'] = 'vier'; - - -// By default allow pseudonyms - -$a->config['system']['no_regfullname'] = true; - -//Deny public access to the local directory -//$a->config['system']['block_local_dir'] = false; - -// Location of the global directory -$a->config['system']['directory'] = 'https://dir.friendica.social'; - -// Allowed protocols in link URLs; HTTP protocols always are accepted -$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; - -// Authentication cookie lifetime, in days -$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/conf/local-sample.config.php b/conf/local-sample.config.php new file mode 100644 index 0000000..ad05da0 --- /dev/null +++ b/conf/local-sample.config.php @@ -0,0 +1,44 @@ + [ + 'hostname' => 'localhost', + 'username' => '__DB_NAME__', + 'password' => '__DB_PWD__', + 'database' => '__DB_NAME__', + 'charset' => 'utf8mb4', + ], + + // **************************************************************** + // The configuration below will be overruled by the admin panel. + // Changes made below will only have an effect if the database does + // not contain any configuration for the friendica system. + // **************************************************************** + + 'config' => [ + 'admin_email' => '__EMAIL__', + 'sitename' => 'Friendica Social Network', + 'register_policy' => \Friendica\Module\Register::OPEN, + 'register_text' => '', + ], + 'system' => [ + 'default_timezone' => 'UTC', + 'language' => 'en', + ], +]; diff --git a/conf/local.ini.php b/conf/local.ini.php deleted file mode 100644 index 359f3ee..0000000 --- a/conf/local.ini.php +++ /dev/null @@ -1,41 +0,0 @@ -= 4.1.0" + "yunohost": ">= 4.2.0" }, "previous_maintainers": { "name": "aymhce", @@ -31,22 +39,13 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Friendica. Friendica must be installed on the ROOT domain, so be careful!", - "fr": "Choisissez un domaine pour Friendica.Friendica doit etre installe a la racine, soyez prudent" - }, "example": "domain.org" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose the Friendica administrator (must be an existing YunoHost user)", - "fr": "Choisissez l'administrateur pour Friendica (l'utilisateur YunoHost doit exister)" - }, - "example": "homer" + "example": "johndoe" } - ] } } diff --git a/scripts/_common.sh b/scripts/_common.sh index b8749f1..bb74e80 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,31 +13,6 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli # EXPERIMENTAL HELPERS #================================================= -ynh_smart_mktemp () { - local min_size="${1:-300}" - # Transform the minimum size from megabytes to kilobytes - min_size=$(( $min_size * 1024 )) - - # Check if there's enough free space in a directory - is_there_enough_space () { - local free_space=$(df --output=avail "$1" | sed 1d) - test $free_space -ge $min_size - } - - if is_there_enough_space /tmp; then - local tmpdir=/tmp - elif is_there_enough_space /var; then - local tmpdir=/var - elif is_there_enough_space /; then1 - local tmpdir=/ - elif is_there_enough_space /home; then - local tmpdir=/home - else - ynh_die "Insufficient free space to continue..." - fi - - echo "$(mktemp --directory --tmpdir="$tmpdir")" -} #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index b50cd45..c31c808 100644 --- a/scripts/backup +++ b/scripts/backup @@ -71,4 +71,4 @@ ynh_backup --src_path="/etc/cron.d/$app" # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..ff06606 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,105 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # 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 WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 463903b..561457a 100644 --- a/scripts/install +++ b/scripts/install @@ -28,9 +28,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url='/' admin=$YNH_APP_ARG_ADMIN -admin_mail=$(yunohost user info $admin | grep "mail:" | cut -d' ' -f2) -is_public=1 -database="1" +email=$(ynh_user_get_info --username=$admin --key=mail) app=$YNH_APP_INSTANCE_NAME @@ -53,9 +51,15 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=email --value=$admin_mail -ynh_app_setting_set --app=$app --key=database --value=$database +ynh_app_setting_set --app=$app --key=email --value=$email + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE @@ -74,13 +78,17 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # 1- Clone stable repo -git clone https://github.com/friendica/friendica.git -b stable "$final_path" +ynh_exec_warn_less git clone https://github.com/friendica/friendica.git -b stable "$final_path" # Copy .htaccess-dist to ..htaccess cp -f "$final_path/.htaccess-dist" "$final_path/.htaccess" # 2 - Clone addons repo -git clone https://github.com/friendica/friendica-addons.git -b stable "$final_path/addon" +ynh_exec_warn_less git clone https://github.com/friendica/friendica-addons.git -b stable "$final_path/addon" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -90,29 +98,18 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated nginx config ynh_add_nginx_config -# configure friendica -config="$final_path/config/local.config.php" -cp -f "$final_path/config/local-sample.config.php" $config -ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config" -ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file="$config" -ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$config" -#ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$config" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." + +ynh_add_config --template="../conf/local-sample.config.php" --destination="$final_path/config/local.config.php" # init db ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql" -# ldap addon config -cp "../conf/addon.config.php" "$final_path/config/." - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app +# LDAP addon config +ynh_add_config --template="../conf/addon.config.php" --destination="$final_path/config/addon.config.php" #================================================= # PHP-FPM CONFIGURATION @@ -127,11 +124,14 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) mkdir -p "${final_path}/view/smarty3" chmod -R 775 $final_path/view/smarty3 -# Set up poller -ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$final_path" --target_file="../conf/poller-cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron" -ynh_replace_string --match_string="__PHP_VERSION__" --replace_string="$phpversion" --target_file="../conf/poller-cron" -cp ../conf/poller-cron /etc/cron.d/$app +#================================================= +# SETUP A CRON +#================================================= +ynh_script_progression --message="Setuping a cron..." + +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -145,14 +145,9 @@ pushd "$final_path" php$phpversion bin/composer.phar install 2>/dev/null bin/console config system addon ldapauth popd + ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO addon (id, name, version, installed, hidden, timestamp, plugin_admin) VALUES (NULL, 'ldapauth', '', '1', '0', UNIX_TIMESTAMP(), '0');" -#================================================= -# Folder rights -#================================================= - -chown -R $app: $final_path - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/restore b/scripts/restore index 69d4a40..2b6fe1f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -60,6 +60,14 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_print_info "Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -67,13 +75,10 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_print_info "Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create $app +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod -R 775 $final_path/view/smarty3 #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -85,28 +90,12 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated php-fpm config ynh_add_fpm_config --package="$extra_php_dependencies" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." - -# set permission -chmod -R 775 $final_path/view/smarty3 - #================================================= # RESTORE THE CRON FILE #================================================= ynh_restore_file "/etc/cron.d/$app" -#================================================= -# Folder rights -#================================================= - -chown -R $app: $final_path - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 83e7989..b15207c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -admin_mail=$(ynh_app_setting_get --app=$app --key=email) +email=$(ynh_app_setting_get --app=$app --key=email) admin=$(ynh_app_setting_get --app=$app --key=admin) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -76,9 +76,9 @@ if [ -f $final_path/.htconfig.php ]; then fi # If admin_mail setting doesn't exist, create it -if [ -z $admin_mail ]; then - admin_mail=$(ynh_user_get_info --username=$admin --key=mail) - ynh_app_setting_set --app=$app --key=email --value=$admin_mail +if [ -z $email ]; then + email=$(ynh_user_get_info --username=$admin --key=mail) + ynh_app_setting_set --app=$app --key=email --value=$email fi # Cleaning legacy permissions @@ -88,6 +88,14 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -113,7 +121,7 @@ then else # Create a temporary directory and backup smarty3 folder - tmpdir="$(ynh_smart_mktemp 6000)" + tmpdir="$(mktemp -d)" ynh_script_progression --message="Upgrading source files..." cp -a "$final_path/view/smarty3" "$tmpdir/view/smarty3" @@ -132,24 +140,15 @@ else # Restore the smarty3 folder cp -a "$tmpdir/view/smarty3" "${final_path}" ynh_secure_remove "$tmpdir" - fi fi # Copy config file for correct place -config="$final_path/config/local.config.php" -cp -a "/var/www/$app/config/local-sample.config.php" $config +ynh_add_config --template="../conf/local-sample.config.php" --destination="$final_path/config/local.config.php" -# Replace strings in config file -ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config" -ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file= "$config" -ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$config" -#ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$config" - -# ldap addon config -cp -f "../conf/addon.config.php" "$final_path/config/." +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" # 3 - some extra folders chmod -R 775 $final_path/view/smarty3 @@ -162,14 +161,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -182,17 +173,9 @@ ynh_add_fpm_config --package="$extra_php_dependencies" # STORE THE CONFIG FILE CHECKSUM #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/config/local.config.php" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config/local.config.php" - -# Set up cron job -ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$final_path" --target_file="../conf/poller-cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron" -ynh_replace_string --match_string="__PHP_VERSION__" --replace_string="$phpversion" --target_file="../conf/poller-cron" -cp "../conf/poller-cron" "/etc/cron.d/$app" +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" # Run composer pushd "$final_path" @@ -200,12 +183,6 @@ pushd "$final_path" bin/console config system addon ldapauth popd -#================================================= -# Folder rights -#================================================= - -chown -R $app: $final_path - #================================================= # RELOAD NGINX #=================================================