1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pleroma_ynh.git synced 2024-09-03 20:15:59 +02:00

Remove previous fixs

This commit is contained in:
Yalh 2019-01-25 13:07:37 +01:00 committed by yalh76
parent 10783c144b
commit 48e709a72b
5 changed files with 50 additions and 55 deletions

View file

@ -55,13 +55,13 @@ Go to **cd /var/www/pleroma/pleroma**.
**Run:**
$ sudo -u pleroma MIX_ENV=pleroma mix pleroma.user new <NICKNAME> <EMAIL>
$ sudo -u pleroma MIX_ENV=prod mix pleroma.user new <NICKNAME> <EMAIL>
### Password reset
**Run:**
$ MIX_ENV=pleroma mix pleroma.user reset_password <NICKNAME>
$ MIX_ENV=prod mix pleroma.user reset_password <NICKNAME>
This will generate a **password reset link** that you can then send to the user.
@ -72,7 +72,7 @@ You can make users **moderators**. They will then be able to **delete any post**
**Run:**
$ MIX_ENV=pleroma mix pleroma.user set <NICKNAME> --[no-]admin
$ MIX_ENV=prod mix pleroma.user set <NICKNAME> --[no-]admin
**--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user.

View file

@ -3,7 +3,7 @@ Description=__APP__ social network
After=network.target postgresql.service
[Service]
Environment="MIX_ENV=__INSTANCE_NAME__"
Environment="MIX_ENV=prod"
User=__APP__
WorkingDirectory=__FINALPATH__/__APP__
Environment="HOME=__FINALPATH__"

View file

@ -215,31 +215,31 @@ ynh_system_user_create "$app" "$final_path"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
cp -f ../conf/prod.exs "$final_path/$app/config/$app.exs"
cp -f ../conf/prod.secret.exs "$final_path/$app/config/prod.secret.exs"
cp -f ../conf/setup_db.psql "$final_path/$app/config/setup_db.psql"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/$app.exs"
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/$app.exs"
ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/$app.exs"
ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/$app.exs"
ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/setup_db.psql"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/setup_db.psql"
if [ $cache -eq 1 ]
then
ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/$app.exs"
ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/prod.secret.exs"
else
ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/$app.exs"
ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/prod.secret.exs"
fi
# Set registrations open/closed
if [ $registration -eq 1 ]
then
ynh_replace_string "__REG__" "true" "$final_path/$app/config/$app.exs"
ynh_replace_string "__REG__" "true" "$final_path/$app/config/prod.secret.exs"
else
ynh_replace_string "__REG__" "false" "$final_path/$app/config/$app.exs"
ynh_replace_string "__REG__" "false" "$final_path/$app/config/prod.secret.exs"
fi
@ -249,26 +249,26 @@ fi
# Give permisiion to the final_path
chown -R "$app":"$app" "$final_path"
# App setup and db migration
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix local.hex --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix local.rebar --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.hex --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.rebar --force )
( cd $final_path/$app && sudo -u "$app" mix deps.get )
ynh_psql_execute_as_root \
"ALTER USER $app WITH SUPERUSER;"
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix ecto.migrate --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix ecto.migrate --force )
ynh_psql_execute_as_root \
"ALTER USER $app WITH NOSUPERUSER;"
# Add user and retrieve a password reset link that you can then send to the user
admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix pleroma.user new "$admin" "$admin_email" | tail -1 )
admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 )
# Make user moderator
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix pleroma.user set "$admin" --moderator )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator )
# Make user admin
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix pleroma.user set "$admin" --admin )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --admin )
#=================================================
# SETUP SYSTEMD
@ -324,7 +324,7 @@ ynh_add_systemd_config
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
#ynh_replace_string "match_string" "replace_string" "$final_path/$app/config/$app.exs"
#ynh_replace_string "match_string" "replace_string" "$final_path/$app/config/prod.secret.exs"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -335,7 +335,7 @@ ynh_add_systemd_config
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/$app/config/$app.exs"
ynh_store_file_checksum "$final_path/$app/config/prod.secret.exs"
#=================================================
# GENERIC FINALIZATION

View file

@ -161,60 +161,55 @@ CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS citext;"
yunohost firewall allow Both "$port" 2>&1
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.hex --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.rebar --force )
( cd $final_path/$app && sudo -u "$app" mix deps.get )
ynh_psql_execute_as_root \
"ALTER USER $app WITH SUPERUSER;"
( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix ecto.migrate --force )
ynh_psql_execute_as_root \
"ALTER USER $app WITH NOSUPERUSER;"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
cp -f ../conf/prod.exs "$final_path/$app/config/$app.exs"
cp -f ../conf/prod.secret.exs "$final_path/$app/config/prod.secret.exs"
cp -f ../conf/setup_db.psql "$final_path/$app/config/setup_db.psql"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/$app.exs"
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/$app.exs"
ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/$app.exs"
ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/$app.exs"
ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/$app.exs"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/prod.secret.exs"
ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/setup_db.psql"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/setup_db.psql"
if [ $cache -eq 1 ]
then
ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/$app.exs"
ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/prod.secret.exs"
else
ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/$app.exs"
ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/prod.secret.exs"
fi
# Set registrations open/closed
if [ $registration -eq 1 ]
then
ynh_replace_string "__REG__" "true" "$final_path/$app/config/$app.exs"
ynh_replace_string "__REG__" "true" "$final_path/$app/config/prod.secret.exs"
else
ynh_replace_string "__REG__" "false" "$final_path/$app/config/$app.exs"
ynh_replace_string "__REG__" "false" "$final_path/$app/config/prod.secret.exs"
fi
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/$app/config/$app.exs"
ynh_store_file_checksum "$final_path/$app/config/prod.secret.exs"
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different "$final_path/$app/config/$app.exs"
ynh_backup_if_checksum_is_different "$final_path/$app/config/prod.secret.exs"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/$app/config/$app.exs"
#=================================================
# MAKE THE UPGRADE
#=================================================
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix local.hex --force )
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix local.rebar --force )
( cd $final_path/$app && sudo -u "$app" mix deps.get )
ynh_psql_execute_as_root \
"ALTER USER $app WITH SUPERUSER;"
( cd $final_path/$app && sudo -u "$app" MIX_ENV=$app mix ecto.migrate --force )
ynh_psql_execute_as_root \
"ALTER USER $app WITH NOSUPERUSER;"
ynh_store_file_checksum "$final_path/$app/config/prod.secret.exs"
#=================================================
# SETUP LOGROTATE