mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Merge pull request #3 from nemsia/master
Big Pull request for install script
This commit is contained in:
commit
06981deb6a
5 changed files with 60 additions and 25 deletions
|
@ -15,7 +15,7 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra
|
||||||
|
|
||||||
### Mise à jour
|
### 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?
|
## What is Mastodon?
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ Mastodon is a free, open-source social network. A decentralized alternative to c
|
||||||
|
|
||||||
### Install
|
### 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
|
### Update
|
||||||
|
|
||||||
`$ sudo yunohost app upgrade --verbose mastoron -u https://github.com/YunoHost-Apps/mastoron_ynh.git`
|
`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git`
|
||||||
|
|
|
@ -176,6 +176,15 @@ ynh_psql_create_user() {
|
||||||
"CREATE USER ${1} WITH PASSWORD '${2}';"
|
"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
|
# Create a database and grant optionnaly privilegies to a user
|
||||||
#
|
#
|
||||||
# usage: ynh_mysql_create_db db [user [pwd]]
|
# usage: ynh_mysql_create_db db [user [pwd]]
|
||||||
|
@ -217,4 +226,4 @@ ynh_psql_drop_db() {
|
||||||
# | arg: user - the user name to drop
|
# | arg: user - the user name to drop
|
||||||
ynh_psql_drop_user() {
|
ynh_psql_drop_user() {
|
||||||
sudo su -c "dropuser ${1}" postgres
|
sudo su -c "dropuser ${1}" postgres
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,32 +70,35 @@ sudo apt-get -y install nodejs
|
||||||
|
|
||||||
# Install Yarn
|
# Install Yarn
|
||||||
ynh_package_install yarn
|
ynh_package_install yarn
|
||||||
# sudo npm install -g yarn
|
|
||||||
|
|
||||||
# Set UTF8 encoding by default
|
# Set UTF8 encoding by default
|
||||||
# Bug: Warning: PG::InsufficientPrivilege: ERROR: permission denied to copy database "template1"
|
sudo su -c "psql" postgres <<< \
|
||||||
# Exec db:setup
|
"update pg_database set datistemplate='false' where datname='template1';"
|
||||||
# sudo su -c "psql" postgres <<< \
|
sudo su -c "psql" postgres <<< \
|
||||||
# "update pg_database set datistemplate='false' where datname='template1';"\
|
"drop database template1;"
|
||||||
# "drop database template1;"\
|
sudo su -c "psql" postgres <<< \
|
||||||
# "create database template1 encoding='UTF8' template template0;"\
|
"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='true' where datname='template1';"
|
||||||
|
|
||||||
# Create DB without password
|
# Create DB without password
|
||||||
ynh_psql_create_db_without_password "$app"
|
ynh_psql_create_db_without_password "$app"
|
||||||
sudo systemctl restart postgresql
|
sudo systemctl restart postgresql
|
||||||
|
|
||||||
# Download all Ruby source
|
# Download all Ruby source
|
||||||
sudo git clone https://github.com/rbenv/rbenv.git $final_path/.rbenv
|
sudo su - $app <<CLONECOMMANDS
|
||||||
sudo git clone https://github.com/rbenv/ruby-build.git $final_path/.rbenv/plugins/ruby-build
|
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)
|
# Be king rewind (/var/cache/yunohost/from_file/scripts)
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Get Mastodon last version
|
# Get Mastodon last version
|
||||||
sudo mkdir "${final_path}/live"
|
# sudo mkdir "${final_path}/live"
|
||||||
SETUP_SOURCE
|
# SETUP_SOURCE
|
||||||
sudo chown -R $app: "${final_path}"
|
# sudo chown -R $app: "${final_path}"
|
||||||
|
|
||||||
# Install de rbenv
|
# Install de rbenv
|
||||||
# Tips: rbenv init - bash (see: https://github.com/rbenv/rbenv/issues/925)
|
# Tips: rbenv init - bash (see: https://github.com/rbenv/rbenv/issues/925)
|
||||||
|
@ -109,17 +112,17 @@ COMMANDS
|
||||||
|
|
||||||
# Install ruby-build
|
# Install ruby-build
|
||||||
sudo su - $app <<RCOMMANDS
|
sudo su - $app <<RCOMMANDS
|
||||||
/opt/mastodon/.rbenv/bin/rbenv install 2.3.1
|
/opt/mastodon/.rbenv/bin/rbenv install 2.4.1
|
||||||
/opt/mastodon/.rbenv/versions/2.3.1/bin/ruby -v
|
/opt/mastodon/.rbenv/versions/2.4.1/bin/ruby -v
|
||||||
RCOMMANDS
|
RCOMMANDS
|
||||||
|
|
||||||
# Create symlink for ruby
|
# 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
|
# Install Mastodon
|
||||||
sudo su - $app <<MCOMMANDS
|
sudo su - $app <<MCOMMANDS
|
||||||
pushd ~/live
|
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
|
bin/bundle install --deployment --without development test
|
||||||
yarn install --production
|
yarn install --production
|
||||||
MCOMMANDS
|
MCOMMANDS
|
||||||
|
@ -173,7 +176,8 @@ pushd ~/live
|
||||||
ACOMMANDS
|
ACOMMANDS
|
||||||
|
|
||||||
# Add Services
|
# 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 cp ../conf/mastodon-web.service /etc/systemd/system/mastodon-web.service
|
||||||
sudo chown root: /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-sidekiq
|
||||||
sudo yunohost service add mastodon-streaming
|
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
|
# Copy nginx config
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
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
|
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
@ -219,4 +235,8 @@ fi
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# Reload Nginx
|
# Reload Nginx
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx || true
|
||||||
|
# debug
|
||||||
|
# sudo systemctl status nginx
|
||||||
|
# sudo systemctl reload nginx
|
||||||
|
|
||||||
|
|
|
@ -98,4 +98,4 @@ sudo userdel -f $app
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
||||||
echo -e "\e[0m" # Restore normal color
|
echo -e "\e[0m" # Restore normal color
|
||||||
|
|
|
@ -31,6 +31,9 @@ db_name=$app
|
||||||
sudo sed -i "s@__PATH__@$app@g" ../conf/nginx.conf*
|
sudo sed -i "s@__PATH__@$app@g" ../conf/nginx.conf*
|
||||||
sudo sed -i "s@__FINALPATH__@$final_path/@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
|
# Update Mastodon
|
||||||
sudo su - $app <<COMMANDS
|
sudo su - $app <<COMMANDS
|
||||||
pushd ~/live
|
pushd ~/live
|
||||||
|
@ -39,6 +42,9 @@ RAILS_ENV=production bin/bundle exec rails db:migrate
|
||||||
RAILS_ENV=production bin/bundle exec rails assets:precompile
|
RAILS_ENV=production bin/bundle exec rails assets:precompile
|
||||||
COMMANDS
|
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 app is public, add url to SSOWat conf as skipped_uris
|
||||||
if [ $is_public = "Yes" ];
|
if [ $is_public = "Yes" ];
|
||||||
then
|
then
|
||||||
|
@ -51,4 +57,4 @@ fi
|
||||||
# Reload Nginx
|
# Reload Nginx
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
# Reload Mastodon
|
# Reload Mastodon
|
||||||
sudo systemctl restart mastodon-*.service
|
sudo systemctl restart mastodon-*.service
|
||||||
|
|
Loading…
Add table
Reference in a new issue