mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
commit
42aede06da
7 changed files with 97 additions and 13 deletions
|
@ -28,8 +28,6 @@
|
||||||
upgrade=1 from_commit=cba843be0d7e00d7d7290f0d0da95807711a96d4
|
upgrade=1 from_commit=cba843be0d7e00d7d7290f0d0da95807711a96d4
|
||||||
# 1.1.0~ynh1
|
# 1.1.0~ynh1
|
||||||
upgrade=1 from_commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
upgrade=1 from_commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
||||||
# 1.1.0~ynh1
|
|
||||||
upgrade=1 from_commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
|
@ -52,5 +50,3 @@ Notification=all
|
||||||
name=1.0.7~ynh1
|
name=1.0.7~ynh1
|
||||||
; commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
; commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
||||||
name=1.1.0~ynh1
|
name=1.1.0~ynh1
|
||||||
; commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e
|
|
||||||
name=1.1.0~ynh1
|
|
||||||
|
|
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,12 @@ 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="$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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -148,6 +166,8 @@ pushd $final_path/$app/js
|
||||||
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_secure_remove --file="$final_path/$app/js"
|
||||||
|
|
||||||
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
||||||
pushd $final_path/$app
|
pushd $final_path/$app
|
||||||
sudo -u "$app" MIX_ENV=prod mix local.hex --force
|
sudo -u "$app" MIX_ENV=prod mix local.hex --force
|
||||||
|
@ -159,6 +179,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
|
||||||
|
@ -174,10 +196,12 @@ pushd $final_path/$app
|
||||||
sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
|
sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_secure_remove --file="$final_path/.cache"
|
||||||
|
|
||||||
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
|
||||||
|
@ -126,6 +127,44 @@ ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
# Create a dedicated user (if not existing)
|
# 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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
rsync -a $final_path/$app/uploads/ $datadir/uploads/
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
ynh_secure_remove --file="$final_path/$app/uploads"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -140,9 +179,6 @@ then
|
||||||
# Backup the config file in the temp dir
|
# Backup the config file in the temp dir
|
||||||
cp -af "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
|
cp -af "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
|
||||||
|
|
||||||
# Backup upload dir
|
|
||||||
rsync -a "$final_path/$app/uploads" "$tmpdir/."
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path/$app"
|
ynh_secure_remove --file="$final_path/$app"
|
||||||
|
|
||||||
|
@ -152,9 +188,6 @@ then
|
||||||
# Restore the config file
|
# Restore the config file
|
||||||
cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
|
cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
|
||||||
|
|
||||||
# Restore upload dir
|
|
||||||
rsync -a "$tmpdir/uploads" "$final_path/$app/."
|
|
||||||
|
|
||||||
# Remove the tmp directory securely
|
# Remove the tmp directory securely
|
||||||
ynh_secure_remove --file="$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
fi
|
fi
|
||||||
|
@ -196,8 +229,11 @@ pushd $final_path/$app/js
|
||||||
sudo -u $app env PATH=$PATH yarn install
|
sudo -u $app env PATH=$PATH yarn install
|
||||||
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
|
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
|
||||||
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
||||||
|
sudo -u $app env PATH=$PATH yarn cache clean --all
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_secure_remove --file="$final_path/$app/js"
|
||||||
|
|
||||||
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
||||||
pushd $final_path/$app
|
pushd $final_path/$app
|
||||||
sudo -u "$app" MIX_ENV=prod mix local.hex --force
|
sudo -u "$app" MIX_ENV=prod mix local.hex --force
|
||||||
|
@ -207,6 +243,8 @@ pushd $final_path/$app
|
||||||
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
|
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_secure_remove --file="$final_path/.cache"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RUN APP MIGRATIONS
|
# RUN APP MIGRATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -229,7 +267,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