aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--scripts/.fonctions11
-rw-r--r--scripts/install58
-rw-r--r--scripts/remove2
-rw-r--r--scripts/upgrade8
5 files changed, 60 insertions, 25 deletions
diff --git a/README.md b/README.md
index 4fe4817..6d5b174 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra
### Mise à jour
-`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastoron_ynh.git`
+`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git`
## What is Mastodon?
@@ -25,8 +25,8 @@ Mastodon is a free, open-source social network. A decentralized alternative to c
### Install
-`$ sudo yunohost app install https://github.com/YunoHost-Apps/mastoron_ynh.git`
+`$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git`
### Update
-`$ sudo yunohost app upgrade --verbose mastoron -u https://github.com/YunoHost-Apps/mastoron_ynh.git` \ No newline at end of file
+`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git`
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