1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00
This commit is contained in:
ericgaspar 2022-04-06 07:27:45 +02:00
parent 5934fb0179
commit a132e7590d
3 changed files with 37 additions and 37 deletions

View file

@ -36,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -47,7 +47,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
@ -58,7 +58,7 @@ ynh_app_setting_set --app=$app --key=random_string --value=$random_string
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
@ -68,7 +68,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
@ -77,7 +77,7 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 1 - Hubzilla
ynh_script_progression --message="Setting up Hubzilla source files..." --weight=2
ynh_script_progression --message="Setting up Hubzilla source files..."
git clone --quiet https://framagit.org/hubzilla/core.git "$final_path"
@ -88,7 +88,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$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..." --weight=2
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..."
@ -123,7 +123,7 @@ pushd "$final_path"
popd
# 3 - Some extra folders
ynh_script_progression --message="Creating smarty3 folder for personal data..." --weight=2
ynh_script_progression --message="Creating smarty3 folder for personal data..."
mkdir -p "${final_path}/store/[data]/smarty3"
chmod -R 775 $final_path/store
@ -135,7 +135,7 @@ chmod -R 775 $final_path/store
#cp $final_path/install/htconfig.sample.php $config
# Create php.log inside Hubzilla for logs
ynh_script_progression --message="Create php.log for the Hubzilla debuging..." --weight=2
ynh_script_progression --message="Create php.log for the Hubzilla debuging..."
touch "$final_path/php.log"
chmod 750 "$final_path"
@ -145,7 +145,7 @@ chown -R $app:www-data "$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=2
ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
@ -157,7 +157,7 @@ ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
@ -167,7 +167,7 @@ chown $app:$app "$final_path/.htconfig.php"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
@ -175,7 +175,7 @@ ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
@ -184,7 +184,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CRON CONFIGURATION
#=================================================
ynh_script_progression --message="Set up cron job..." --weight=1
ynh_script_progression --message="Set up cron job..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
@ -193,7 +193,7 @@ chmod 644 "/etc/cron.d/$app"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log"
@ -201,14 +201,14 @@ ynh_use_logrotate "$final_path/php.log"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Add Fail2Ban..." --weight=1
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"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -216,4 +216,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression --message="Installation of $app completed"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1
ynh_script_progression --message="Removing the MySQL database..."
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
@ -34,14 +34,14 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
ynh_script_progression --message="Removing app main directory..."
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
@ -49,7 +49,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
@ -57,7 +57,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
ynh_script_progression --message="Removing dependencies..."
ynh_remove_app_dependencies
@ -79,7 +79,7 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
ynh_script_progression --message="Removing Fail2Ban configuration..."
ynh_remove_fail2ban_config
@ -88,7 +88,7 @@ ynh_remove_fail2ban_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -27,7 +27,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
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
@ -41,7 +41,7 @@ ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
@ -65,7 +65,7 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
@ -75,7 +75,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=5
ynh_script_progression --message="Upgrading source files..."
if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then
pushd "$final_path"
@ -143,7 +143,7 @@ chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
@ -151,7 +151,7 @@ ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
@ -172,7 +172,7 @@ ynh_store_file_checksum --file="$final_path/.htconfig.php"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
@ -180,14 +180,14 @@ ynh_use_logrotate --non-append
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Re-configure Fail2Ban..." --weight=1
ynh_script_progression --message="Re-configure Fail2Ban..."
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# UPGRADE CRON
#=================================================
ynh_script_progression --message="Re-configure CRON..." --weight=1
ynh_script_progression --message="Re-configure CRON..."
# Set up cron job
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
@ -197,7 +197,7 @@ chmod 644 "/etc/cron.d/$app"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -205,4 +205,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression --message="Upgrade of $app completed"