diff options
| author | Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr> | 2018-05-01 11:29:25 +0200 |
|---|---|---|
| committer | Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr> | 2018-05-01 11:29:25 +0200 |
| commit | f0b132281241bcfdc38be62dd79324b78a4972f2 (patch) | |
| tree | ef9688ca0989097d0b47f78bd093a588475da22a /scripts/install | |
| parent | 1925b3026b2affacd95464ee98525b156313cfb4 (diff) | |
| download | mastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.tar.gz mastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.tar.bz2 mastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.zip | |
Use latest PostgreSQL helpers
Diffstat (limited to 'scripts/install')
| -rw-r--r-- | scripts/install | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/scripts/install b/scripts/install index 5b1acaa..4a23715 100644 --- a/scripts/install +++ b/scripts/install @@ -116,31 +116,16 @@ ynh_install_app_dependencies \ # TODO: use non-official https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/postgres/postgres # TODO: this commands doesn't looks like a requirement, you may fully remove it # Set UTF8 encoding by default -su -c "psql" postgres <<< \ - "update pg_database set datistemplate='false' where datname='template1';" -su -c "psql" postgres <<< \ - "drop database template1;" -su -c "psql" postgres <<< \ - "create database template1 encoding='UTF8' template template0;" -su -c "psql" postgres <<< \ - "update pg_database set datistemplate='true' where datname='template1';" -# Create DB without password -ynh_psql_create_db_without_password "$app" -systemctl restart postgresql +ynh_psql_test_if_first_run + +db_user=$(ynh_sanitize_dbid "$app") +db_name=$(ynh_sanitize_dbid "$app") +db_pwd=$(ynh_string_random) +ynh_app_setting_set $app db_pwd $db_pwd +ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -# TODO: dont su as $app, work root and set corrects rights at the end of install -# Download all sources rbenv, ruby and mastodon -( - su $app - git clone https://github.com/rbenv/rbenv.git $final_path/.rbenv - git clone https://github.com/rbenv/ruby-build.git $final_path/.rbenv/plugins/ruby-build - git clone https://github.com/tootsuite/mastodon.git $final_path/live -) #================================================= # NGINX CONFIGURATION @@ -161,6 +146,19 @@ cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Create user unix adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --disabled-login +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +# TODO: dont su as $app, work root and set corrects rights at the end of install +# Download all sources rbenv, ruby and mastodon +( + su $app + git clone https://github.com/rbenv/rbenv.git $final_path/.rbenv + git clone https://github.com/rbenv/ruby-build.git $final_path/.rbenv/plugins/ruby-build + git clone https://github.com/tootsuite/mastodon.git $final_path/live +) + # Switch branch to tagged release cd $final_path/live version=$(curl -s https://api.github.com/repos/tootsuite/mastodon/releases/latest | grep tag_name | cut -d\" -f4) @@ -208,8 +206,9 @@ ln -s /opt/mastodon/.rbenv/versions/2.5.0/bin/ruby /usr/bin/ruby || true cp -a $final_path/live/.env.production.sample $final_path/live/.env.production sed -i "s@REDIS_HOST=redis@REDIS_HOST=127.0.0.1@g" "${final_path}/live/.env.production" sed -i "s@DB_HOST=db@DB_HOST=/var/run/postgresql@g" "${final_path}/live/.env.production" -sed -i "s@DB_USER=postgres@DB_USER=${app}@g" "${final_path}/live/.env.production" -sed -i "s@DB_NAME=postgres@DB_NAME=${app}_production@g" "${final_path}/live/.env.production" +sed -i "s@DB_USER=postgres@DB_USER=${db_user}@g" "${final_path}/live/.env.production" +sed -i "s@DB_NAME=postgres@DB_NAME=${db_name}@g" "${final_path}/live/.env.production" +sed -i "s@DB_PASS=@DB_PASS=${db_name}@g" "${final_path}/live/.env.production" sed -i "s@LOCAL_DOMAIN=example.com@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" language="$(echo $language | head -c 2)" |
