diff --git a/check_process b/check_process index 1501c7c..69906f4 100644 --- a/check_process +++ b/check_process @@ -2,8 +2,7 @@ ; Manifest domain="domain.tld" path="/path" - username="john" - name="john" + admin="john" email="admin@example.com" is_public=1 ; Checks @@ -16,6 +15,8 @@ upgrade=1 #2.0.23~ynh1 upgrade=1 from_commit=ba7931d0524925cb4a4264ac857af9ea7c7e6120 + #2.1.4~ynh1 + upgrade=1 from_commit=61571b15dec769da5bf2466c5e8c56f204268bd6 backup_restore=1 multi_instance=1 change_url=1 @@ -25,4 +26,6 @@ Notification=change ;;; Upgrade options ; commit=ba7931d0524925cb4a4264ac857af9ea7c7e6120 name=Testing (#42) + ; commit=ba7931d0524925cb4a4264ac857af9ea7c7e6120 + name=Testing (#50) manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/config.ini.php b/conf/config.ini.php index d0f1ac0..49be9c5 100755 --- a/conf/config.ini.php +++ b/conf/config.ini.php @@ -1,7 +1,10 @@ ; DO NOT DELETE THIS LINE +dbtype="mysql" dbhost="localhost" dbport="3306" dbuser="__DB_USER__" dbpass="__DB_PWD__" dbname="__DB_NAME__" tblpfx="wt_" +base_url="https://__DOMAIN____PATH__" +rewrite_urls="0" diff --git a/conf/nginx.conf b/conf/nginx.conf index ca740c7..aa2548c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -25,8 +25,8 @@ location __PATH__/ { include conf.d/yunohost_panel.conf.inc; } - # Deny access to /data/config.ini.php - location = __PATH__/data/config.ini.php { - deny all; - return 404; - } +# Deny access to /data/config.ini.php +location = __PATH__/data/config.ini.php { + deny all; + return 404; +} diff --git a/conf/sql/admin.sql b/conf/sql/admin.sql index 127ed0c..33811a7 100644 --- a/conf/sql/admin.sql +++ b/conf/sql/admin.sql @@ -1,3 +1,3 @@ -INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__USER_NAME__', '__NAME__', '__USER_EMAIL__', '__PASSWORD__'); +INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__ADMIN__', '__FULLNAME__', '__EMAIL__', '__SALT_PASSWORD__'); INSERT INTO `wt_user_setting` (`user_id`, `setting_name`, `setting_value`) VALUES ('1', 'canadmin', '1'), ('1', 'verified', '1'), ('1', 'verified_by_admin', '1'); diff --git a/manifest.json b/manifest.json index 9df9c1c..7e2fc4c 100644 --- a/manifest.json +++ b/manifest.json @@ -41,34 +41,7 @@ "example": "/webtrees", "default": "/webtrees" }, - { - "name": "username", - "type": "string", - "ask": { - "en": "Choose an admin username (Not a LDAP User)", - "fr": "Choisissez un nom d'utilisateur pour l'administrateur de Webtrees (ne doit pas être un utilisateur YunoHost existant)" - }, - "example": "john" - }, - { - "name": "name", - "type": "string", - "ask": { - "en": "Name of the user (Not a LDAP User)", - "fr": "Nom de cet utilisateur" - }, - "example": "john doe" - }, - { - "name": "email", - "type": "string", - "ask": { - "en": "Admin email (All the new registration will be sent on this email)", - "fr": "Adresse email de l'administrateur (Toutes les nouvelles inscriptions seront envoyées à cette adresse)" - }, - "example": "admin@example.com" - }, - { + { "name": "is_public", "type": "boolean", "help": { @@ -76,6 +49,14 @@ "fr": "Si cochée, Webtrees sera publique" }, "default": true + }, + { + "name": "admin", + "type": "user" + }, + { + "name": "password", + "type": "password" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index d859609..217a2a1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,56 +20,3 @@ pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-mysql php #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` has important message for you" - - local mail_message="This is an automated message from your beloved YunoHost server. Specific information for $app. -$app_message" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} diff --git a/scripts/install b/scripts/install index 673b1ee..4248836 100755 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,11 +28,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -admin_username=$YNH_APP_ARG_USERNAME -admin_name=$YNH_APP_ARG_NAME -admin_email=$YNH_APP_ARG_EMAIL -password=$(ynh_string_random 24) -admin_password=$(openssl passwd -1 -salt xyz $password) +admin=$YNH_APP_ARG_ADMIN +email=$(ynh_user_get_info --username=$admin --key=mail) +fullname=$(ynh_user_get_info --username=$admin --key=fullname) +password=$YNH_APP_ARG_PASSWORD +salt_password=$(openssl passwd -1 -salt xyz $password) app=$YNH_APP_INSTANCE_NAME @@ -50,6 +54,7 @@ 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 #================================================= # INSTALL DEPENDENCIES @@ -114,16 +119,15 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) # Adding the details of the database to the config file ynh_add_config --template="../conf/config.ini.php" --destination="$final_path/data/config.ini.php" +chmod 400 "$final_path/data/config.ini.php" +chown $app:$app "$final_path/data/config.ini.php" + # Load initial SQL into the new database -ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/webtrees.sql" +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "../conf/sql/webtrees.sql" -# Replace variables in sql scripts -ynh_replace_string --match_string="__USER_NAME__" --replace_string="$admin_username" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__NAME__" --replace_string="$admin_name" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__USER_EMAIL__" --replace_string="$admin_email" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__PASSWORD__" --replace_string="$admin_password" --target_file="../conf/sql/admin.sql" - -ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/admin.sql" +ynh_add_config --template="../conf/sql/admin.sql" --destination="/var/tmp/admin.sql" +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "/var/tmp/admin.sql" +ynh_secure_remove --file="/var/tmp/admin.sql" #================================================= # SETUP SSOWAT @@ -143,22 +147,6 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message="Webtrees was successfully installed :) - -Please open https://$domain$path_url - -Your credentials for the admin panel are: -- admin username: $admin_username -- admin password: $password - -If you facing an issue or want to improve Webtrees, please open a new issue in this project: https://github.com/YunoHost-Apps/webtrees_ynh" - -ynh_send_readme_to_admin "$message" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 57b7362..66f3402 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,6 +13,11 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -35,7 +40,8 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die "There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS diff --git a/scripts/upgrade b/scripts/upgrade index 7ecc61e..f87c34d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -85,17 +85,9 @@ ynh_script_progression --message="Upgrading source files..." if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - # Move old app dir - mv ${final_path} ${final_path}.old # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source "$final_path" - - # restore data - cp -a ${final_path}.old/data ${final_path} - - # delete temp directory - ynh_secure_remove --file=${final_path}.old + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/data " fi chmod 750 "$final_path"