mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
bb7b5beb92
commit
4319cbd413
11 changed files with 110 additions and 162 deletions
|
@ -1,4 +0,0 @@
|
||||||
; Additional php.ini defines, specific to this pool of workers.
|
|
||||||
|
|
||||||
php_admin_value[upload_max_filesize] = 50M
|
|
||||||
php_admin_value[post_max_size] = 50M
|
|
|
@ -33,7 +33,7 @@ location __PATH__/ {
|
||||||
location ~* \.php$ {
|
location ~* \.php$ {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
|
|
@ -10,8 +10,8 @@ WorkingDirectory=__INSTALL_DIR__/
|
||||||
Type=simple
|
Type=simple
|
||||||
StandardOutput=append:/var/log/__APP__/daemon.log
|
StandardOutput=append:/var/log/__APP__/daemon.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
ExecStart=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php start
|
ExecStart=/usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/bin/daemon.php start
|
||||||
ExecStop=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php stop
|
ExecStop=/usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/bin/daemon.php stop
|
||||||
PIDFile=__INSTALL_DIR__/daemon.pid
|
PIDFile=__INSTALL_DIR__/daemon.pid
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
InaccessibleDirectories=/home /root /boot /opt /mnt /media
|
InaccessibleDirectories=/home /root /boot /opt /mnt /media
|
||||||
|
|
|
@ -20,7 +20,8 @@ userdoc = "https://wiki.friendi.ca/"
|
||||||
code = "https://github.com/friendica/friendica"
|
code = "https://github.com/friendica/friendica"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = true
|
ldap = true
|
||||||
|
@ -60,6 +61,7 @@ ram.runtime = "50M"
|
||||||
[resources.system_user]
|
[resources.system_user]
|
||||||
|
|
||||||
[resources.install_dir]
|
[resources.install_dir]
|
||||||
|
group = "www-data:r-x"
|
||||||
|
|
||||||
[resources.permissions]
|
[resources.permissions]
|
||||||
main.url = "/"
|
main.url = "/"
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,55 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
(cd "$install_dir" && ynh_exec_as "$app" "php$phpversion" bin/console.php maintenance 1)
|
(cd "$install_dir" && ynh_exec_as_app "php$php_version" bin/console.php maintenance 1)
|
||||||
|
|
||||||
trap '(cd $install_dir && ynh_exec_as $app php$phpversion bin/console.php maintenance 0)' EXIT
|
trap '(cd $install_dir && ynh_exec_as_app php$php_version bin/console.php maintenance 0)' EXIT
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_backup --src_path="/var/log/$app"
|
ynh_backup "/var/log/$app"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-daemon.service"
|
ynh_backup "/etc/systemd/system/$app-daemon.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up the MySQL database..."
|
ynh_print_info "Backing up the MySQL database..."
|
||||||
|
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
ynh_mysql_dump_db > db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -1,32 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3
|
ynh_script_progression "Updating NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN FRIENDICA CONF
|
# MODIFY URL IN FRIENDICA CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Updating the Friendica config..."
|
ynh_print_info "Updating the Friendica config..."
|
||||||
|
|
||||||
ynh_replace_string --match_string="'url' => 'https://.*'," --replace_string="'url' => 'https://$domain'," --target_file="$install_dir/config/local.config.php"
|
ynh_replace --match="'url' => 'https://.*'," --replace="'url' => 'https://$domain'," --file="$install_dir/config/local.config.php"
|
||||||
ynh_store_file_checksum --file="$install_dir/config/local.config.php"
|
ynh_store_file_checksum "$install_dir/config/local.config.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -19,14 +13,14 @@ timezone=$(cat /etc/timezone)
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
ynh_script_progression "Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=email --value="$email"
|
ynh_app_setting_set --key=email --value="$email"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
ynh_script_progression "Setting up 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="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
@ -35,65 +29,64 @@ ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
|
||||||
mkdir -p "$install_dir/view/smarty3"
|
mkdir -p "$install_dir/view/smarty3"
|
||||||
|
|
||||||
chmod -R 775 "$install_dir/view/smarty3"
|
chmod -R 775 "$install_dir/view/smarty3"
|
||||||
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 | chmod -R o-rwx "$install_dir"
|
||||||
chown -R "$app:www-data" "$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"
|
||||||
|
ynh_config_add --template="local-sample.config.php" --destination="$install_dir/config/local.config.php"
|
||||||
ynh_add_config --template="local-sample.config.php" --destination="$install_dir/config/local.config.php"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM configy
|
# Create a dedicated PHP-FPM configy
|
||||||
ynh_add_fpm_config
|
ynh_config_add_phpfpm
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-daemon"
|
ynh_config_add_systemd --service="$app-daemon"
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_config_add_logrotate
|
||||||
|
|
||||||
# Create a dedicated Fail2Ban config
|
# Create a dedicated Fail2Ban config
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
|
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding the LDAP Auth addon configuration file..." --weight=1
|
ynh_script_progression "Adding the LDAP Auth addon configuration file..."
|
||||||
|
|
||||||
# LDAP addon config
|
# LDAP addon config
|
||||||
ynh_add_config --template="addon.config.php" --destination="$install_dir/config/addon.config.php"
|
ynh_config_add --template="addon.config.php" --destination="$install_dir/config/addon.config.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL FRIENDICA
|
# INSTALL FRIENDICA
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Install Friendica..." --weight=1
|
ynh_script_progression "Install Friendica..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
# Import Composer dependencies
|
# Import Composer dependencies
|
||||||
ynh_exec_as "$app" "php$phpversion" bin/composer.phar install --no-dev --quiet
|
ynh_exec_as_app "php$php_version" bin/composer.phar install --no-dev --quiet
|
||||||
|
|
||||||
# Install application
|
# Install application
|
||||||
ynh_exec_as "$app" "php$phpversion" bin/console.php -f "$install_dir/config/local.config.php"
|
ynh_exec_as_app "php$php_version" bin/console.php -f "$install_dir/config/local.config.php"
|
||||||
|
|
||||||
# Enable LDAP Auth addon
|
# Enable LDAP Auth addon
|
||||||
ynh_exec_as "$app" "php$phpversion" bin/console.php addon enable ldapauth
|
ynh_exec_as_app "php$php_version" bin/console.php addon enable ldapauth
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
ynh_systemctl --service="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -16,32 +10,33 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
|
if ynh_hide_warnings yunohost service status "$app" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
ynh_script_progression "Removing $app service integration..."
|
||||||
yunohost service remove "$app-daemon"
|
yunohost service remove "$app-daemon"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEMD SERVICE
|
# REMOVE SYSTEMD SERVICE
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
# Remove the dedicated PHP-FPM config
|
# Remove the dedicated PHP-FPM config
|
||||||
ynh_remove_fpm_config
|
ynh_config_remove_phpfpm
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_config_remove_logrotate
|
||||||
|
|
||||||
ynh_remove_fail2ban_config
|
ynh_config_remove_fail2ban
|
||||||
|
|
||||||
ynh_remove_systemd_config --service="$app-daemon"
|
ynh_config_remove_systemd"$app-daemon"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -13,69 +7,67 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
ynh_script_progression "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore "$install_dir"
|
||||||
|
|
||||||
if [ -f "$install_dir/daemon.pid" ]; then ynh_secure_remove --file="$install_dir/daemon.pid"; fi
|
if [ -f "$install_dir/daemon.pid" ]; then ynh_safe_rm "$install_dir/daemon.pid"; fi
|
||||||
|
|
||||||
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 | chmod -R o-rwx "$install_dir"
|
||||||
chown -R "$app:www-data" "$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/view/smarty3"
|
chmod -R 775 "$install_dir/view/smarty3"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
ynh_script_progression "Restoring the MySQL database..."
|
||||||
|
|
||||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
ynh_mysql_db_shell < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
ynh_script_progression "Restoring system configurations related to $app..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-daemon.service"
|
ynh_restore "/etc/systemd/system/$app-daemon.service"
|
||||||
systemctl enable "$app-daemon.service" --quiet
|
systemctl enable "$app-daemon.service" --quiet
|
||||||
|
|
||||||
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/var/log/$app"
|
ynh_restore "/var/log/$app"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
|
||||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
ynh_systemctl --action=restart --service=fail2ban
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
ynh_systemctl --service="php$php_version-fpm" --action=reload
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
ynh_systemctl --service="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
#==============
|
#==============
|
||||||
# FINALIZATION
|
# FINALIZATION
|
||||||
#==============
|
#==============
|
||||||
|
|
||||||
# exit maintenance mode since the app was backed up while in maintenance mode
|
# exit maintenance mode since the app was backed up while in maintenance mode
|
||||||
(cd "$install_dir" && ynh_exec_as "$app" "php$phpversion" bin/console.php maintenance 0)
|
(cd "$install_dir" && ynh_exec_as_app "php$php_version" bin/console.php maintenance 0)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -1,25 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-daemon" --action="stop" --log_path="/var/log/$app/daemon.log"
|
ynh_systemctl --service="$app-daemon" --action="stop" --log_path="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression "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="$install_dir" --keep="config/local.config.php"
|
ynh_setup_source --dest_dir="$install_dir" --keep="config/local.config.php"
|
||||||
|
@ -27,62 +21,61 @@ ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
|
||||||
|
|
||||||
# clear the smarty cache
|
# clear the smarty cache
|
||||||
# cf: https://github.com/friendica/friendica/issues/11212#issuecomment-1046051750
|
# cf: https://github.com/friendica/friendica/issues/11212#issuecomment-1046051750
|
||||||
ynh_secure_remove --file="$install_dir/view/smarty3/compiled"
|
ynh_safe_rm "$install_dir/view/smarty3/compiled"
|
||||||
mkdir "$install_dir/view/smarty3/compiled"
|
mkdir "$install_dir/view/smarty3/compiled"
|
||||||
chmod -R 775 "$install_dir/view/smarty3"
|
chmod -R 775 "$install_dir/view/smarty3"
|
||||||
|
|
||||||
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 | chmod -R o-rwx "$install_dir"
|
||||||
chown -R "$app:www-data" "$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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM config
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config
|
ynh_config_add_phpfpm
|
||||||
|
|
||||||
ynh_use_logrotate --non-append
|
ynh_config_add_logrotate
|
||||||
|
|
||||||
if [ -f "/etc/cron.d/$app" ]; then
|
if [ -f "/etc/cron.d/$app" ]; then
|
||||||
ynh_print_info --message="Removing the legacy cron..."
|
ynh_print_info "Removing the legacy cron..."
|
||||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
ynh_safe_rm "/etc/cron.d/$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-daemon"
|
ynh_config_add_systemd --service="$app-daemon"
|
||||||
|
|
||||||
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
yunohost service add "$app-daemon" --description="Friendica daemon" --log="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
# Create a dedicated Fail2Ban config
|
# Create a dedicated Fail2Ban config
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
|
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression "Updating configuration..."
|
||||||
|
|
||||||
# fix the url if necessary (there should be no trailing slash)
|
# fix the url if necessary (there should be no trailing slash)
|
||||||
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "'url' => 'https://$domain'," "$install_dir/config/local.config.php"; then
|
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "'url' => 'https://$domain'," "$install_dir/config/local.config.php"; then
|
||||||
ynh_print_info --message="Patching the Friendica config file: fix the domain setting..."
|
ynh_print_info "Patching the Friendica config file: fix the domain setting..."
|
||||||
ynh_replace_string --match_string="'url' => 'https://.*'," --replace_string="'url' => 'https://$domain'," --target_file="$install_dir/config/local.config.php"
|
ynh_replace --match="'url' => 'https://.*'," --replace="'url' => 'https://$domain'," --file="$install_dir/config/local.config.php"
|
||||||
ynh_store_file_checksum --file="$install_dir/config/local.config.php"
|
ynh_store_file_checksum "$install_dir/config/local.config.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add the path to the pidfile if missing
|
# add the path to the pidfile if missing
|
||||||
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "pidfile" "$install_dir/config/local.config.php"; then
|
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "pidfile" "$install_dir/config/local.config.php"; then
|
||||||
ynh_print_info --message="Patching the Friendica config file: add the PID file path for the daemon..."
|
ynh_print_info "Patching the Friendica config file: add the PID file path for the daemon..."
|
||||||
ynh_replace_string --match_string="'basepath' => '$install_dir'," --replace_string="'basepath' => '$install_dir',\n 'pidfile' => '$install_dir/daemon.pid'," --target_file="$install_dir/config/local.config.php"
|
ynh_replace --match="'basepath' => '$install_dir'," --replace="'basepath' => '$install_dir',\n 'pidfile' => '$install_dir/daemon.pid'," --file="$install_dir/config/local.config.php"
|
||||||
ynh_store_file_checksum --file="$install_dir/config/local.config.php"
|
ynh_store_file_checksum "$install_dir/config/local.config.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add log path to the config
|
# add log path to the config
|
||||||
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "logfile" "$install_dir/config/local.config.php"; then
|
if [ -f "$install_dir/config/local.config.php" ] && ! grep -q -e "logfile" "$install_dir/config/local.config.php"; then
|
||||||
ynh_print_info --message="Patching the Friendica config file: add the path for the Friendica logfile..."
|
ynh_print_info "Patching the Friendica config file: add the path for the Friendica logfile..."
|
||||||
ynh_replace_string --match_string="'basepath' => '$install_dir'," --replace_string="'basepath' => '$install_dir',\n 'logfile' => '/var/log/friendica/friendica.log',\n 'loglevel' => 'notice'," --target_file="$install_dir/config/local.config.php"
|
ynh_replace --match="'basepath' => '$install_dir'," --replace="'basepath' => '$install_dir',\n 'logfile' => '/var/log/friendica/friendica.log',\n 'loglevel' => 'notice'," --file="$install_dir/config/local.config.php"
|
||||||
ynh_store_file_checksum --file="$install_dir/config/local.config.php"
|
ynh_store_file_checksum "$install_dir/config/local.config.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -91,19 +84,19 @@ fi
|
||||||
|
|
||||||
# Run Composer
|
# Run Composer
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_exec_as "$app" "php$phpversion" bin/composer.phar install --no-dev --quiet
|
ynh_exec_as_app "php$php_version" bin/composer.phar install --no-dev --quiet
|
||||||
ynh_exec_as "$app" "php$phpversion" bin/console.php dbstructure update
|
ynh_exec_as_app "php$php_version" bin/console.php dbstructure update
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
ynh_systemctl --service="$app-daemon" --action="start" --log_path="/var/log/$app/daemon.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Reference in a new issue