mirror of
https://github.com/YunoHost-Apps/monica_ynh.git
synced 2024-09-03 19:46:23 +02:00
Updated .env and send message to admin on fresh install
This commit is contained in:
parent
f9caf6f209
commit
a17e7b3741
4 changed files with 116 additions and 40 deletions
44
conf/.env
44
conf/.env
|
@ -13,7 +13,7 @@ APP_DEBUG=false
|
|||
# The encryption key. This is the most important part of the application. Keep
|
||||
# this secure otherwise, everyone will be able to access your application.
|
||||
# Must be 32 characters long exactly.
|
||||
# Use `php artisan key:generate` to generate a random key.
|
||||
# Use `php artisan key:generate` or `pwgen -s 32 1` to generate a random key.
|
||||
APP_KEY=random_key
|
||||
|
||||
# Prevent information leakage by referring to IDs with hashIds instead of
|
||||
|
@ -24,8 +24,13 @@ HASH_LENGTH=18
|
|||
# The URL of your application.
|
||||
APP_URL=https://__DOMAIN__
|
||||
|
||||
# Force using APP_URL as base url of your application.
|
||||
# You should not need this, unless you are using subdirectory config.
|
||||
APP_FORCE_URL=false
|
||||
|
||||
# Database information
|
||||
# To keep this information secure, we urge you to change the default password
|
||||
# Currently only "mysql" compatible servers are working
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
|
@ -45,7 +50,7 @@ DB_TEST_PASSWORD=secret
|
|||
DB_USE_UTF8MB4=true
|
||||
|
||||
# Mail credentials used to send emails from the application.
|
||||
MAIL_DRIVER=mail
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=25
|
||||
MAIL_USERNAME=
|
||||
|
@ -54,6 +59,7 @@ MAIL_ENCRYPTION=
|
|||
# Outgoing emails will be sent with these identity
|
||||
MAIL_FROM_ADDRESS=monica@yunodomain
|
||||
MAIL_FROM_NAME="Monica"
|
||||
# New registration notification sent to this email
|
||||
APP_EMAIL_NEW_USERS_NOTIFICATION=yunomail
|
||||
|
||||
|
||||
|
@ -104,7 +110,7 @@ SESSION_LIFETIME=120
|
|||
QUEUE_CONNECTION=sync
|
||||
|
||||
# If you use redis, set the redis host or ip, like:
|
||||
#REDIS_HOST=redis
|
||||
REDIS_HOST=redis
|
||||
|
||||
# Maximum allowed size for uploaded files, in kilobytes.
|
||||
# Make sure this is an integer, without commas or spaces.
|
||||
|
@ -126,17 +132,14 @@ AWS_BUCKET=
|
|||
AWS_SERVER=
|
||||
|
||||
# Allow Two Factor Authentication feature on your instance
|
||||
MFA_ENABLED=false
|
||||
MFA_ENABLED=true
|
||||
|
||||
# Enable DAV support
|
||||
DAV_ENABLED=true
|
||||
|
||||
# CLIENT ID and SECRET used for the official mobile application
|
||||
# This is to make sure that only the mobile application that you approve can
|
||||
# access the route to let your users sign in with their credentials
|
||||
# Note: the official mobile application is not currently available on the stores.
|
||||
MOBILE_CLIENT_ID=__IDENTITY__
|
||||
MOBILE_CLIENT_SECRET=__KEY__
|
||||
# CLIENT ID and SECRET used for OAuth authentication
|
||||
PASSPORT_PERSONAL_ACCESS_CLIENT_ID=__IDENTITY__
|
||||
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET==__KEY__
|
||||
|
||||
# Allow to access general statistics about your instance through a public API
|
||||
# call
|
||||
|
@ -146,27 +149,6 @@ ALLOW_STATISTICS_THROUGH_PUBLIC_API_ACCESS=false
|
|||
# like CASL or GDPR
|
||||
POLICY_COMPLIANT=true
|
||||
|
||||
# Have access to paid features available on https://monicahq.com, for free.
|
||||
# Can be true or false. Default to false.
|
||||
# If set to true, that means your users will have to pay to access the paid
|
||||
# features. We use Stripe to do this.
|
||||
REQUIRES_SUBSCRIPTION=false
|
||||
|
||||
# Number of contacts allowed in the Free version if the instance requires
|
||||
# a subscription
|
||||
NUMBER_OF_ALLOWED_CONTACTS_FREE_ACCOUNT=10
|
||||
|
||||
# ONLY NECESSARY IF MONICA REQUIRES A SUBSCRIPTION TO WORK
|
||||
# Leave blank unless you know what you are doing.
|
||||
STRIPE_KEY=
|
||||
STRIPE_SECRET=
|
||||
PAID_PLAN_MONTHLY_FRIENDLY_NAME=
|
||||
PAID_PLAN_MONTHLY_ID=
|
||||
PAID_PLAN_MONTHLY_PRICE=
|
||||
PAID_PLAN_ANNUAL_FRIENDLY_NAME=
|
||||
PAID_PLAN_ANNUAL_ID=
|
||||
PAID_PLAN_ANNUAL_PRICE=
|
||||
|
||||
# Enable geolocation services
|
||||
# This is used to translate addresses to GPS coordinates.
|
||||
ENABLE_GEOLOCATION=false
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies=""
|
||||
pkg_dependencies="redis-server"
|
||||
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
source _common.sh
|
||||
source ynh_composer__2
|
||||
source /usr/share/yunohost/helpers
|
||||
source send_readme_to_admin.sh
|
||||
source ynh_package_version
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
|
@ -28,6 +30,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
|||
language=$YNH_APP_ARG_LANGUAGE
|
||||
random_key=$(ynh_string_random --length=32)
|
||||
email=$(ynh_user_get_info $admin 'mail')
|
||||
password=$(ynh_string_random --length=8)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -139,7 +142,7 @@ ynh_replace_string --match_string="language" --replace_string="$language" --targ
|
|||
ynh_script_progression --message="Deploying..."
|
||||
|
||||
pushd "$final_path"
|
||||
php$phpversion artisan monica:update --force
|
||||
php$phpversion artisan setup:production --email=$email --password=$password -vvv -n
|
||||
php$phpversion artisan passport:keys
|
||||
php$phpversion artisan passport:client --password -n > key.txt
|
||||
mobile_id=$( cd $final_path && tail -2 key.txt | head -1 | cut -c 12- )
|
||||
|
@ -196,6 +199,31 @@ ynh_script_progression --message="Reloading nginx web server..."
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
# WARNING : theses command are used in INSTALL
|
||||
# For any update do it in all files
|
||||
|
||||
echo "Hi,
|
||||
-----------------------------------------------------------
|
||||
|
|
||||
| Welcome to Monica v${last_version}
|
||||
|
|
||||
-----------------------------------------------------------
|
||||
| You can now sign in to your account:
|
||||
| username: $email
|
||||
| password: $password
|
||||
| URL: https://monica.anmol.net.in
|
||||
| It is advised to change your password after first login.
|
||||
-----------------------------------------------------------
|
||||
Setup is done. Have fun.
|
||||
|
||||
|
||||
" > mail_to_send
|
||||
|
||||
ynh_send_readme_to_admin --app_message="$mail_to_send" --recipients="$email"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
66
scripts/send_readme_to_admin.sh
Normal file
66
scripts/send_readme_to_admin.sh
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||
|
||||
# Send an email to inform the administrator
|
||||
#
|
||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||
# | arg: -m --app_message= - The message to send to the administrator.
|
||||
# | arg: -r, --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() {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=app_message= [r]=recipients= )
|
||||
local app_message
|
||||
local recipients
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
local app_message="${app_message:-...No specific information...}"
|
||||
local recipients="${recipients:-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\` was just installed!"
|
||||
|
||||
local mail_message="This is an automated message from your beloved YunoHost server.
|
||||
Specific information for the application $app.
|
||||
$app_message
|
||||
---
|
||||
Automatic diagnosis data from YunoHost
|
||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||
|
||||
# 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"
|
||||
}
|
Loading…
Add table
Reference in a new issue