mirror of
https://github.com/YunoHost-Apps/hubzilla_ynh.git
synced 2024-09-03 19:26:21 +02:00
Upgrade to version PHP8.1
This commit is contained in:
parent
c9480001d2
commit
8e1bcc8415
7 changed files with 100 additions and 119 deletions
|
@ -100,4 +100,3 @@ App::$config['ldapauth']['ldap_searchdn'] = 'ou=users,dc=yunohost,dc=org';
|
|||
App::$config['ldapauth']['ldap_userattr'] = 'uid';
|
||||
App::$config['ldapauth']['ldap_autocreateaccount_emailattribute'] = 'mail';
|
||||
App::$config['ldapauth']['create_account'] = '1';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
},
|
||||
"services": [
|
||||
"nginx",
|
||||
"php7.3-fpm",
|
||||
"php8.1-fpm",
|
||||
"mysql",
|
||||
"postgresql"
|
||||
],
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
# dependencies used by the app
|
||||
YNH_PHP_VERSION="8.1"
|
||||
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd"
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="postgresql postgresql-contrib"
|
||||
pkg_dependencies="postgresql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -73,9 +73,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
if [ $database -eq 2 ]; then
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
fi
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -87,17 +85,11 @@ ynh_script_progression --message="Setting up Hubzilla source files..."
|
|||
git clone --quiet https://framagit.org/hubzilla/core.git "$final_path"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
# 2 - Hubzilla Addons
|
||||
|
||||
# Make addon Directory and unpack the Hubzilla addons to this directory
|
||||
ynh_script_progression --message="Create addon directory inside Hubzilla root folder..."
|
||||
# mkdir $final_path/addon
|
||||
# ynh_script_progression --message="Setting up Hubzilla addons source files..."
|
||||
|
||||
# ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
|
||||
|
||||
pushd "$final_path"
|
||||
mkdir -p extend/addon/hzaddons
|
||||
|
@ -147,6 +139,16 @@ chmod 750 "$final_path"
|
|||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
|
||||
|
||||
chmod 400 "$final_path/.htconfig.php"
|
||||
chown $app:$app "$final_path/.htconfig.php"
|
||||
|
||||
#=================================================
|
||||
# CREATE A DATABASE
|
||||
#=================================================
|
||||
|
@ -157,52 +159,21 @@ if [ $database -eq 1 ]; then
|
|||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
ynh_script_progression --message="Importing database..."
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
|
||||
elif [ $database -eq 2 ]; then
|
||||
# Create postgresql database
|
||||
ynh_script_progression --message="Creating a postgresql database..."
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_script_progression --message="Importing database..."
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
|
||||
else
|
||||
ynh_die --message="Some problem occured in creating the database, contact maintainer"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config"
|
||||
ynh_replace_string --match_string= "mysqlpassword" --replace_string="$db_pwd" --target_file="$config"
|
||||
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_user" --target_file="$config"
|
||||
ynh_replace_string --match_string= "mysqldatabasename" --replace_string="$db_name" --target_file="$config"
|
||||
ynh_replace_string --match_string= "mysite.example" --replace_string="$domain" --target_file="$config"
|
||||
ynh_replace_string --match_string= "if the auto install failed, put a unique random string here" --replace_string="$random_string" --target_file="$config"
|
||||
sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" "$config"
|
||||
ynh_replace_string --match_string= "//error_reporting(E_ERROR | E_WARNING | E_PARSE );" --replace_string="error_reporting(E_ERROR | E_WARNING | E_PARSE );" --target_file="$config"
|
||||
ynh_replace_string --match_string= "//ini_set('error_log','php.out');" --replace_string="ini_set('error_log','php.log');" --target_file="$config"
|
||||
ynh_replace_string --match_string= "//ini_set('log_errors','1');" --replace_string="ini_set('log_errors','1');" --target_file="$config"
|
||||
ynh_replace_string --match_string= "//ini_set('display_errors', '0');" --replace_string="ini_set('display_errors', '0');" --target_file="$config"
|
||||
sed -i "s/\['php_path'\] = 'php';/\['php_path'\] = 'php$phpversion';/g" "$config"
|
||||
|
||||
|
||||
#ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
|
||||
|
||||
|
||||
# addon ldap config
|
||||
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
|
||||
|
||||
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -217,7 +188,13 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Configuring PHP-FPM..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
#CRON JOB CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Cron..."
|
||||
|
||||
# Set up cron job
|
||||
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
|
||||
|
@ -239,14 +216,6 @@ ynh_script_progression --message="Add Fail2Ban..."
|
|||
|
||||
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
# As Hubzilla is social network and have its own permission there is no need to keep Hubzilla behind SSO
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
|
@ -18,7 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user="$db_name"
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||
|
||||
|
@ -34,18 +34,10 @@ if [ $database -eq 1 ]; then
|
|||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
elif [ $database -eq 2 ]; then
|
||||
# Removing PostgreSQL database
|
||||
ynh_script_progression --message="Removing postgresql database..."
|
||||
ynh_script_progression --message="Removing PostgreSQL database..."
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -70,6 +62,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..."
|
|||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -32,8 +32,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
|
@ -42,8 +42,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
|
@ -77,18 +75,13 @@ chown -R $app:www-data "$final_path"
|
|||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..."
|
||||
|
||||
if [ $database -eq 1 ]; then
|
||||
ynh_script_progression --message="Restoring MySQL database..."
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
elif [ $database -eq 2 ]; then
|
||||
# Removing postgresql database
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_test_if_first_run
|
||||
|
@ -103,8 +96,16 @@ ynh_script_progression --message="Restoring PHP-FPM configuration..."
|
|||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
# Recreate a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -117,6 +118,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
|
|
|
@ -24,6 +24,21 @@ version=$(grep STD_VERSION $final_path/boot.php | cut -c 38- | rev | cut -c 5-
|
|||
last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
|
||||
database=$(ynh_app_setting_get --app=$app --key=database)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -48,20 +63,6 @@ if ynh_legacy_permissions_exists; then
|
|||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -148,13 +149,25 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading PHP-FPM configuration..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
|
@ -182,30 +195,31 @@ ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
if [ $database -eq 1 ]; then
|
||||
#=================================================
|
||||
# CHECK VERSION FOR SPECIFIC MYSQL UPDATE
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
# Check version and if this version was a fresh install push mysql query
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
is_version_equal_three_eight_four=$(awk 'BEGIN{ print "'$version'"<"'3.8.4'" }')
|
||||
if [ -z "$last_update" ] && [ "$is_version_equal_three_eight_four" -eq 1 ]; then
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/385.sql"
|
||||
fi
|
||||
# if [ $database -eq 1 ]; then
|
||||
# #=================================================
|
||||
# # CHECK VERSION FOR SPECIFIC MYSQL UPDATE
|
||||
# #=================================================
|
||||
|
||||
elif [ $database -eq 2 ]; then
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
fi
|
||||
is_version_less_then_five=$(awk 'BEGIN{ print "'$version'"<"'5.0.0'" }')
|
||||
# # Check version and if this version was a fresh install push mysql query
|
||||
# db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
# db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
# is_version_equal_three_eight_four=$(awk 'BEGIN{ print "'$version'"<"'3.8.4'" }')
|
||||
# if [ -z "$last_update" ] && [ "$is_version_equal_three_eight_four" -eq 1 ]; then
|
||||
# ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/385.sql"
|
||||
# fi
|
||||
|
||||
if [ "$is_version_less_then_five" -eq 1 ] && [ -f "$final_path/util/z6convert.php" ] ; then
|
||||
pushd "$final_path"
|
||||
php${YNH_PHP_VERSION} util/z6convert.php
|
||||
popd
|
||||
fi
|
||||
# elif [ $database -eq 2 ]; then
|
||||
# ynh_install_app_dependencies $pkg_dependencies
|
||||
# fi
|
||||
# is_version_less_then_five=$(awk 'BEGIN{ print "'$version'"<"'5.0.0'" }')
|
||||
|
||||
# if [ "$is_version_less_then_five" -eq 1 ] && [ -f "$final_path/util/z6convert.php" ] ; then
|
||||
# pushd "$final_path"
|
||||
# php${YNH_PHP_VERSION} util/z6convert.php
|
||||
# popd
|
||||
# fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
|
Loading…
Add table
Reference in a new issue