1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/streams_ynh.git synced 2024-09-03 20:26:20 +02:00

Try to solve some testing errors

This commit is contained in:
dragondaddy 2024-09-02 22:02:47 +02:00
parent 15f44fec27
commit c0a801acf4
9 changed files with 32 additions and 194 deletions

View file

@ -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

View file

@ -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."

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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 <HOST>.*$"
ynh_config_add_fail2ban --logpath="/var/log/$app/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$"
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"

View file

@ -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
#=================================================

View file

@ -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

View file

@ -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"