From c0a801acf4c307844f885fcfe9dac63b61990b44 Mon Sep 17 00:00:00 2001 From: dragondaddy Date: Mon, 2 Sep 2024 22:02:47 +0200 Subject: [PATCH] Try to solve some testing errors --- conf/cronjobs | 5 +-- conf/daily-update.sh | 17 -------- manifest.toml | 17 +++++++- scripts/_common.sh | 4 +- scripts/config | 97 -------------------------------------------- scripts/install | 50 +++++------------------ scripts/remove | 3 -- scripts/restore | 4 +- scripts/upgrade | 29 +------------ 9 files changed, 32 insertions(+), 194 deletions(-) delete mode 100644 conf/daily-update.sh diff --git a/conf/cronjobs b/conf/cronjobs index 3dd3c45..a41a623 100644 --- a/conf/cronjobs +++ b/conf/cronjobs @@ -1,4 +1,3 @@ # Run poller periodically to update your website -*/10 * * * * __APP__ /usr/bin/php__PHP_VERSION__ -f Code/Daemon/Run.php Cron > /dev/null 2>&1 -# Daily software update job -30 05 * * * root /bin/bash __DATA_DIR__/daily-update.sh >> __DATA_DIR__/daily-updates.log 2>&1 +*/10 * * * * __APP__ /usr/bin/php__PHP_VERSION__ -f src/Daemon/Run.php Cron > /dev/null 2>&1 + diff --git a/conf/daily-update.sh b/conf/daily-update.sh deleted file mode 100644 index fff1714..0000000 --- a/conf/daily-update.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# -echo " " -echo "+++ $(date) +++" -echo " " -git_branch="$(cd /var/www/__APP__ && sudo -u __APP__ \ - git branch --show-current)" 2> /dev/null -if echo $git_branch | grep -q "release" -then - echo "$(date) - Updating website..." - (cd /var/www/__APP__ ; sudo -u __APP__ util/udall) -else - echo "$(date) - Updating release branch code..." - (cd /var/www/__APP__ ; sudo -u __APP__ git fetch origin release:release) -fi -echo "$(date) - Daily update finished." - diff --git a/manifest.toml b/manifest.toml index 98f8191..ec4ea65 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Streams" description.en = "Open source fediverse server" description.fr = "Serveur fediverse open source" -version = "24.05.10~ynh1" +version = "24.8.27~ynh1" maintainers = ["Papa Dragon"] @@ -47,6 +47,19 @@ ram.runtime = "50M" [resources] + [resources.sources] + [resources.sources.main] + url = "https://codeberg.org/streams/streams/archive/v24.8.27.tar.gz" + sha256 = "61bc0e0cb088c2644bcc4993f41af449d111a394e559eede75204b504b5fcbbb" + autoupdate.strategy = "latest_forgejo_tag" + autoupdate.version_regex = "^v(.*)$" + + [resources.sources.addons] + url = "https://codeberg.org/streams/streams-addons/archive/47ce10d5f6e855186d10f2373dc7bbe385454cce.tar.gz" + sha256 = "ddea62f2c745ccb29f291813e0a8a24b122c9eba67539fd3a792862c6653b134" + autoupdate.strategy = "latest_forgejo_commit" + autoupdate.upstream = "https://codeberg.org/streams/streams-addons" + [resources.ports] [resources.system_user] @@ -60,7 +73,7 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "php8.2-mbstring, php8.2-cli, php8.2-imagick, php8.2-xml, php8.2-zip, php8.2-curl, php8.2-ldap, php8.2-gd, mariadb-server, php8.2-mysql php8.2-gmp" + packages = "php8.3-mbstring, php8.3-cli, php8.3-imagick, php8.3-xml, php8.3-zip, php8.3-curl, php8.3-ldap, php8.3-gd, mariadb-server, php8.3-mysql php8.3-gmp" [resources.database] type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 519f979..1134a1b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,5 +6,5 @@ # PHP APP SPECIFIC #================================================= -composer_version="2.5.8" -YNH_PHP_VERSION="8.2" +composer_version="2.7.8" +YNH_PHP_VERSION="8.3" diff --git a/scripts/config b/scripts/config index 4fe4408..42973b1 100644 --- a/scripts/config +++ b/scripts/config @@ -3,123 +3,26 @@ source _common.sh source /usr/share/yunohost/helpers -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS #================================================= php_version="$YNH_PHP_VERSION" -current_fpm_footprint=$(ynh_app_setting_get --key=fpm_footprint) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= -get__git_branch_mode() { - # Git branch mode status - git_branch_mode_status="$(cd "$install_dir" && ynh_exec_as_app git branch --show-current)" 2> /dev/null - if echo $git_branch_mode_status | grep -q "release" - then - echo "0" - elif echo $git_branch_mode_status | grep -q "dev" - then - echo "1" - else - ynh_print_warn "Not using \"release\" or \"dev\" branch, please handle this in command line" - exit 0 - fi -} - -get__fpm_footprint() { - # Free footprint value for php-fpm - # Check if current_fpm_footprint is an integer - if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null - then - echo "specific" - else - echo "$current_fpm_footprint" - fi -} - -get__free_footprint() { - # Free footprint value for php-fpm - # Check if current_fpm_footprint is an integer - if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null - then - # If current_fpm_footprint is an integer, that's a numeric value for the footprint - echo "$current_fpm_footprint" - else - echo "0" - fi -} - #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= -set__git_branch_mode() { - if [ "$git_branch_mode" -eq "0" ] - then - # We allow switch back to "release" only if the branch is ahead of "dev" - if [ -z "$(cd "$install_dir" && git log --oneline release..dev)" ] - then - # If git_branch was set to 0, switch to "release" branch - ynh_print_info "Switching to \"release\" branch" - (cd "$install_dir" && ynh_exec_as_app git checkout release) - ynh_print_info "Full update of the website" - (cd /home/yunohost.app/"$app" && bash daily-update.sh >> daily-updates.log 2>&1) - else - ynh_die "\"release\" branch is behind your local \"dev\" branch, rolling back is not allowed here" - exit 1 - fi - elif [ "$git_branch_mode" -eq "1" ]; then - # If git_branch was set to 1, switch to "dev" branch - (cd "$install_dir" && ynh_exec_as_app git checkout dev) - ynh_print_info "Switching to \"dev\" branch" - fi - ynh_app_setting_set --key=git_branch_mode --value="$git_branch_mode" -} - -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | set__fpm_footprint() { -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" != "specific" ] - then -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value="$fpm_footprint" - fi -} - -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | set__fpm_free_footprint() { -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" = "specific" ] - then -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value="$fpm_free_footprint" - fi -} - -#================================================= - ynh_app_config_validate() { _ynh_app_config_validate - - if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | # If fpm_footprint is set to 'specific', use $fpm_free_footprint value. -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" = "specific" ] - then -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_footprint=$fpm_free_footprint - fi - -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" == "0" ] - then - ynh_print_warn "When selecting 'specific', you have to set a footprint value into the field below." - - exit 0 - fi - fi } ynh_app_config_apply() { _ynh_app_config_apply - - ynh_config_add_phpfpm } ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 52ea764..725b29e 100755 --- a/scripts/install +++ b/scripts/install @@ -10,23 +10,14 @@ source /usr/share/yunohost/helpers email=$(ynh_user_get_info --username=$admin --key=mail) upload="256M" random_string="$(ynh_string_random --length=48)" -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="medium" -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0 -#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="medium" -git_branch_mode="0" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression "Storing installation settings..." - ynh_app_setting_set --key=email --value=$email ynh_app_setting_set --key=upload --value=$upload ynh_app_setting_set --key=random_string --value=$random_string -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint -#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage -ynh_app_setting_set --key=git_branch_mode --value="$git_branch_mode" #================================================= # CREATE A DATABASE @@ -41,18 +32,14 @@ ynh_mysql_db_shell \ #================================================= ynh_script_progression "Setting up source files..." -mkdir -p "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" # Download, check integrity, uncompress and patch the source from GitHub -ynh_exec_as_app git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet -git config --system --add safe.directory $install_dir +ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons" -touch "$install_dir/php.log" -mkdir -p "$install_dir/store" -mkdir -p "$install_dir/cache/smarty3" +ynh_exec_as_app mkdir -p "$install_dir/store" +ynh_exec_as_app mkdir -p "$install_dir/cache/smarty3" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -chmod -R 775 $install_dir/store $install_dir/cache +ynh_exec_as_app chmod -R 775 $install_dir/store $install_dir/cache #================================================= # PHP-FPM CONFIGURATION @@ -73,18 +60,7 @@ ynh_script_progression "Pulling in external libraries with Composer..." ynh_composer_install ynh_composer_exec install --no-dev -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" -#================================================= -# ADDONS -#================================================= -ynh_script_progression "Installing addons..." - -pushd $install_dir - ynh_exec_as_app git config pull.rebase false - ynh_exec_as_app util/add_addon_repo https://codeberg.org/streams/streams-addons.git zaddons - cd /var/www/$app/extend/addon/zaddons - ynh_exec_as_app git config pull.rebase false -popd +chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC SETUP @@ -113,9 +89,6 @@ ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htc ynh_store_file_checksum $install_dir/.htconfig.php -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.htconfig.php" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.htconfig.php" - ynh_exec_as_app touch $data_dir/extra_conf.php #================================================= @@ -125,11 +98,6 @@ ynh_script_progression "Setuping cron job..." # Set up cron job ynh_config_add --template="cronjobs" --destination="/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" -# Add daily update script -ynh_config_add --template="daily-update.sh" --destination="/home/yunohost.app/$app/daily-update.sh" -chown root: "/home/yunohost.app/$app/daily-update.sh" #================================================= # SETUP LOGROTATE @@ -145,10 +113,12 @@ ynh_config_add_logrotate "$install_dir/php.log" ynh_script_progression "Configuring Fail2Ban..." # Create a dedicated Fail2Ban config -ynh_config_add_fail2ban --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" +ynh_config_add_fail2ban --logpath="/var/log/$app/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" +ynh_exec_as_app touch "/var/log/$app/php.log" #================================================= # END OF SCRIPT #================================================= - +ls -ld /var/www/$app +namei -l /var/www/streams/index.php ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e6e3b99..ea8bd5c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -23,9 +23,6 @@ ynh_config_remove_fail2ban # Remove a cron file ynh_safe_rm "/etc/cron.d/$app" -# Remove daily updates logfile -ynh_safe_rm "$data_dir/daily-updates.log" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index fd8d6c9..9d4f088 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,8 +11,6 @@ ynh_script_progression "Restoring the app main directory..." ynh_restore "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATABASE #================================================= @@ -20,7 +18,7 @@ ynh_script_progression "Restoring MySQL database..." ynh_mysql_db_shell \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" -ynh_mysql_db_shell < "./db.sql"" +ynh_mysql_db_shell < "./db.sql" #================================================= # RESTORE FAIL2BAN CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 272a128..ef3e090 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,24 +15,6 @@ email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= ynh_script_progression "Ensuring downward compatibility..." -# If fpm_footprint doesn't exist, create it -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ -z "$fpm_footprint" ]; then - fpm_footprint=low -#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint -fi - -# If fpm_free_footprint doesn't exist, create it -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | if [ -z "$fpm_free_footprint" ]; then - fpm_free_footprint=0 -#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint -fi - -# If fpm_usage doesn't exist, create it -#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | if [ -z "$fpm_usage" ]; then - fpm_usage=low -#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage -fi - # Make sure that git_branch_mode exists with relevant value git_branch_mode_status="$(cd "$install_dir" && ynh_exec_as_app git branch --show-current)" 2> /dev/null if echo $git_branch_mode_status | grep -q "release" @@ -67,7 +49,7 @@ then # We make the install cloning the repo mkdir -p "$install_dir" - #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" + chown -R $app:www-data "$install_dir" ynh_exec_as_app git clone https://codeberg.org/streams/streams.git "$install_dir" --quiet git config --system --add safe.directory $install_dir @@ -83,8 +65,6 @@ then mv $data_dir/cache $install_dir/ mv $data_dir/php.log $install_dir/ - #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" - #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/store $install_dir/cache fi @@ -107,7 +87,6 @@ ynh_script_progression "Pulling in external libraries with Composer..." ynh_composer_install ynh_composer_exec install --no-dev -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # ADDONS #================================================= @@ -130,9 +109,6 @@ max_imported_follow=10 ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.htconfig.php" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.htconfig.php" - if [ ! -f $data_dir/extra_conf.php ] then ynh_exec_as_app touch $data_dir/extra_conf.php @@ -145,8 +121,7 @@ ynh_script_progression "Setuping cron job..." # Set up cron job ynh_config_add --template="cronjobs" --destination="/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" + # Add daily update script ynh_config_add --template="daily-update.sh" --destination="/home/yunohost.app/$app/daily-update.sh" chown root: "/home/yunohost.app/$app/daily-update.sh"