diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/.fonctions | 11 | ||||
| -rw-r--r-- | scripts/install | 58 | ||||
| -rw-r--r-- | scripts/remove | 2 | ||||
| -rw-r--r-- | scripts/upgrade | 8 |
4 files changed, 57 insertions, 22 deletions
diff --git a/scripts/.fonctions b/scripts/.fonctions index 59e4f46..8abb720 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -176,6 +176,15 @@ ynh_psql_create_user() { "CREATE USER ${1} WITH PASSWORD '${2}';" } +# Create a user without password +# +# usage: ynh_mysql_create_user user pwd [host] +# | arg: user - the user name to create +ynh_psql_create_user_without_password() { + sudo su -c "psql" postgres <<< \ + "CREATE USER ${1};" +} + # Create a database and grant optionnaly privilegies to a user # # usage: ynh_mysql_create_db db [user [pwd]] @@ -217,4 +226,4 @@ ynh_psql_drop_db() { # | arg: user - the user name to drop ynh_psql_drop_user() { sudo su -c "dropuser ${1}" postgres -}
\ No newline at end of file +} diff --git a/scripts/install b/scripts/install index d8c61b7..6a1fe20 100644 --- a/scripts/install +++ b/scripts/install @@ -70,32 +70,35 @@ sudo apt-get -y install nodejs # Install Yarn ynh_package_install yarn -# sudo npm install -g yarn # Set UTF8 encoding by default -# Bug: Warning: PG::InsufficientPrivilege: ERROR: permission denied to copy database "template1" -# Exec db:setup -# sudo su -c "psql" postgres <<< \ -# "update pg_database set datistemplate='false' where datname='template1';"\ -# "drop database template1;"\ -# "create database template1 encoding='UTF8' template template0;"\ -# "update pg_database set datistemplate='true' where datname='template1';" +sudo su -c "psql" postgres <<< \ + "update pg_database set datistemplate='false' where datname='template1';" +sudo su -c "psql" postgres <<< \ + "drop database template1;" +sudo su -c "psql" postgres <<< \ + "create database template1 encoding='UTF8' template template0;" +sudo su -c "psql" postgres <<< \ + "update pg_database set datistemplate='true' where datname='template1';" # Create DB without password ynh_psql_create_db_without_password "$app" sudo systemctl restart postgresql # Download all Ruby source -sudo git clone https://github.com/rbenv/rbenv.git $final_path/.rbenv -sudo git clone https://github.com/rbenv/ruby-build.git $final_path/.rbenv/plugins/ruby-build +sudo su - $app <<CLONECOMMANDS +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 +CLONECOMMANDS # Be king rewind (/var/cache/yunohost/from_file/scripts) popd # Get Mastodon last version -sudo mkdir "${final_path}/live" -SETUP_SOURCE -sudo chown -R $app: "${final_path}" +# sudo mkdir "${final_path}/live" +# SETUP_SOURCE +# sudo chown -R $app: "${final_path}" # Install de rbenv # Tips: rbenv init - bash (see: https://github.com/rbenv/rbenv/issues/925) @@ -109,17 +112,17 @@ COMMANDS # Install ruby-build sudo su - $app <<RCOMMANDS -/opt/mastodon/.rbenv/bin/rbenv install 2.3.1 -/opt/mastodon/.rbenv/versions/2.3.1/bin/ruby -v +/opt/mastodon/.rbenv/bin/rbenv install 2.4.1 +/opt/mastodon/.rbenv/versions/2.4.1/bin/ruby -v RCOMMANDS # Create symlink for ruby -sudo ln -s /opt/mastodon/.rbenv/versions/2.3.1/bin/ruby /usr/bin/ruby || true +sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true # Install Mastodon sudo su - $app <<MCOMMANDS pushd ~/live -/opt/mastodon/.rbenv/versions/2.3.1/bin/gem install bundler +/opt/mastodon/.rbenv/versions/2.4.1/bin/gem install bundler bin/bundle install --deployment --without development test yarn install --production MCOMMANDS @@ -173,7 +176,8 @@ pushd ~/live ACOMMANDS # Add Services -pushd /var/cache/yunohost/from_file/scripts +#pushd /var/cache/yunohost/from_file/mastodon_ynh-master/scripts +pushd $(popd) sudo cp ../conf/mastodon-web.service /etc/systemd/system/mastodon-web.service sudo chown root: /etc/systemd/system/mastodon-web.service @@ -193,6 +197,18 @@ sudo yunohost service add mastodon-web sudo yunohost service add mastodon-sidekiq sudo yunohost service add mastodon-streaming +# restart 1 +sudo systemctl restart /etc/systemd/system/mastodon-*.service + +# Re-Install bundle WHY ??? +sudo su - $app <<MCOMMANDS +pushd ~/live +bundle install +MCOMMANDS + +# restart 2 +sudo systemctl restart /etc/systemd/system/mastodon-*.service + # Copy nginx config sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf @@ -219,4 +235,8 @@ fi sudo yunohost app ssowatconf # Reload Nginx -sudo systemctl reload nginx
\ No newline at end of file +sudo systemctl reload nginx || true +# debug +# sudo systemctl status nginx +# sudo systemctl reload nginx + diff --git a/scripts/remove b/scripts/remove index ba35199..c2316ad 100644 --- a/scripts/remove +++ b/scripts/remove @@ -98,4 +98,4 @@ sudo userdel -f $app # Reload services sudo service nginx reload -echo -e "\e[0m" # Restore normal color
\ No newline at end of file +echo -e "\e[0m" # Restore normal color diff --git a/scripts/upgrade b/scripts/upgrade index 0260ee1..771b98b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,6 +31,9 @@ db_name=$app sudo sed -i "s@__PATH__@$app@g" ../conf/nginx.conf* sudo sed -i "s@__FINALPATH__@$final_path/@g" ../conf/nginx.conf* +# Stop Mastodon Services +sudo systemctl stop /etc/systemd/system/mastodon-*.service + # Update Mastodon sudo su - $app <<COMMANDS pushd ~/live @@ -39,6 +42,9 @@ RAILS_ENV=production bin/bundle exec rails db:migrate RAILS_ENV=production bin/bundle exec rails assets:precompile COMMANDS +# Start Mastodon Services +sudo systemctl start /etc/systemd/system/mastodon-*.service + # If app is public, add url to SSOWat conf as skipped_uris if [ $is_public = "Yes" ]; then @@ -51,4 +57,4 @@ fi # Reload Nginx sudo systemctl reload nginx # Reload Mastodon -sudo systemctl restart mastodon-*.service
\ No newline at end of file +sudo systemctl restart mastodon-*.service |
