mirror of
https://github.com/YunoHost-Apps/monica_ynh.git
synced 2024-09-03 19:46:23 +02:00
Cleaning
This commit is contained in:
parent
9fbc6c00e2
commit
54e4ae6bc0
5 changed files with 19 additions and 107 deletions
1
conf/cron
Normal file
1
conf/cron
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan schedule:run
|
|
@ -28,6 +28,7 @@ language=$YNH_APP_ARG_LANGUAGE
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
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")
|
||||||
|
phpversion=$YNH_PHP_VERSION
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing composer dependencies..."
|
ynh_script_progression --message="Installing composer dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" --install_args="--ignore-platform-req=ext-redis"
|
ynh_exec_warn_less ynh_install_composer --install_args="--ignore-platform-req=ext-redis"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
|
@ -130,43 +131,39 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
ynh_script_progression --message="Adding a configuration file..."
|
||||||
|
|
||||||
|
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- )
|
||||||
|
|
||||||
|
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_add_config --template="../conf/.env" --destination="$final_path/.env"
|
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||||
|
chmod 400 "$final_path/.env"
|
||||||
|
chown $app:$app "$final_path/.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEPLOY
|
# DEPLOY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Deploying..."
|
ynh_script_progression --message="Deploying..."
|
||||||
|
|
||||||
update-alternatives --set php /usr/bin/php$phpversion
|
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn run production
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn run production
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan setup:production --force --email=$email --password="$password"
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan setup:production --force --email=$email --password="$password"
|
||||||
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_key=$( cd $final_path && tail -1 key.txt | cut -c 16- )
|
|
||||||
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="$final_path/.env"
|
|
||||||
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_secure_remove --file="$final_path/key.txt"
|
ynh_secure_remove --file="$final_path/key.txt"
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan config:cache
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan config:cache
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 400 "$final_path/.env"
|
|
||||||
chown $app:$app "$final_path/.env"
|
|
||||||
|
|
||||||
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="Installing the cron file..."
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -70,9 +70,8 @@ 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 "$final_path/.env"
|
||||||
chmod 400 "$config"
|
chown $app:$app "$final_path/.env"
|
||||||
chown $app:$app "$config"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
|
|
@ -31,18 +31,9 @@ email=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION NUMBER
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
abort_if_up_to_date
|
|
||||||
# previous function is what defines 'version', more precisely the 'previous version'
|
|
||||||
previous_version="${version}"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,7 +79,7 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..."
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$final_path"
|
||||||
|
@ -128,74 +119,25 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating php dependencies..."
|
ynh_script_progression --message="Updating php dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$final_path" --commands="update" --install_args="--ignore-platform-req=ext-redis"
|
ynh_exec_warn_less ynh_composer_exec --install_args="--no-interaction --no-dev --ignore-platform-req=ext-redis"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
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"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE A CONFIG FILE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
|
||||||
|
|
||||||
config="$final_path/.env"
|
|
||||||
ynh_backup_if_checksum_is_different --file="$config"
|
|
||||||
cp ../conf/.env "$config"
|
|
||||||
|
|
||||||
ynh_add_config --template="../conf/.env" --destination="$config"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEPLOYMENT
|
# DEPLOYMENT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Deploying..."
|
ynh_script_progression --message="Deploying..."
|
||||||
|
|
||||||
update-alternatives --set php /usr/bin/php$phpversion
|
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn run production
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn run production
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan setup:production --force
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan monica:update --force
|
||||||
popd
|
|
||||||
|
|
||||||
if [ -f $final_path/storage/oauth-private.key ]; then
|
|
||||||
mobile_id=$(ynh_app_setting_get --app=$app --key=mobile_id)
|
|
||||||
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_KEY" --replace_string="$mobile_key" --target_file="$config"
|
|
||||||
else
|
|
||||||
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:client --password -n > key.txt
|
|
||||||
mobile_id=$( tail -2 key.txt | head -1 | cut -c 12- )
|
|
||||||
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_KEY" --replace_string="$mobile_key" --target_file="$config"
|
|
||||||
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_secure_remove --file="$final_path/key.txt"
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
pushd "$final_path"
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan config:cache
|
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan config:cache
|
||||||
popd
|
popd
|
||||||
|
|
||||||
if ynh_version_gt "2.15.0" "${previous_version}" ; then
|
|
||||||
ynh_script_progression --message="Upgrading for 2.15.0..."
|
|
||||||
pushd "$final_path"
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion artisan monica:moveavatarstophotosdirectory
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
|
||||||
ynh_store_file_checksum --file="$config"
|
|
||||||
|
|
||||||
chmod 400 "$config"
|
|
||||||
chown $app:$app "$config"
|
|
||||||
|
|
||||||
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
read_json () {
|
|
||||||
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
|
||||||
}
|
|
||||||
|
|
||||||
read_manifest () {
|
|
||||||
if [ -f '../manifest.json' ] ; then
|
|
||||||
read_json '../manifest.json' "$1"
|
|
||||||
else
|
|
||||||
read_json '../settings/manifest.json' "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
abort_if_up_to_date () {
|
|
||||||
version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7')
|
|
||||||
last_version=$(read_manifest 'version')
|
|
||||||
if [ "${version}" = "${last_version}" ]; then
|
|
||||||
ynh_print_info "Up-to-date, nothing to do"
|
|
||||||
ynh_die "" 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_version_gt ()
|
|
||||||
{
|
|
||||||
dpkg --compare-versions "$1" gt "$2"
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue