From f97b72a21a7292eaba11803d1a4e414bce5c1e8d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 18 May 2021 14:15:30 +0200 Subject: [PATCH] Fix --- scripts/_common.sh | 68 ++++++---------------------------------------- scripts/backup | 5 ++++ scripts/install | 10 +++++-- scripts/upgrade | 34 ++++++++++------------- 4 files changed, 35 insertions(+), 82 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 48045d0..6e38880 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,72 +5,20 @@ #================================================= YNH_PHP_VERSION=7.4 -YNH_COMPOSER_VERSION=2.0.8 +YNH_COMPOSER_VERSION=2.0.13 extra_php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-exif php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysqli php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-zip" # needed for raw upload and video playback pkg_dependencies="ufraw-batch ffmpeg" +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # EXPERIMENTAL HELPERS #================================================= -# readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 -# # Declare the actual composer version to use. -# # A packager willing to use another version of composer can override the variable into its _common.sh. -# YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} - -# # Execute a command with Composer -# # -# # usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# # | arg: -v, --phpversion - PHP version to use with composer -# # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# # | arg: -c, --commands - Commands to execute. -# ynh_composer_exec () { -# # Declare an array to define the options of this helper. -# local legacy_args=vwc -# declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) -# local phpversion -# local workdir -# local commands -# # Manage arguments with getopts -# ynh_handle_getopts_args "$@" -# workdir="${workdir:-$final_path}" -# phpversion="${phpversion:-$YNH_PHP_VERSION}" - -# COMPOSER_HOME="$workdir/.composer" \ -# php${phpversion} "$workdir/composer.phar" $commands \ -# -d "$workdir" --quiet --no-interaction -# } - -# # Install and initialize Composer in the given directory -# # -# # usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] -# # | arg: -v, --phpversion - PHP version to use with composer -# # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# # | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include -# # | arg: -c, --composerversion - Composer version to install -# ynh_install_composer () { -# # Declare an array to define the options of this helper. -# local legacy_args=vwa -# declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) -# local phpversion -# local workdir -# local install_args -# local composerversion -# # Manage arguments with getopts -# ynh_handle_getopts_args "$@" -# workdir="${workdir:-$final_path}" -# phpversion="${phpversion:-$YNH_PHP_VERSION}" -# install_args="${install_args:-}" -# composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" - -# curl -sS https://getcomposer.org/installer 2>&1 \ -# | COMPOSER_HOME="$workdir/.composer" \ -# php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ -# || ynh_die "Unable to install Composer." 2>&1 - -# # update dependencies to create composer.lock -# ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ -# || ynh_die "Unable to update core dependencies with Composer." -# } +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index e5ee3e8..7645bce 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,11 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/install b/scripts/install index 2680a41..4beb733 100755 --- a/scripts/install +++ b/scripts/install @@ -129,15 +129,19 @@ pushd $final_path popd # Setup custom user.css file -cp ../conf/user.css.example $final_path/public/dist/user.css +ynh_add_config --template="../conf/user.css.example" --destination="$final_path/public/dist/user.css" #================================================= # SECURE FILES AND DIRECTORIES #================================================= # Set permissions to app files -chown -R $app: $final_path -chmod 750 $final_path/bootstrap/cache + +chmod 750 "$final_path" +chmod 750 "$final_path/bootstrap/cache" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + chown -R $app: $public_path chmod 755 $public_path diff --git a/scripts/upgrade b/scripts/upgrade index e4aa069..0310bbf 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,7 +28,6 @@ version=ynh_app_upstream_version #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -77,6 +76,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -91,11 +98,8 @@ then cp -a "$final_path/public/uploads" "$public_path/uploads" fi - # Remove the app directory securely - ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="$final_path/public/dist/user.css" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/public/dist/user.css $final_path/.env" fi #================================================= @@ -113,14 +117,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=6 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -134,15 +130,15 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie #================================================= ynh_script_progression --message="Installing Composer..." --weight=1 -ynh_install_composer --workdir="$final_path" --install_args="--ignore-platform-reqs" +ynh_install_composer --install_args="--ignore-platform-reqs" #================================================= # SETUP APPLICATION CONFIG #================================================= -ynh_script_progression --message="Setting Lychee config..." +# ynh_script_progression --message="Setting Lychee config..." -# Setup application config -ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" +# # Setup application config +# ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" #================================================= # INSTALL AND INITIALIZE COMPOSER @@ -152,8 +148,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading Lychee source files..." --weight=4 pushd $final_path - php$phpversion artisan key:generate --no-interaction --force - php$phpversion artisan migrate --no-interaction --force + php$phpversion artisan key:generate -n --force + php$phpversion artisan migrate -n --force popd fi