Commit e6bbd574 authored by Spctrl's avatar Spctrl

drop specific version for psql + add improved helper for random strings

parent c2fd7ed9
...@@ -50,8 +50,8 @@ Extra info: ...@@ -50,8 +50,8 @@ Extra info:
* To check your current Pleroma version you can go to `yourdomain.tld/api/v1/instance` * To check your current Pleroma version you can go to `yourdomain.tld/api/v1/instance`
TODO: TODO:
* Test the installation (esp scope setting) * Make generate_config more elegant
* Make dependencys version independant (ie postgressql uses 9.6 atm, higher should also be possible) * check logrotate
* Make the remove more elegant (esp the removal of the DB) * Make the remove more elegant (esp the removal of the DB)
* Make backup and restore work as expected * Make backup and restore work as expected
* Use psql helpers for backup/restore if possible * Use psql helpers for backup/restore if possible
......
...@@ -10,4 +10,22 @@ ...@@ -10,4 +10,22 @@
ynh_delete_file_checksum () { ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name ynh_app_setting_delete $app $checksum_setting_name
} }
\ No newline at end of file
# ============= CUSTOM HELPERS =============
# Improvement on default helper who in some cases returned empty string
#
# Generate a random string
#
# example: pwd=$(ynh_string_random 8)
#
# usage: ynh_string_random [length]
# | arg: length - the string length to generate (default: 24)
ynh_string_random() {
str=''
while [ ${#str} -lt ${1:-24} ]; do
str=$str$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9');
done
echo $str | sed -n 's/\(.\{'"${1:-24}"'\}\).*/\1/p'
}
#!/bin/bash #!/bin/bash
# yunohost app install --debug ./pleroma_ynh/ --args "domain=plrm.spectral.pirate&instance_name=pirate&is_public=yes&allow_scopes=no&instance_user=spctrl&instance_user_password=neutrinet&instance_user_password_verify=neutrinet&instance_user_mail=me@pl.ma" # yunohost app install --debug ./pleroma_ynh/ --args "domain=plrm.spectral.pirate&instance_name=pirate&is_public=yes&allow_scopes=yes&instance_user=spctrl&instance_user_password=neutrinet&instance_user_password_verify=neutrinet&instance_user_mail=me@pl.ma"
#================================================= #=================================================
# GENERIC START # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source _common.sh
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
...@@ -85,7 +85,7 @@ then ...@@ -85,7 +85,7 @@ then
rm erlang_solutions.asc rm erlang_solutions.asc
fi fi
apt-get update apt-get update
ynh_install_app_dependencies git build-essential postgresql-9.6 postgresql-contrib-9.6 elixir erlang-dev erlang-parsetools erlang-xmerl erlang-tools esl-erlang ynh_install_app_dependencies git build-essential postgresql postgresql-contrib elixir erlang-dev erlang-parsetools erlang-xmerl erlang-tools esl-erlang
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
...@@ -103,6 +103,9 @@ git clone https://git.pleroma.social/pleroma/pleroma $final_path/pleroma ...@@ -103,6 +103,9 @@ git clone https://git.pleroma.social/pleroma/pleroma $final_path/pleroma
# TODO: there's a merge comming in Pleroma that makes it all non-interactive # TODO: there's a merge comming in Pleroma that makes it all non-interactive
# https://git.pleroma.social/pleroma/pleroma/merge_requests/243 # https://git.pleroma.social/pleroma/pleroma/merge_requests/243
# this will simplify this whole block # this will simplify this whole block
# TODO: There is also a helper that can create a secret and pasword
# this can simplify this whole block as well
cp ../conf/generate_config.ex $final_path/pleroma/lib/mix/tasks/generate_config.ex cp ../conf/generate_config.ex $final_path/pleroma/lib/mix/tasks/generate_config.ex
chown -R $app: $final_path chown -R $app: $final_path
...@@ -159,7 +162,6 @@ else ...@@ -159,7 +162,6 @@ else
ynh_replace_string "registrations_open: true" "registrations_open: false" "$final_path/pleroma/config/prod.secret.exs" ynh_replace_string "registrations_open: true" "registrations_open: false" "$final_path/pleroma/config/prod.secret.exs"
fi fi
# TODO: To be tested!
# Check if scope setting is already in the file # Check if scope setting is already in the file
if ! ( cat "$final_path/pleroma/config/prod.secret.exs" | grep "scope_options_enabled: " ) if ! ( cat "$final_path/pleroma/config/prod.secret.exs" | grep "scope_options_enabled: " )
then then
...@@ -188,7 +190,7 @@ fi ...@@ -188,7 +190,7 @@ fi
# ADD USER TO INSTANCE # ADD USER TO INSTANCE
#================================================= #=================================================
# The tasks fails, so I have to set the the pasword for the postgresql DB-user first # We have to set the the pasword for the postgresql DB-user first, otherwise the task fails.
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
su - $app -c "cd $final_path/pleroma; MIX_ENV=prod mix local.hex --force; MIX_ENV=prod mix register_user $instance_user $instance_user $instance_user_mail 'Moderator of this instance' $instance_user_password; MIX_ENV=prod mix set_moderator $instance_user true;" su - $app -c "cd $final_path/pleroma; MIX_ENV=prod mix local.hex --force; MIX_ENV=prod mix register_user $instance_user $instance_user $instance_user_mail 'Moderator of this instance' $instance_user_password; MIX_ENV=prod mix set_moderator $instance_user true;"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment