mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
Manage upgrade to 1.2.2
This commit is contained in:
parent
13a993aacc
commit
eb11b7d7dd
5 changed files with 93 additions and 24 deletions
8
conf/geolix.exs
Normal file
8
conf/geolix.exs
Normal file
|
@ -0,0 +1,8 @@
|
|||
config :geolix,
|
||||
databases: [
|
||||
%{
|
||||
id: :city,
|
||||
adapter: Geolix.Adapter.MMDB2,
|
||||
source: "__DATADIR__/geo/dbip-city-lite-2021-07.mmdb"
|
||||
}
|
||||
]
|
7
conf/geolix.src
Normal file
7
conf/geolix.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://download.db-ip.com/free/dbip-city-lite-2021-07.mmdb.gz
|
||||
SOURCE_SUM=646a612147dfeedba438d0752b82bee969ca8c315c0f497ca05192cbcc42a20e
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=dbip-city-lite-2021-07.mmdb.gz
|
||||
SOURCE_EXTRACT=true
|
|
@ -113,7 +113,7 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
|
||||
config="$final_path/$app/config/prod.secret.exs"
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
|
||||
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
|
||||
|
|
|
@ -144,6 +144,8 @@ ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
|||
mkdir -p $datadir
|
||||
mkdir -p "$datadir/uploads/"
|
||||
|
||||
ynh_setup_source --dest_dir="$datadir/geo"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
@ -153,7 +155,7 @@ chown -R $app:$app "$datadir"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies and building app..." --weight=5
|
||||
|
||||
config="$final_path/$app/config/prod.secret.exs"
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
|
||||
pushd $final_path/$app/js
|
||||
ynh_use_nodejs
|
||||
|
@ -179,6 +181,13 @@ cat "../conf/mail.exs" >> "$config"
|
|||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
|
||||
cat "../conf/uploads.exs" >> "$config"
|
||||
|
||||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/geolix.exs"
|
||||
cat "../conf/geolix.exs" >> "$config"
|
||||
ynh_setup_source --dest_dir="$datadir/geo"
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
pushd $final_path/$app
|
||||
chmod o-rwx $config
|
||||
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
|
||||
|
|
|
@ -86,10 +86,6 @@ ynh_secure_remove --file="$final_path/$app/priv/data/GeoLite2-City.mmdb"
|
|||
|
||||
ynh_secure_remove --file="/usr/share/GeoIP"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE FROM PREVIOUS VERSION
|
||||
#=================================================
|
||||
|
||||
if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
||||
ynh_script_progression --message="Upgrade configuration to 1.0.0..."
|
||||
|
||||
|
@ -105,8 +101,8 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
|||
ynh_secure_remove --file="$final_path/$app/.env"
|
||||
|
||||
# Configure Mobilizon
|
||||
config="$final_path/$app/config/prod.secret.exs"
|
||||
ynh_add_config --template="../conf/prod.secret.exs" --destination="$config"
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
ynh_add_config --template="../conf/runtime.exs" --destination="$config"
|
||||
|
||||
# Implement ldap and mail
|
||||
cat "../conf/ldap.exs" >> "$config"
|
||||
|
@ -119,18 +115,6 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
|||
ynh_store_file_checksum --file="$config"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# CREATE DATADIR FOLDER
|
||||
#=================================================
|
||||
|
||||
# If datadir doesn't exist, create it
|
||||
if [ -z "$datadir" ]; then
|
||||
ynh_script_progression --message="Create datadir folder..."
|
||||
|
@ -150,7 +134,7 @@ if [ -z "$datadir" ]; then
|
|||
|
||||
rsync -a $final_path/$app/uploads/ $datadir/uploads/
|
||||
|
||||
config="$final_path/$app/config/prod.secret.exs"
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
|
||||
|
@ -165,6 +149,44 @@ if [ -z "$datadir" ]; then
|
|||
ynh_secure_remove --file="$final_path/$app/uploads"
|
||||
fi
|
||||
|
||||
if [ ! -f "$final_path/$app/config/runtime.exs" ]; then
|
||||
ynh_delete_file_checksum --file="$final_path/$app/config/prod.secret.exs"
|
||||
mv "$final_path/$app/config/prod.secret.exs" "$final_path/$app/config/runtime.exs"
|
||||
ynh_replace_string --match_string="server: true," --replace_string="" --target_file="$final_path/$app/config/runtime.exs"
|
||||
ynh_store_file_checksum --file="$final_path/$app/config/runtime.exs"
|
||||
fi
|
||||
|
||||
# If geo folder doesn't exist, create it
|
||||
if [ -z "$datadir/geo" ]; then
|
||||
ynh_script_progression --message="Create geo folder..."
|
||||
|
||||
ynh_setup_source --dest_dir="$datadir/geo"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
|
||||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/geolix.exs"
|
||||
cat "../conf/geolix.exs" >> "$config"
|
||||
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown $app:$app "$config"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -177,7 +199,7 @@ then
|
|||
tmpdir="$(mktemp -d)"
|
||||
|
||||
# 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/runtime.exs" "$tmpdir/runtime.exs"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path/$app"
|
||||
|
@ -186,7 +208,7 @@ then
|
|||
ynh_setup_source --dest_dir="$final_path/$app"
|
||||
|
||||
# Restore the config file
|
||||
cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
|
||||
cp -af "$tmpdir/runtime.exs" "$final_path/$app/config/runtime.exs"
|
||||
|
||||
# Remove the tmp directory securely
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
|
@ -219,6 +241,29 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CREATE DATADIR FOLDER
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Create datadir folder..."
|
||||
|
||||
mkdir -p $datadir
|
||||
mkdir -p "$datadir/uploads/"
|
||||
|
||||
ynh_setup_source --dest_dir="$datadir/geo" --source_id=geolix
|
||||
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
|
||||
ynh_replace_string --match_string="$datadir/geo/.*" --replace_string="$datadir/geo/dbip-city-lite-2021-07.mmdb" --target_file=$config
|
||||
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
#=================================================
|
||||
# MAKE SETUP
|
||||
#=================================================
|
||||
|
@ -261,7 +306,7 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
config="$final_path/$app/config/prod.secret.exs"
|
||||
config="$final_path/$app/config/runtime.exs"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
|
Loading…
Add table
Reference in a new issue