mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
Fix upload
This commit is contained in:
parent
070bcbe2d3
commit
11bd9c69a6
6 changed files with 86 additions and 3 deletions
2
conf/uploads.exs
Normal file
2
conf/uploads.exs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Web.Upload.Uploader.Local, uploads: "__DATADIR__/uploads"
|
|
@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -56,6 +57,14 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/$app/config.exs"
|
||||||
|
|
||||||
|
ynh_backup --src_path="$datadir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -122,7 +122,7 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" -
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$config"
|
||||||
chown $app:www-data "$config"
|
chown $app:$app "$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -133,6 +133,24 @@ ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# CREATE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating the data directory..."
|
||||||
|
|
||||||
|
# Define app's data directory
|
||||||
|
datadir="/home/yunohost.app/${app}"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
|
||||||
|
chmod 750 "$datadir"
|
||||||
|
chmod -R o-rwx "$datadir"
|
||||||
|
chown -R $app:$app "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MAKE SETUP
|
# MAKE SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -159,6 +177,8 @@ popd
|
||||||
|
|
||||||
cat "../conf/ldap.exs" >> "$config"
|
cat "../conf/ldap.exs" >> "$config"
|
||||||
cat "../conf/mail.exs" >> "$config"
|
cat "../conf/mail.exs" >> "$config"
|
||||||
|
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
|
||||||
|
cat "../conf/uploads.exs" >> "$config"
|
||||||
|
|
||||||
pushd $final_path/$app
|
pushd $final_path/$app
|
||||||
chmod o-rwx $config
|
chmod o-rwx $config
|
||||||
|
@ -177,7 +197,7 @@ popd
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$config"
|
||||||
chown $app:www-data "$config"
|
chown $app:$app "$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
|
|
@ -36,6 +36,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
ynh_user_password=$(ynh_app_setting_get --app=$app --key=ynh_user_password)
|
ynh_user_password=$(ynh_app_setting_get --app=$app --key=ynh_user_password)
|
||||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -80,6 +81,22 @@ chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the data directory..."
|
||||||
|
|
||||||
|
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||||
|
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
|
||||||
|
chmod 750 "$datadir"
|
||||||
|
chmod -R o-rwx "$datadir"
|
||||||
|
chown -R $app:$app "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -28,6 +28,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -118,6 +119,40 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DATADIR FOLDER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# If datadir doesn't exist, create it
|
||||||
|
if [ -z "$datadir" ]; then
|
||||||
|
ynh_script_progression --message="Create datadir folder..."
|
||||||
|
|
||||||
|
# Define app's data directory
|
||||||
|
datadir="/home/yunohost.app/${app}"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
|
||||||
|
chmod 750 "$datadir"
|
||||||
|
chmod -R o-rwx "$datadir"
|
||||||
|
chown -R $app:$app "$datadir"
|
||||||
|
|
||||||
|
config="$final_path/$app/config/prod.secret.exs"
|
||||||
|
|
||||||
|
ynh_backup_if_checksum_is_different --file="$config"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
|
||||||
|
cat "../conf/uploads.exs" >> "$config"
|
||||||
|
|
||||||
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
|
chmod 400 "$config"
|
||||||
|
chown $app:$app "$config"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -229,7 +264,7 @@ ynh_backup_if_checksum_is_different --file="$config"
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$config"
|
||||||
chown $app:www-data "$config"
|
chown $app:$app "$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
|
Loading…
Add table
Reference in a new issue