From 40e39fcfbbe83eea584886d972ff199e9e4daf18 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Fri, 14 Apr 2017 16:36:06 +0200 Subject: [PATCH 1/9] [fix] create secret keys with 128 character (not Uppercase) --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 9696925..eb3559a 100644 --- a/scripts/install +++ b/scripts/install @@ -136,9 +136,9 @@ sudo sed -i "s@DB_USER=postgres@DB_USER=${app}@g" "${final_path}/live/.env.produ sudo sed -i "s@DB_NAME=postgres@DB_NAME=${app}_production@g" "${final_path}/live/.env.production" sudo sed -i "s@LOCAL_DOMAIN=example.com@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" -sudo sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" -sudo sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" -sudo sed -i "s@OTP_SECRET=@OTP_SECRET=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" +sudo sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" +sudo sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" +sudo sed -i "s@OTP_SECRET=@OTP_SECRET=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" sudo sed -i 's,SMTP_LOGIN=,SMTP_LOGIN='${admin_mastodon}'@'${domain}',' "${final_path}/live/.env.production" sudo sed -i "s@SMTP_PASSWORD=@SMTP_PASSWORD=${admin_pass}@g" "${final_path}/live/.env.production" From 382deeb25384cc156dff4332217ee18d3436842f Mon Sep 17 00:00:00 2001 From: magikcypress Date: Fri, 14 Apr 2017 16:43:00 +0200 Subject: [PATCH 2/9] [fix] don't use subdir --- manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 22ce245..9409e47 100644 --- a/manifest.json +++ b/manifest.json @@ -35,11 +35,11 @@ "name": "path", "type": "path", "ask": { - "en": "Choose a path for Mastodon", - "fr": "Choisissez un chemin pour Mastodon" + "en": "Choose a path for Mastodon (don't use subdir ex: /mastodon)", + "fr": "Choisissez un chemin pour Mastodon (ne pas utiliser de répertoire ex: /mastodon)" }, - "example": "/mastodon", - "default": "/mastodon" + "example": "/", + "default": "/" }, { "name": "admin", From 032100abf99eaa46873cb0fc11d7bd1ea0ef7b24 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Fri, 14 Apr 2017 16:43:43 +0200 Subject: [PATCH 3/9] [fix] no need alias config nginx --- conf/nginx.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 780c462..8ab2b9f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,4 @@ location __PATH__ { - # alias __FINALPATH__/live/public; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; From 4045dfd749e1ff7ed83cccff1a03d9937601cdd8 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Fri, 14 Apr 2017 16:44:41 +0200 Subject: [PATCH 4/9] [fix] Clear code install script --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index eb3559a..1c964b7 100644 --- a/scripts/install +++ b/scripts/install @@ -165,11 +165,9 @@ pushd ~/live ACOMMANDS # init rbenv & create bundle -# Tips: rbenv init bash (see: https://github.com/rbenv/rbenv/issues/925) sudo su - $app < Date: Sat, 15 Apr 2017 01:56:09 +0200 Subject: [PATCH 5/9] [fix] Update crontab --- conf/crontab_mastodon | 7 ++++--- scripts/install | 11 ----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/conf/crontab_mastodon b/conf/crontab_mastodon index 972cc3c..f6794fb 100644 --- a/conf/crontab_mastodon +++ b/conf/crontab_mastodon @@ -1,3 +1,4 @@ -@hourly cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:media:clear -@hourly cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:push:refresh -@hourly cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:feeds:clear \ No newline at end of file +@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:media:clear +@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:push:refresh +@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:feeds:clear +@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:users:clear \ No newline at end of file diff --git a/scripts/install b/scripts/install index 1c964b7..75c2cfd 100644 --- a/scripts/install +++ b/scripts/install @@ -154,23 +154,12 @@ RAILS_ENV=production bin/bundle exec rails db:setup RAILS_ENV=production bin/bundle exec rails --trace assets:precompile CCOMMANDS -# TODO: Doesn't work for the moment, -# Mastodon need a user for creating an administator account -# Create admin user -# Create confirm email -sudo su - $app < Date: Sat, 15 Apr 2017 04:20:28 +0200 Subject: [PATCH 6/9] [add] language --- manifest.json | 17 +++++++++++++---- scripts/install | 5 +++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 9409e47..84bb6fd 100644 --- a/manifest.json +++ b/manifest.json @@ -9,12 +9,12 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "0.6 dev", + "version": "1.1.1", "url": "https://github.com/tootsuite/mastodon", - "license": "AGPL", + "license": "AGPL v3.0", "maintainer": { - "name": "cyp", - "email": "cyp@rouquin.me" + "name": "cyp, nemsia", + "email": "cyp@rouquin.me, nemsia@nemsia.org" }, "multi_instance": false, "services": [ @@ -59,6 +59,15 @@ }, "example": "adminpassword" }, + { + "name": "language", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["en_EN", "fr_FR"], + "default": "fr_FR" + }, { "name": "is_public", "ask": { diff --git a/scripts/install b/scripts/install index 75c2cfd..2e68844 100644 --- a/scripts/install +++ b/scripts/install @@ -17,6 +17,7 @@ domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH admin_mastodon=$YNH_APP_ARG_ADMIN admin_pass=$YNH_APP_ARG_PASSWD +language=$YNH_APP_ARG_LANGUAGE is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -35,6 +36,7 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path ynh_app_setting_set $app admin $admin_mastodon ynh_app_setting_set $app pass $admin_pass +ynh_app_setting_set $app language $language ynh_app_setting_set $app is_public $is_public # Create user unix @@ -136,6 +138,9 @@ sudo sed -i "s@DB_USER=postgres@DB_USER=${app}@g" "${final_path}/live/.env.produ sudo sed -i "s@DB_NAME=postgres@DB_NAME=${app}_production@g" "${final_path}/live/.env.production" sudo sed -i "s@LOCAL_DOMAIN=example.com@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" +language="$(echo $language | head -c 2)" +sudo sed -i "s@# DEFAULT_LOCALE=de@DEFAULT_LOCALE=${language}@g" "${final_path}/live/.env.production" + sudo sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" sudo sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" sudo sed -i "s@OTP_SECRET=@OTP_SECRET=$(head -n128 /dev/urandom | tr -dc -d 'a-z0-9' | head -c128)@g" "${final_path}/live/.env.production" From 2be310eefa3f86efba61a6df79fa70edf8cd20e8 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sun, 16 Apr 2017 16:08:42 +0200 Subject: [PATCH 7/9] [fix] Clear code & fix install --- README.md | 20 +++++++++++++++++--- conf/crontab_mastodon | 5 ++++- conf/nginx.conf | 2 +- manifest.json | 12 +----------- scripts/.fonctions | 5 ++--- scripts/install | 8 ++------ 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ac871f6..33a02de 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # Mastodon for YunoHost -[![Status](https://img.shields.io/badge/status-in_progress-yellow.svg?style=flat)](https://github.com/Snipees/couchpotato_ynh/milestones) +[![Latest Version](https://img.shields.io/badge/version-_--_-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Status](https://img.shields.io/badge/status-testing-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/milestones) +[![Dependencies](https://img.shields.io/badge/dependencies-includes-lightgrey.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh#dependencies) +[![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](https://raw.githubusercontent.com/YunoHost-Apps/mastodon_ynh/master/LICENSE) [![Yunohost version](https://img.shields.io/badge/yunohost-2.4.2_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) - -:warning: working process for the moment, do not working correctly & do not install in production :warning: +[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues) ## Mastodon c'est quoi ? @@ -19,6 +21,12 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra `$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` +## Recommandations + +Vous ne pouvez pas installer Mastodon en subdirectory, vous devez obligatoirement utiliser un domaine ou un sous-domaine pour cette application. + +Il semble important de fermer les inscriptions pour votre Mastodon, pour que ça reste une instance privé. Nous vous invitons à bloquer les instances distantes malfaisantes depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. + ## What is Mastodon? Mastodon is a free, open-source social network. A decentralized alternative to commercial platforms, it avoids the risks of a single company monopolizing your communication. Pick a server that you trust — whichever you choose, you can interact with everyone else. Anyone can run their own Mastodon instance and participate in the social network seamlessly. @@ -32,3 +40,9 @@ Mastodon is a free, open-source social network. A decentralized alternative to c ### Update `$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` + +## Recommendation + +You can't install Mastodon in subdirectory, you must use a domain or subdomain for this application. + +It seems important to close the inscriptions for your Mastodon, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. diff --git a/conf/crontab_mastodon b/conf/crontab_mastodon index f6794fb..62caff0 100644 --- a/conf/crontab_mastodon +++ b/conf/crontab_mastodon @@ -1,4 +1,7 @@ @daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:media:clear + @daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:push:refresh + @daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:feeds:clear -@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:users:clear \ No newline at end of file + +@daily __APP__ cd /opt/__APP__/live && RAILS_ENV=production /opt/__APP__/.rbenv/shims/bundle exec rake mastodon:users:clear diff --git a/conf/nginx.conf b/conf/nginx.conf index 8ab2b9f..5ce3d7a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__ { +location / { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; diff --git a/manifest.json b/manifest.json index 84bb6fd..f4f245e 100644 --- a/manifest.json +++ b/manifest.json @@ -31,16 +31,6 @@ }, "example": "domain.org" }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Mastodon (don't use subdir ex: /mastodon)", - "fr": "Choisissez un chemin pour Mastodon (ne pas utiliser de répertoire ex: /mastodon)" - }, - "example": "/", - "default": "/" - }, { "name": "admin", "type": "user", @@ -75,7 +65,7 @@ "fr": "Mastodon est-il public ?" }, "choices": ["Yes", "No"], - "default": "Yes" + "default": "No" } ] } diff --git a/scripts/.fonctions b/scripts/.fonctions index 8abb720..0a148a6 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -22,7 +22,7 @@ EXIT_PROPERLY () { # Causes the script to stop in the event of an error. And cle fi # Compensates the ssowat bug that does not remove the app's input in case of installation error. - sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json + sudo sed -i "\@\"$domain/\":@d" /etc/ssowat/conf.json if [ "$ynh_version" = "2.2" ]; then /bin/bash $script_dir/remove @@ -54,7 +54,7 @@ CHECK_PATH () { # Checks / at the beginning of the path. And his absence at the } CHECK_DOMAINPATH () { # Checks the availability of the path and domain. - sudo yunohost app checkurl $domain$path -a $app + sudo yunohost app checkurl $domain -a $app } CHECK_FINALPATH () { # Checks that the destination folder is not already in use. @@ -110,7 +110,6 @@ SETUP_SOURCE () { # Download source, decompress and copu into $final_path fi } - ### REMOVE SCRIPT REMOVE_NGINX_CONF () { # Delete nginx configuration diff --git a/scripts/install b/scripts/install index 2e68844..b78cb47 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ CLEAN_SETUP () { TRAP_ON # Active trap to stop the script if an error is detected. domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH admin_mastodon=$YNH_APP_ARG_ADMIN admin_pass=$YNH_APP_ARG_PASSWD language=$YNH_APP_ARG_LANGUAGE @@ -26,14 +25,11 @@ CHECK_VAR "$app" "app name not set" CHECK_USER "$admin_mastodon" -CHECK_PATH - CHECK_DOMAINPATH CHECK_FINALPATH ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path ynh_app_setting_set $app admin $admin_mastodon ynh_app_setting_set $app pass $admin_pass ynh_app_setting_set $app language $language @@ -188,12 +184,12 @@ sudo yunohost service add mastodon-streaming # 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 -sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf # Install crontab sudo cp ../conf/crontab_mastodon /etc/cron.d/$app sudo sed -i "s@__APP__@$app@g" /etc/cron.d/$app +# Restart crontab +sudo systemctl restart cron # Private or not if [ "$is_public" = "Yes" ]; From f78a530923104af8213bc76b150405657bedc533 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sun, 16 Apr 2017 16:33:17 +0200 Subject: [PATCH 8/9] Complete README for after install --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 33a02de..067e452 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,20 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra `$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git` +Une fois l'installation effectuée, vous pouvez créer un compte manuellement sur Mastodon depuis votre navigateur. Lorsque vous avez crée le premier utilisateur vous pouvez créer l'administrateur de votre Mastodon. Pour celà, il faut impérativement passer par une interface en ligne de commande et taper les commandes suivantes : + +**se connecter en sudo sur l'utilisateur** + +`$ sudo su mastodon` + +**se placer dans le répertoire où est installé Mastodon** + +`$ cd /opt/mastodon/live` + +**lancer la commande de création de l'administrateur** + +`$ RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=*Nom de votre utilisateur*` + ### Mise à jour `$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` @@ -37,6 +51,20 @@ Mastodon is a free, open-source social network. A decentralized alternative to c `$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git` +After installation, you can create an account manually on Mastodon from your browser. When you have created the first user you can create the administrator of your Mastodon. For this, it is imperative to go through a command line and type the following commands: + +**sudo to the user** + +`$ sudo su mastodon` + +**change directory where Mastodon is installed** + +`$ cd /opt/mastodon/live` + +**launch the command to create the administrator** + +`$ RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=*Nom de votre utilisateur*` + ### Update `$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` From e237896f74196b8b98eddc0ad5e5d8774b937765 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sun, 16 Apr 2017 16:36:08 +0200 Subject: [PATCH 9/9] Petouille README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 067e452..d66dc2c 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ After installation, you can create an account manually on Mastodon from your bro **launch the command to create the administrator** -`$ RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=*Nom de votre utilisateur*` +`$ RAILS_ENV=production bin/bundle exec rails mastodon:make_admin USERNAME=*username*` ### Update