mirror of
https://github.com/YunoHost-Apps/monica_ynh.git
synced 2024-09-03 19:46:23 +02:00
Fix
This commit is contained in:
parent
0a99baa77e
commit
cba6d15a93
4 changed files with 59 additions and 38 deletions
1
conf/cron
Normal file
1
conf/cron
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan schedule:run
|
|
@ -31,6 +31,9 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
random_key=$(ynh_string_random --length=32)
|
random_key=$(ynh_string_random --length=32)
|
||||||
email=$(ynh_user_get_info --username=$admin --key="mail")
|
email=$(ynh_user_get_info --username=$admin --key="mail")
|
||||||
|
fpm_footprint="low"
|
||||||
|
fpm_free_footprint=0
|
||||||
|
fpm_usage="low"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
@ -53,6 +56,9 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=random_key --value=$random_key
|
ynh_app_setting_set --app=$app --key=random_key --value=$random_key
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -102,7 +108,7 @@ chown -R $app:www-data "$final_path"
|
||||||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM config
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -132,15 +138,11 @@ chown -R $app:www-data "$final_path"
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
|
|
||||||
config="$final_path/.env"
|
config="$final_path/.env"
|
||||||
cp ../conf/.env "$config"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
|
ynh_add_config --template=../conf/.env --destination=$final_path/.env
|
||||||
ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
|
chmod 600 $final_path/.env
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
|
chown $app:$app $final_path/.env
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__EMAIL__" --replace_string="$email" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEPLOY
|
# DEPLOY
|
||||||
|
@ -157,8 +159,8 @@ pushd "$final_path"
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:client --password -n > key.txt
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:client --password -n > key.txt
|
||||||
mobile_id=$( cd $final_path && tail -2 key.txt | head -1 | cut -c 12- )
|
mobile_id=$( cd $final_path && tail -2 key.txt | head -1 | cut -c 12- )
|
||||||
mobile_key=$( cd $final_path && tail -1 key.txt | cut -c 16- )
|
mobile_key=$( cd $final_path && tail -1 key.txt | cut -c 16- )
|
||||||
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$final_path/.env"
|
||||||
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$final_path/.env"
|
||||||
ynh_app_setting_set --app=$app --key=mobile_id --value=$mobile_id
|
ynh_app_setting_set --app=$app --key=mobile_id --value=$mobile_id
|
||||||
ynh_app_setting_set --app=$app --key=mobile_key --value=$mobile_key
|
ynh_app_setting_set --app=$app --key=mobile_key --value=$mobile_key
|
||||||
ynh_secure_remove --file="$final_path/key.txt"
|
ynh_secure_remove --file="$final_path/key.txt"
|
||||||
|
@ -166,20 +168,22 @@ pushd "$final_path"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$final_path/.env"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$final_path/.env"
|
||||||
chown $app:$app "$config"
|
chown $app:$app "$final_path/.env"
|
||||||
|
|
||||||
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL THE CRON FILE
|
# INSTALL THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing the cron file..."
|
ynh_script_progression --message="Setuping a cron..." --weight=1
|
||||||
|
|
||||||
echo "* * * * * -u $app /usr/bin/php$phpversion $final_path/artisan schedule:run" > /tmp/cron$app
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
mv /tmp/cron$app /etc/cron.d/$app
|
|
||||||
|
chown root: "/etc/cron.d/$app"
|
||||||
|
chmod 644 "/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -34,6 +34,9 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -63,10 +66,6 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
config="$final_path/.env"
|
|
||||||
chmod 400 "$config"
|
|
||||||
chown $app:$app "$config"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,6 +85,9 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
# Recreate a dedicated php-fpm config
|
||||||
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -27,6 +27,10 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
|
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
|
||||||
email=$(ynh_user_get_info --username=$admin --key=mail)
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
|
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
|
||||||
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -56,6 +60,24 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
|
# If fpm_footprint doesn't exist, create it
|
||||||
|
if [ -z "$fpm_footprint" ]; then
|
||||||
|
fpm_footprint=low
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If fpm_free_footprint doesn't exist, create it
|
||||||
|
if [ -z "$fpm_free_footprint" ]; then
|
||||||
|
fpm_free_footprint=0
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If fpm_usage doesn't exist, create it
|
||||||
|
if [ -z "$fpm_usage" ]; then
|
||||||
|
fpm_usage=low
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
|
fi
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
# Cleaning legacy permissions
|
||||||
if ynh_legacy_permissions_exists; then
|
if ynh_legacy_permissions_exists; then
|
||||||
ynh_legacy_permissions_delete_all
|
ynh_legacy_permissions_delete_all
|
||||||
|
@ -132,17 +154,9 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
config="$final_path/.env"
|
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
||||||
ynh_backup_if_checksum_is_different --file="$config"
|
|
||||||
cp ../conf/.env "$config"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
|
ynh_add_config --template=../conf/.env --destination=$final_path/.env
|
||||||
ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__EMAIL__" --replace_string="$email" --target_file="$config"
|
|
||||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEPLOYMENT
|
# DEPLOYMENT
|
||||||
|
@ -161,16 +175,16 @@ popd
|
||||||
if [ -f $final_path/storage/oauth-private.key ]; then
|
if [ -f $final_path/storage/oauth-private.key ]; then
|
||||||
mobile_id=$(ynh_app_setting_get --app=$app --key=mobile_id)
|
mobile_id=$(ynh_app_setting_get --app=$app --key=mobile_id)
|
||||||
mobile_key=$(ynh_app_setting_get --app=$app --key=mobile_key)
|
mobile_key=$(ynh_app_setting_get --app=$app --key=mobile_key)
|
||||||
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$final_path/.env"
|
||||||
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$final_path/.env"
|
||||||
else
|
else
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:keys
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:keys
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:client --password -n > key.txt
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan passport:client --password -n > key.txt
|
||||||
mobile_id=$( tail -2 key.txt | head -1 | cut -c 12- )
|
mobile_id=$( tail -2 key.txt | head -1 | cut -c 12- )
|
||||||
mobile_key=$( tail -1 key.txt | cut -c 16- )
|
mobile_key=$( tail -1 key.txt | cut -c 16- )
|
||||||
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_ID__" --replace_string="$mobile_id" --target_file="$final_path/.env"
|
||||||
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$config"
|
ynh_replace_string --match_string="__MOBILE_KEY__" --replace_string="$mobile_key" --target_file="$final_path/.env"
|
||||||
ynh_app_setting_set --app=$app --key=mobile_id --value=$mobile_id
|
ynh_app_setting_set --app=$app --key=mobile_id --value=$mobile_id
|
||||||
ynh_app_setting_set --app=$app --key=mobile_key --value=$mobile_key
|
ynh_app_setting_set --app=$app --key=mobile_key --value=$mobile_key
|
||||||
ynh_secure_remove --file="$final_path/key.txt"
|
ynh_secure_remove --file="$final_path/key.txt"
|
||||||
|
@ -188,10 +202,10 @@ if ynh_version_gt "2.15.0" "${previous_version}" ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$final_path/.env"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$final_path/.env"
|
||||||
chown $app:$app "$config"
|
chown $app:$app "$final_path/.env"
|
||||||
|
|
||||||
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue