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

Merge branch 'testing' into new-PF-version

This commit is contained in:
yalh76 2022-01-11 20:08:34 +01:00
commit 30a648f546
7 changed files with 86 additions and 100 deletions

View file

@ -1 +1 @@
* * * * * /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan schedule:run >> /dev/null 2>&1
* * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan schedule:run >> /dev/null 2>&1

View file

@ -19,43 +19,5 @@ pkg_dependencies="postgresql libgd3 jpegoptim optipng pngquant ffmpeg imagemagic
#=================================================
#=================================================
# REDIS HELPERS
# FUTURE OFFICIAL HELPERS
#=================================================
# get the first available redis database
#
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result="$(redis-cli INFO keyspace)"
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
fi
db=-1
done
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db"
}
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_redis_remove_db database
# | arg: database - the database to erase
ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source ynh_supervisor
source /usr/share/yunohost/helpers
@ -183,9 +184,6 @@ ynh_script_progression --message="Installing the cron file..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source ynh_supervisor
source /usr/share/yunohost/helpers
@ -43,6 +44,14 @@ ynh_script_progression --message="Stopping and removing the supervisor service..
# Remove the dedicated supervisor config
ynh_remove_supervisor_config --service="${app}-horizon"
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
@ -90,29 +99,16 @@ ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing the cron file..."
ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE THE LOG FILE
#=================================================
ynh_script_progression --message="Removing the log file..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"

View file

@ -43,7 +43,8 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
@ -85,25 +86,6 @@ ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$p
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_script_progression --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# CREATE LOG FILE
#=================================================
ynh_script_progression --message="Creating log file..."
mkdir -p "/var/log/$app/"
touch "/var/log/$app/${app}-horizon.log"
chown -R $app: "/var/log/$app/"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -122,6 +104,17 @@ ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/cron.d/$app"
mkdir -p "/var/log/$app/"
touch "/var/log/$app/${app}-horizon.log"
chown -R $app: "/var/log/$app/"
#=================================================
# RESTORE SUPERVISOR CONFIGURATION
#=================================================
@ -130,6 +123,13 @@ ynh_script_progression --message="Restoring the supervisor configuration..."
ynh_restore_file --origin_path="/etc/supervisor/conf.d/${app}-horizon.conf"
supervisorctl reread && supervisorctl update
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -144,13 +144,6 @@ ynh_script_progression --message="Starting a supervisor service..."
ynh_supervisor_action --service_name="${app}-horizon" --action="reload" --log_path="systemd" --line_match="success: ${app}-horizon"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_redis
source ynh_supervisor
source /usr/share/yunohost/helpers
@ -53,9 +54,18 @@ ynh_clean_setup () {
ynh_abort_if_errors
#=================================================
# ENSURE UPGRADE COMPATIBILITY
# STANDARD UPGRADE STEPS
#=================================================
ynh_script_progression --message="Ensuring upgrade compatibility..."
# STOP SUPERVISOR SERVICE
#=================================================
ynh_script_progression --message="Stopping a supervisor service..."
ynh_supervisor_action --service_name="${app}-horizon" --action="stop" --log_path="systemd" --line_match="stopped: ${app}-horizon"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
@ -131,22 +141,13 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SUPERVISOR SERVICE
#=================================================
ynh_script_progression --message="Stopping a supervisor service..."
ynh_supervisor_action --service_name="${app}-horizon" --action="stop" --log_path="systemd" --line_match="stopped: ${app}-horizon"
#=================================================
# CREATE DEDICATED USER
#=================================================
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"
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -246,9 +247,6 @@ ynh_script_progression --message="Upgrading cron file..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# SETUP SUPERVISOR
#=================================================

39
scripts/ynh_redis Normal file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# get the first available redis database
#
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result="$(redis-cli INFO keyspace)"
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
fi
db=-1
done
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db"
}
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_redis_remove_db database
# | arg: database - the database to erase
ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}