From 9c37e95309833ae19048ee1e53b8c4070f3e7f8d Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 21 Jun 2018 08:18:02 +0530 Subject: [PATCH 001/129] Improved the app --- check_process | 4 +- conf/mastodon-streaming.service | 2 +- conf/mastodon-web.service | 2 +- conf/nginx.conf | 4 +- manifest.json | 9 --- scripts/_common.sh | 60 ++++++++++++++- scripts/backup | 25 ++++++- scripts/install | 128 ++++++++++++++++---------------- scripts/remove | 21 +----- scripts/restore | 40 +++++----- scripts/upgrade | 56 ++++++++------ 11 files changed, 204 insertions(+), 147 deletions(-) diff --git a/check_process b/check_process index 5045355..8a7f1c6 100644 --- a/check_process +++ b/check_process @@ -2,9 +2,9 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - admin="john" (USER) path="/path" (PATH) - passwd="12345678" + admin="john" (USER) + language="fr_FR" ; Checks pkg_linter=1 setup_sub_dir=0 diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index 443cac0..689d482 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -7,7 +7,7 @@ User=__APP__ WorkingDirectory=__FINALPATH__/live Environment="NODE_ENV=production" - Environment="PORT=4000" + Environment="PORT=__PORT_STREAM__" ExecStart=/usr/bin/npm run start TimeoutSec=15 Restart=always diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 06069f1..46b304e 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -7,7 +7,7 @@ User=__APP__ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" - Environment="PORT=3000" + Environment="PORT=__PORT_WEB__" ExecStart=__FINALPATH__/live/bin/bundle exec puma -C config/puma.rb TimeoutSec=15 Restart=always diff --git a/conf/nginx.conf b/conf/nginx.conf index 585109e..a183a31 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -28,7 +28,7 @@ location @proxy { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_pass_header Server; - proxy_pass http://127.0.0.1:3000; + proxy_pass http://127.0.0.1:__PORT_WEB__; proxy_buffering off; proxy_redirect off; proxy_http_version 1.1; @@ -42,7 +42,7 @@ location /api/v1/streaming { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://127.0.0.1:4000; + proxy_pass http://127.0.0.1:__PORT_STREAM__; proxy_buffering off; proxy_redirect off; proxy_http_version 1.1; diff --git a/manifest.json b/manifest.json index ddb2479..fed1d7d 100644 --- a/manifest.json +++ b/manifest.json @@ -40,15 +40,6 @@ }, "example": "john" }, - { - "name": "passwd", - "type": "password", - "ask": { - "en": "Enter password of this administrator ≥ 8 character", - "fr": "Ajouter le mot de passe pour cette administrateur ≥ 8 charactères" - }, - "example": "adminpassword" - }, { "name": "language", "ask": { diff --git a/scripts/_common.sh b/scripts/_common.sh index df631ad..7def11e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -107,7 +107,6 @@ ynh_psql_execute_file_as_root() { # | arg: pwd - Password of the database. If not given, a password will be generated ynh_psql_setup_db () { db_user="$1" - app="$1" db_name="$2" new_db_pwd=$(ynh_string_random) # Generate a random password # If $3 is not given, use new_db_pwd instead for db_pwd. @@ -162,7 +161,7 @@ ynh_psql_dump_db() { ynh_psql_create_user() { user="$1" pwd="$2" - sudo --login --user=postgres psql -c"CREATE USER $user WITH PASSWORD '$pwd' CREATEDB;" postgres + sudo --login --user=postgres psql -c"CREATE USER $user WITH PASSWORD '$pwd'" postgres } # Drop a user @@ -173,3 +172,60 @@ ynh_psql_drop_user() { user="$1" sudo --login --user=postgres dropuser "$user" } + +# Send an email to inform the administrator +# +# usage: ynh_send_readme_to_admin app_message [recipients] +# | arg: app_message - The message to send to the administrator. +# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# example: "root admin@domain" +# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you +# example: "root admin@domain user1 user2" +ynh_send_readme_to_admin() { + local app_message="${1:-...No specific information...}" + local recipients="${2:-root}" + + # Retrieve the email of users + find_mails () { + local list_mails="$1" + local mail + local recipients=" " + # Read each mail in argument + for mail in $list_mails + do + # Keep root or a real email address as it is + if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" + then + recipients="$recipients $mail" + else + # But replace an user name without a domain after by its email + if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) + then + recipients="$recipients $mail" + fi + fi + done + echo "$recipients" + } + recipients=$(find_mails "$recipients") + + local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" + + local mail_message="This is an automated message from your beloved YunoHost server. +Specific information for the application $app. +$app_message +--- +Automatic diagnosis data from YunoHost +$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" + + # Define binary to use for mail command + if [ -e /usr/bin/bsd-mailx ] + then + local mail_bin=/usr/bin/bsd-mailx + else + local mail_bin=/usr/bin/mail.mailutils + fi + + # Send the email to the recipients + echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" +} diff --git a/scripts/backup b/scripts/backup index be3b0a4..bc1822a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -34,10 +34,13 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) final_path=$(ynh_app_setting_get "$app" final_path) db_name=$(ynh_app_setting_get "$app" db_name) -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set "$app" db_name "$db_name" -fi + +# Stop Mastodon Services +# Restart Mastodon +yunohost service stop "$app-web" +yunohost service stop "$app-sidekiq" +yunohost service stop "$app-streaming" + #================================================= # STANDARD BACKUP STEPS @@ -58,6 +61,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_psql_dump_db "$db_name" > db.sql +ynh_backup "db.sql" #================================================= # SPECIFIC BACKUP @@ -74,3 +78,16 @@ ynh_backup "/etc/systemd/system/$app-streaming.service" #================================================= ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list" + +yunohost service start "$app-web" +yunohost service start "$app-sidekiq" +yunohost service start "$app-streaming" + +# Waiting start all services +sleep 30 + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx diff --git a/scripts/install b/scripts/install index 5d5bf1e..f4a8f63 100644 --- a/scripts/install +++ b/scripts/install @@ -25,8 +25,10 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN admin_mastodon=$YNH_APP_ARG_ADMIN admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') -admin_pass=$YNH_APP_ARG_PASSWD +admin_pass=$(ynh_string_random 24) language=$YNH_APP_ARG_LANGUAGE +port_web=$(ynh_find_port 3000) +port_stream=$(ynh_find_port 4000) path_url="/" @@ -39,9 +41,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# TODO: remove this test, don't as password anymore, generate it and send it by email to admin with: https://github.com/YunoHost-Apps/Experimental_helpers/tree/master/send_readme_to_admin -[[ ${#admin_pass} -gt 7 ]] || ynh_die "Password is too weak, must be longer than 7 characters" - # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) @@ -54,11 +53,11 @@ ynh_webpath_register $app $domain $path_url # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set $app domain $domain -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 path $path_url +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app admin $admin_mastodon +ynh_app_setting_set $app language $language +ynh_app_setting_set $app port_web $port_web +ynh_app_setting_set $app port_stream $port_stream #================================================= @@ -87,16 +86,8 @@ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list ynh_package_update -# Creates the destination directory and stores its location. -ynh_app_setting_set "$app" final_path "$final_path" - -# Install de Node.js -# TODO: use https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_install_nodejs/ynh_install_nodejs -( - cd /opt - curl -sL https://deb.nodesource.com/setup_6.x | bash - - apt-get -y install nodejs -) +# install nodejs +ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies \ @@ -112,29 +103,27 @@ ynh_install_app_dependencies \ ffmpeg \ `# Yarn ` \ yarn - + #================================================= -# CREATE A DATABASE +# DATABASE SETUP #================================================= -# 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 - -ynh_psql_test_if_first_run - -db_user=$(ynh_sanitize_dbid "$app") +# Create postgresql database db_name="${app}_production" -db_name=$(ynh_sanitize_dbid "$db_name") -db_pwd=$(ynh_string_random) -ynh_app_setting_set $app db_name $db_name -ynh_app_setting_set $app db_pwd $db_pwd -ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" +db_pwd=$(ynh_string_random 30) +ynh_app_setting_set "$app" db_name "$db_name" +ynh_app_setting_set "$app" db_pwd "$db_pwd" +ynh_psql_test_if_first_run +ynh_psql_create_user "$app" "$db_pwd" +ynh_psql_execute_as_root \ +"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +# Creates the destination directory and stores its location. +ynh_app_setting_set "$app" final_path "$final_path" # Download all sources rbenv, ruby and mastodon ynh_setup_source "$final_path/.rbenv" "app-rbenv" @@ -145,19 +134,17 @@ ynh_setup_source "$final_path/live" "app-mastodon" # NGINX CONFIGURATION #================================================= -# TODO: use official helper ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@__PATH__@$app@g" ../conf/nginx.conf* -sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf* -cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +# Create a dedicated nginx config +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" +ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -# TODO: use official helper ynh_system_user_create -# Create user unix -adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password +# Create a system user +ynh_system_user_create $app chown -R "$app" "$final_path" @@ -189,34 +176,32 @@ yarn install --pure-lockfile popd # Adjust Mastodon config -# TODO: use official helper ynh_replace_string -# TODO: save the config file in conf folder, to make replacement easier to read -# TODO: use ynh_string_random + 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=${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_pwd}@g" "${final_path}/live/.env.production" -sed -i "s@LOCAL_DOMAIN=example.com@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" +ynh_replace_string "REDIS_HOST=redis" "REDIS_HOST=127.0.0.1" "${final_path}/live/.env.production" +ynh_replace_string "DB_HOST=db" "DB_HOST=/var/run/postgresql" "${final_path}/live/.env.production" +ynh_replace_string "DB_USER=postgres" "DB_USER=${app}" "${final_path}/live/.env.production" +ynh_replace_string "DB_NAME=postgres" "DB_NAME=${db_name}" "${final_path}/live/.env.production" +ynh_replace_string "DB_PASS=" "DB_PASS=${db_pwd}" "${final_path}/live/.env.production" +ynh_replace_string "LOCAL_DOMAIN=example.com" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" language="$(echo $language | head -c 2)" -sed -i "s@# DEFAULT_LOCALE=de@DEFAULT_LOCALE=${language}@g" "${final_path}/live/.env.production" +ynh_replace_string "# DEFAULT_LOCALE=de" "DEFAULT_LOCALE=${language}" "${final_path}/live/.env.production" paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=${paperclip_secret}@g" "${final_path}/live/.env.production" -sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=${secret_key_base}@g" "${final_path}/live/.env.production" -sed -i "s@OTP_SECRET=@OTP_SECRET=${otp_secret}@g" "${final_path}/live/.env.production" +ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" +ynh_replace_string "SECRET_KEY_BASE=" "SECRET_KEY_BASE=$secret_key_base" "${final_path}/live/.env.production" +ynh_replace_string "OTP_SECRET=" "OTP_SECRET=$otp_secret" "${final_path}/live/.env.production" -sed -i "s@SMTP_LOGIN=@#SMTP_LOGIN=@g" "${final_path}/live/.env.production" -sed -i "s@SMTP_PASSWORD=@#SMTP_PASSWORD=@g" "${final_path}/live/.env.production" -sed -i "s@SMTP_SERVER=smtp.mailgun.org@SMTP_SERVER=localhost@g" "${final_path}/live/.env.production" -sed -i "s@SMTP_PORT=587@SMTP_PORT=25@g" "${final_path}/live/.env.production" -sed -i 's,SMTP_FROM_ADDRESS=notifications@example.com,SMTP_FROM_ADDRESS='${admin_mastodon}'@'${domain}',' "${final_path}/live/.env.production" -sed -i "s@#SMTP_AUTH_METHOD=plain@SMTP_AUTH_METHOD=none@g" "${final_path}/live/.env.production" -sed -i "s@#SMTP_OPENSSL_VERIFY_MODE=peer@SMTP_OPENSSL_VERIFY_MODE=none@g" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_LOGIN=" "#SMTP_LOGIN=" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_PASSWORD=" "#SMTP_PASSWORD=" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_SERVER=smtp.mailgun.org" "SMTP_SERVER=localhost" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_PORT=587" "SMTP_PORT=25" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_FROM_ADDRESS=notifications@example.com" "SMTP_FROM_ADDRESS=$admin_mastodon@$domain" "${final_path}/live/.env.production" +ynh_replace_string "#SMTP_AUTH_METHOD=plain" "SMTP_AUTH_METHOD=none" "${final_path}/live/.env.production" +ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_VERIFY_MODE=none" "${final_path}/live/.env.production" # Preconfig CSS & JS # Install Mastodon @@ -232,9 +217,14 @@ sed -i "s@#SMTP_OPENSSL_VERIFY_MODE=peer@SMTP_OPENSSL_VERIFY_MODE=none@g" "${fin INSTALL ) -# TODO: use ynh_find_port to have generic port selection for RAILS +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" ynh_add_systemd_config "$app-web" "mastodon-web.service" -# TODO: use ynh_find_port to have generic port selection for NODES ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" @@ -286,3 +276,15 @@ ynh_app_setting_set "$app" unprotected_uris "/" # Reload Nginx systemctl reload nginx + +#================================================= +# SEND A README FOR THE ADMIN +#================================================= + +message="Mastodon was successfully installed :) +Please open 'https://$domain$path_url' +The admin username is: '$admin_mastodon_mail' +The admin password is: '$admin_pass' +If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" + +ynh_send_readme_to_admin "$message" "$admin_mastodon" diff --git a/scripts/remove b/scripts/remove index 0ea12df..b92d3b9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers source _future.sh - #================================================= # LOAD SETTINGS #================================================= @@ -22,11 +21,6 @@ app=$YNH_APP_INSTANCE_NAME # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) db_name=$(ynh_app_setting_get "$app" db_name) -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set "$app" db_name "$db_name" -fi -db_user=$(ynh_sanitize_dbid "$app") final_path=$(ynh_app_setting_get "$app" final_path) #================================================= @@ -67,13 +61,13 @@ fi # Remove metapackage and its dependencies ynh_remove_app_dependencies - +ynh_remove_nodejs #================================================= # REMOVE THE PostgreSQL DATABASE #================================================= # delete postgresql database & user -ynh_psql_remove_db "$db_name" "$db_user" +ynh_psql_remove_db "$db_name" "$app" #================================================= # REMOVE APP MAIN DIR @@ -85,18 +79,12 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= - -ynh_secure_remove "/etc/nginx/conf.d/${domain}.d/${app}.conf" -systemctl reload nginx +ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE THE CRON FILE -#================================================= -# Delete cronlog -ynh_secure_remove /etc/cron.d/$app #================================================= # REMOVE source.list @@ -115,5 +103,4 @@ ynh_secure_remove /etc/apt/sources.list.d/yarn.list #================================================= # REMOVE DEDICATED USER #================================================= - -userdel -f $app +ynh_system_user_delete $app diff --git a/scripts/restore b/scripts/restore index a8dc79f..4716e64 100644 --- a/scripts/restore +++ b/scripts/restore @@ -62,8 +62,7 @@ ynh_restore_file "$final_path" # RECREATE THE DEDICATED USER #================================================= -# Create user unix -adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password +ynh_system_user_create $app #================================================= # RESTORE USER RIGHTS @@ -95,13 +94,8 @@ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list ynh_package_update -# Install de Node.js -# TODO: use https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_install_nodejs/ynh_install_nodejs -( - cd /opt - curl -sL https://deb.nodesource.com/setup_6.x | bash - - apt-get -y install nodejs -) +# install nodejs +ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies \ @@ -123,25 +117,17 @@ ynh_install_app_dependencies \ #================================================= # Restore PostgreSQL database -db_user=$(ynh_sanitize_dbid "$app") + db_name=$(ynh_app_setting_get "$app" db_name) -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set "$app" db_name "$db_name" -fi db_pwd=$(ynh_app_setting_get "$app" db_pwd) ynh_psql_test_if_first_run -ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" +ynh_psql_create_user "$app" "$db_pwd" +ynh_psql_execute_as_root \ +"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" ynh_psql_execute_file_as_root ./db.sql "$db_name" -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= -yunohost service add $app-web -yunohost service add $app-sidekiq -yunohost service add $app-streaming #================================================= # RESTORE SYSTEMD @@ -152,11 +138,21 @@ ynh_restore_file "/etc/systemd/system/$app-sidekiq.service" ynh_restore_file "/etc/systemd/system/$app-streaming.service" systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app-web +yunohost service add $app-sidekiq +yunohost service add $app-streaming + #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND services #================================================= systemctl restart "$app-web" "$app-sidekiq" "$app-streaming" +# Waiting start all services +sleep 30 systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index c6b7a83..a9cde11 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,8 @@ admin=$(ynh_app_setting_get "$app" admin) language=$(ynh_app_setting_get "$app" language) final_path=$(ynh_app_setting_get "$app" final_path) path_url="/" +port_web=$(ynh_app_setting_get "$app" port_web) +port_stream=$(ynh_app_setting_get "$app" port_stream) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -48,14 +50,6 @@ if [[ "$admin" = "" || "$language" = "" ]]; then ynh_die fi -# If db_pwd doesn't exist, create it -if [[ -z "$db_pwd" ]]; then - db_pwd=$(ynh_string_random) - ynh_app_setting_set $app db_pwd $db_pwd - ynh_psql_test_if_first_run - sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres - sed -i "s@DB_PASS=@DB_PASS=${db_pwd}@g" "${final_path}/live/.env.production" -fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -86,14 +80,7 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis # INSTALL DEPENDENCIES #================================================= -# upgrade Node.js v4 to v6 -# TODO: use https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_install_nodejs/ynh_install_nodejs -node_version=$(nodejs --version) -if [[ $node_version =~ ^v4.*$ ]]; then - pushd /opt - curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - - sudo apt-get -y install nodejs -fi +ynh_install_nodejs 8 # add additional package for upgrade ynh_package_install pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all @@ -112,20 +99,25 @@ yunohost service stop "$app-sidekiq" yunohost service stop "$app-streaming" # Download Mastodon -ynh_setup_source "$final_path/live" "app-mastodon" +ynh_setup_source "$final_path/live" "app-mastodon" -# Clean un-need Files +# Clean files which are not needed anymore ynh_secure_remove $final_path/live/config/initializers/timeout.rb #================================================= # NGINX CONFIGURATION #================================================= -# TODO: use official helper ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@__PATH__@$app@g" ../conf/nginx.conf* -sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf* -cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" +ynh_add_nginx_config + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a system user +ynh_system_user_create $app # Upgrade rbenv and ruby plugins ynh_setup_source "$final_path/.rbenv" "app-rbenv" @@ -176,9 +168,25 @@ RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails db: COMMANDS ) #================================================= -# RESTART MASTODON +# SETUP SYSTEMD #================================================= +# Create a dedicated systemd config +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" +ynh_add_systemd_config "$app-web" "mastodon-web.service" +ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" +ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +# Add service YunoHost +yunohost service add "$app-web" +yunohost service add "$app-sidekiq" +yunohost service add "$app-streaming" + yunohost service start "$app-web" yunohost service start "$app-sidekiq" yunohost service start "$app-streaming" From 531aaa6a47c87e41f18eff02a4dd10d2481f9a08 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 21 Jun 2018 08:44:18 +0530 Subject: [PATCH 002/129] Fallback user create command --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index f4a8f63..cd9a1ce 100644 --- a/scripts/install +++ b/scripts/install @@ -144,7 +144,7 @@ ynh_add_nginx_config #================================================= # Create a system user -ynh_system_user_create $app +adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password chown -R "$app" "$final_path" diff --git a/scripts/restore b/scripts/restore index 4716e64..a25bb6f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -62,7 +62,7 @@ ynh_restore_file "$final_path" # RECREATE THE DEDICATED USER #================================================= -ynh_system_user_create $app +adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index a9cde11..0f99bab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,12 +112,6 @@ ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= - -# Create a system user -ynh_system_user_create $app # Upgrade rbenv and ruby plugins ynh_setup_source "$final_path/.rbenv" "app-rbenv" From f13690c38b42b07b75598018c85b4b84a88c3d24 Mon Sep 17 00:00:00 2001 From: nemsia Date: Thu, 21 Jun 2018 11:08:52 +0200 Subject: [PATCH 003/129] Add $db_pwd compatibility --- scripts/upgrade | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 0f99bab..0350efe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,6 +50,14 @@ if [[ "$admin" = "" || "$language" = "" ]]; then ynh_die fi +# If db_pwd doesn't exist, create it, need for old install +if [[ -z "$db_pwd" ]]; then + db_pwd=$(ynh_string_random) + ynh_app_setting_set $app db_pwd $db_pwd + ynh_psql_test_if_first_run + sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres + sed -i "s@DB_PASS=@DB_PASS=${db_pwd}@g" "${final_path}/live/.env.production" +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP From fc1dee56d6d0885aedf7525515a9eff7fcda895b Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Fri, 22 Jun 2018 14:00:26 +0530 Subject: [PATCH 004/129] used ynh_replace_string in upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0350efe..0429013 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,7 +56,7 @@ if [[ -z "$db_pwd" ]]; then ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres - sed -i "s@DB_PASS=@DB_PASS=${db_pwd}@g" "${final_path}/live/.env.production" + ynh_replace_string "DB_PASS=" "DB_PASS=${db_pwd}" "${final_path}/live/.env.production" fi #================================================= From 11bdcf719fe8c0caaf07cc80445e57fa4f90dcb8 Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Wed, 11 Jul 2018 20:57:38 +0530 Subject: [PATCH 005/129] Sources updated to 2.4.3 --- conf/app-mastodon.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index fa0e2eb..9ef161a 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.2.tar.gz -SOURCE_SUM=2de73e57e4f3da4b046b8b1d8c90a03d1bdd8f9abddca8f5329d02a34ed821a5 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.3.tar.gz +SOURCE_SUM=efdc680632386665d7b0ba988acd18113557ad165bcc158bfc2c273da76616ce SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From a2a9266d0eaf9c9bd57932fdb86bd7a667bb2693 Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Wed, 11 Jul 2018 20:59:44 +0530 Subject: [PATCH 006/129] Manifest updated to version 2.4.3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index fed1d7d..7496980 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.4.2", + "version": "2.4.3", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From f72f77e56ca52c1658db66f53faac90a589fd715 Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Wed, 11 Jul 2018 21:01:02 +0530 Subject: [PATCH 007/129] Readme updated to version 2.4.3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bcfa53c..bd525b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.4.2-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.4.3-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) From 8a29c1db52736c599aea04782e48346741b06ae5 Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 25 Aug 2018 00:26:40 +0200 Subject: [PATCH 008/129] [mod] Add CSP for security --- conf/nginx.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 585109e..eb823e7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,9 @@ # upload max size client_max_body_size 100M; +# Content Security Policy : security to avoid launching unsecure script +add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://$domain;"; + # add to v1.4 assets root __FINALPATH__/live/public; From 9f983fa602a525d83109d26f3a5e72f5dfa9235f Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 25 Aug 2018 00:37:39 +0200 Subject: [PATCH 009/129] [fix] object-src --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index eb823e7..562ba8c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ client_max_body_size 100M; # Content Security Policy : security to avoid launching unsecure script -add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://$domain;"; +add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__;"; # add to v1.4 assets root __FINALPATH__/live/public; From 16cfcba4e1571b11710e0b084770ce462430677e Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 25 Aug 2018 00:45:54 +0200 Subject: [PATCH 010/129] [mod] use official helper for nginx I didn't find any __PATH__ in nginx config... ?? --- scripts/install | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 5d5bf1e..b33f6ed 100644 --- a/scripts/install +++ b/scripts/install @@ -145,11 +145,7 @@ ynh_setup_source "$final_path/live" "app-mastodon" # NGINX CONFIGURATION #================================================= -# TODO: use official helper ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@__PATH__@$app@g" ../conf/nginx.conf* -sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf* -cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +ynh_add_nginx_config #================================================= # CREATE DEDICATED USER From 29399adc3d0049ddefe33a509e263d36881a31fe Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 25 Aug 2018 00:48:50 +0200 Subject: [PATCH 011/129] [mod] Use nginx Helper. See mod for install --- scripts/upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c6b7a83..15075a3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,11 +121,11 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb # NGINX CONFIGURATION #================================================= -# TODO: use official helper ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@__PATH__@$app@g" ../conf/nginx.conf* -sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf* -cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +ynh_add_nginx_config + +#================================================= +# UPGRADE MASTODON +#================================================= # Upgrade rbenv and ruby plugins ynh_setup_source "$final_path/.rbenv" "app-rbenv" From d49f381c47c57189c55e3bc03de13a52f17a7a3d Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Fri, 31 Aug 2018 02:31:48 +0530 Subject: [PATCH 012/129] Updated sources to version 2.4.5 --- conf/app-mastodon.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 9ef161a..a63adff 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.3.tar.gz -SOURCE_SUM=efdc680632386665d7b0ba988acd18113557ad165bcc158bfc2c273da76616ce +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.5.tar.gz +SOURCE_SUM=9e8cf6a808c9c34b6b609e8acc86b91a02227580b61221d96a4b78560fcc592c SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From a2163df76a79ecb78240438909d62d62db3b1238 Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Fri, 31 Aug 2018 02:34:02 +0530 Subject: [PATCH 013/129] Updated manifest for version 2.4.5 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7496980..9e87449 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.4.3", + "version": "2.4.5", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From d14e574e4324dc37cf2757fbe62f7d154781db51 Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Fri, 31 Aug 2018 02:35:51 +0530 Subject: [PATCH 014/129] Updated readme to version 2.4.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd525b0..cce244f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.4.3-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.4.5-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) From 19c46d2d2bf3a02aba89ee0596f8b5f95e15a642 Mon Sep 17 00:00:00 2001 From: frju365 Date: Fri, 31 Aug 2018 01:47:32 +0200 Subject: [PATCH 015/129] [fix] nginx conf --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index ffa152a..ee17c03 100644 --- a/scripts/install +++ b/scripts/install @@ -271,6 +271,8 @@ ynh_app_setting_set "$app" unprotected_uris "/" # RELOAD NGINX #================================================= +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" # Reload Nginx systemctl reload nginx From aaa1b11ad1ae6c2cc620567ce9dee7a7eba86023 Mon Sep 17 00:00:00 2001 From: frju365 Date: Fri, 31 Aug 2018 01:48:09 +0200 Subject: [PATCH 016/129] Update upgrade --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 207858e..3b42aa6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,6 +116,8 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb # NGINX CONFIGURATION #================================================= +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config #================================================= From e5d9f9cece396f8c82326bf3b458ac4442535db1 Mon Sep 17 00:00:00 2001 From: nemsia Date: Mon, 3 Sep 2018 01:02:28 +0200 Subject: [PATCH 017/129] Revert "Nginx : CSP + typo" (#113) --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/nginx.conf | 3 --- manifest.json | 2 +- scripts/install | 3 +++ scripts/upgrade | 5 ++--- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cce244f..bd525b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.4.5-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.4.3-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index a63adff..9ef161a 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.5.tar.gz -SOURCE_SUM=9e8cf6a808c9c34b6b609e8acc86b91a02227580b61221d96a4b78560fcc592c +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.3.tar.gz +SOURCE_SUM=efdc680632386665d7b0ba988acd18113557ad165bcc158bfc2c273da76616ce SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 87b517a..a183a31 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,6 @@ # upload max size client_max_body_size 100M; -# Content Security Policy : security to avoid launching unsecure script -add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__;"; - # add to v1.4 assets root __FINALPATH__/live/public; diff --git a/manifest.json b/manifest.json index 9e87449..7496980 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.4.5", + "version": "2.4.3", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/install b/scripts/install index ffa152a..cd9a1ce 100644 --- a/scripts/install +++ b/scripts/install @@ -134,6 +134,9 @@ ynh_setup_source "$final_path/live" "app-mastodon" # NGINX CONFIGURATION #================================================= +# Create a dedicated nginx config +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 207858e..0429013 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,11 +116,10 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb # NGINX CONFIGURATION #================================================= +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config -#================================================= -# UPGRADE MASTODON -#================================================= # Upgrade rbenv and ruby plugins ynh_setup_source "$final_path/.rbenv" "app-rbenv" From 91ddc5f6f22530c1ea274a964975747153801787 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Mon, 3 Sep 2018 16:22:31 +0530 Subject: [PATCH 018/129] Updated to version 2.5.0 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/nginx.conf | 3 +++ manifest.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cce244f..d81ad4a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.4.5-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.5.0-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index a63adff..32aa8c6 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.4.5.tar.gz -SOURCE_SUM=9e8cf6a808c9c34b6b609e8acc86b91a02227580b61221d96a4b78560fcc592c +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.5.0.tar.gz +SOURCE_SUM=0b36693058647ab50fff7f1c0c678f0f2b2997908c542c488386e8e16beced74 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index a183a31..156d56d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,9 @@ # upload max size client_max_body_size 100M; +# Content Security Policy : security to avoid launching unsecure script +add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__;"; + # add to v1.4 assets root __FINALPATH__/live/public; diff --git a/manifest.json b/manifest.json index 9e87449..248cf01 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.4.5", + "version": "2.5.0", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From c0f6ab9d6b2974e21cdc7e1256b33866013ee54b Mon Sep 17 00:00:00 2001 From: anmol26s Date: Mon, 3 Sep 2018 21:12:35 +0530 Subject: [PATCH 019/129] Remove nginx replace string duplicate in install --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 8c18517..cd9a1ce 100644 --- a/scripts/install +++ b/scripts/install @@ -274,8 +274,6 @@ ynh_app_setting_set "$app" unprotected_uris "/" # RELOAD NGINX #================================================= -ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" -ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" # Reload Nginx systemctl reload nginx From 2caf4e63f54317a0e3a0bf767811e29266274f15 Mon Sep 17 00:00:00 2001 From: nemsia Date: Wed, 5 Sep 2018 00:12:07 +0200 Subject: [PATCH 020/129] Remove nginx duplicated lines --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index cd9a1ce..e82774b 100644 --- a/scripts/install +++ b/scripts/install @@ -222,8 +222,6 @@ INSTALL #================================================= # Create a dedicated systemd config -ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" -ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" ynh_add_systemd_config "$app-web" "mastodon-web.service" ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" From 961d8c13393cbba7d35e8ef539514db6cc02bbfc Mon Sep 17 00:00:00 2001 From: anmol26s Date: Fri, 12 Oct 2018 07:21:32 +0530 Subject: [PATCH 021/129] Updated to version 2.5.2 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/app-ruby-build.src | 4 ++-- manifest.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d81ad4a..5c56dde 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.5.0-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.5.2-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 32aa8c6..fedac19 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.5.0.tar.gz -SOURCE_SUM=0b36693058647ab50fff7f1c0c678f0f2b2997908c542c488386e8e16beced74 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.5.2.tar.gz +SOURCE_SUM=d25e432f1fcf223270414dd55be4d2878f1af86c21b1f2d7874fa1c57d75ebfb SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index 3041556..8bf0719 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180424.tar.gz -SOURCE_SUM=71dbaf87081369c1f5d27b6a94a927c1eeeb1f36bdffe7851f0a9c1ec87b9373 +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180822.tar.gz +SOURCE_SUM=36dead9a0031f1b42b876f6d6def0fccdddc7d6277c7968ec649ffde82a4e137 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 248cf01..4555fe1 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.5.0", + "version": "2.5.2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From 71d274fbb09471952704f499254cfe68d4f4a4d5 Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 13 Oct 2018 21:17:41 +0200 Subject: [PATCH 022/129] [enh] Allow peertube video which comes from a subdomain --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 156d56d..b5cbddd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ client_max_body_size 100M; # Content Security Policy : security to avoid launching unsecure script -add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self'; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__;"; +add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self' *.__DOMAIN__; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' *.__DOMAIN__; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__ *.__DOMAIN__;"; # add to v1.4 assets root __FINALPATH__/live/public; From 8ab18453580d4a4234eafd8ad7c3379a3e9db98f Mon Sep 17 00:00:00 2001 From: anmol Date: Fri, 2 Nov 2018 07:41:12 +0530 Subject: [PATCH 023/129] Updated to version 2.6.1 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/app-ruby-build.src | 4 ++-- manifest.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5c56dde..72a09e0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.5.2-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.6.1-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index fedac19..afab612 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.5.2.tar.gz -SOURCE_SUM=d25e432f1fcf223270414dd55be4d2878f1af86c21b1f2d7874fa1c57d75ebfb +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.1.tar.gz +SOURCE_SUM=7809c829a589a94a7a10eda4374eb98b36b742e84cf5841be39a7617a98f4809 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index 8bf0719..eb268fb 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180822.tar.gz -SOURCE_SUM=36dead9a0031f1b42b876f6d6def0fccdddc7d6277c7968ec649ffde82a4e137 +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181019.tar.gz +SOURCE_SUM=5ac5838e81ac06478aa23de79aefc4196f7d1ba8aa1a3cc03bc6e81708463a9e SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 4555fe1..6ab1f85 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.5.2", + "version": "2.6.2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From 1752d37cbdea9407143fa09486928b05434764da Mon Sep 17 00:00:00 2001 From: anmol Date: Fri, 2 Nov 2018 18:48:49 +0530 Subject: [PATCH 024/129] Ruby update 2.5.3 --- scripts/upgrade | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0429013..0234b84 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,25 +127,25 @@ ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" # Install ruby 2.5.1 ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.1 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1 || true - exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v ) # Create symlink for ruby rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true # Preconfig CSS & JS # Install Mastodon ( sudo su - $app < Date: Tue, 6 Nov 2018 15:20:18 +0530 Subject: [PATCH 025/129] Added npm install -D babel-loader @babel/core @babel/preset-env webpack --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 0234b84..6b03973 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -154,6 +154,7 @@ MCOMMANDS # Install package with yarn and restart postgresql pushd $final_path/live yarn install --pure-lockfile +npm install -D babel-loader @babel/core @babel/preset-env webpack systemctl restart postgresql popd From 9d07d121ad516bf0d3db1c5eb700cb6575630802 Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 7 Nov 2018 09:42:21 +0530 Subject: [PATCH 026/129] Upgrade error fix and cron job --- conf/cron | 2 ++ manifest.json | 2 +- scripts/backup | 6 ++++++ scripts/install | 13 +++++++++---- scripts/remove | 2 ++ scripts/restore | 6 ++++++ scripts/upgrade | 10 +++++++++- 7 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 conf/cron diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..2b80d85 --- /dev/null +++ b/conf/cron @@ -0,0 +1,2 @@ +RAILS_ENV=production +@daily cd __FINAL__PATH__/live && __FINAL__PATH__/.rbenv/shims/bundle exec rake __USER__:media:remove_remote diff --git a/manifest.json b/manifest.json index 6ab1f85..5bc3c05 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.6.2", + "version": "2.6.1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/backup b/scripts/backup index bc1822a..eeee720 100644 --- a/scripts/backup +++ b/scripts/backup @@ -73,6 +73,12 @@ ynh_backup "/etc/systemd/system/$app-web.service" ynh_backup "/etc/systemd/system/$app-sidekiq.service" ynh_backup "/etc/systemd/system/$app-streaming.service" +#================================================= +# BACKUP THE CRON FILE +#================================================= + +ynh_backup "/etc/cron.d/$app" + #================================================= # BACKUP THE sources.list FILES #================================================= diff --git a/scripts/install b/scripts/install index e82774b..d457b8b 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.1 - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1 - exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v ) # Create symlink for ruby rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true # Yarn install on root pushd $final_path/live @@ -260,6 +260,11 @@ yunohost service add "$app-web" yunohost service add "$app-sidekiq" yunohost service add "$app-streaming" +# SETUP CRON JOB FOR REMOVING CACHE +ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron +ynh_replace_string "__USER__" "$app" ../conf/cron +sudo cp -f ../conf/cron /etc/cron.d/$app + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index b92d3b9..c6c6b05 100644 --- a/scripts/remove +++ b/scripts/remove @@ -85,6 +85,8 @@ ynh_remove_nginx_config # SPECIFIC REMOVE #================================================= +# Remove a cron file +ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE source.list diff --git a/scripts/restore b/scripts/restore index a25bb6f..822f8fc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -146,6 +146,12 @@ yunohost service add $app-web yunohost service add $app-sidekiq yunohost service add $app-streaming +#================================================= +# RESTORE THE CRON FILE +#================================================= + +ynh_restore_file "/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6b03973..f837c9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -107,7 +107,11 @@ yunohost service stop "$app-sidekiq" yunohost service stop "$app-streaming" # Download Mastodon +mv "$final_path/live" "$final_path/live_back" ynh_setup_source "$final_path/live" "app-mastodon" +rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." +rsync -a "$final_path/live_back/.env.production" "$final_path/live/." +rm -Rf "$final_path/live_back" # Clean files which are not needed anymore ynh_secure_remove $final_path/live/config/initializers/timeout.rb @@ -154,7 +158,6 @@ MCOMMANDS # Install package with yarn and restart postgresql pushd $final_path/live yarn install --pure-lockfile -npm install -D babel-loader @babel/core @babel/preset-env webpack systemctl restart postgresql popd @@ -197,6 +200,11 @@ yunohost service start "$app-streaming" # Waiting start all services sleep 30 +# SETUP CRON JOB FOR REMOVING CACHE +ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron +ynh_replace_string "__USER__" "$app" ../conf/cron +sudo cp -f ../conf/cron /etc/cron.d/$app + #================================================= # RELOAD NGINX #================================================= From 49e7f8ac7d89ad9ae211d5149b88438ddf64874c Mon Sep 17 00:00:00 2001 From: anmol Date: Sun, 25 Nov 2018 16:09:47 +0530 Subject: [PATCH 027/129] Updated to version 2.6.2 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 72a09e0..becf009 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.6.1-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.6.2-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index afab612..8c06487 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.1.tar.gz -SOURCE_SUM=7809c829a589a94a7a10eda4374eb98b36b742e84cf5841be39a7617a98f4809 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.2.tar.gz +SOURCE_SUM=3d2ae0eaf64bebed30d8f982e74eb30dd10352af8f2bf227ad34932cfcbe4672 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 5bc3c05..6ab1f85 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.6.1", + "version": "2.6.2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From 5a4c797f6b229309fa1e9831727b972b2dfe0f66 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Tue, 11 Dec 2018 04:00:37 +0530 Subject: [PATCH 028/129] Updated to version 2.6.5 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/app-ruby-build.src | 4 ++-- manifest.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index becf009..533bcb6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.6.2-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.6.5-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 8c06487..ca8a7c6 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.2.tar.gz -SOURCE_SUM=3d2ae0eaf64bebed30d8f982e74eb30dd10352af8f2bf227ad34932cfcbe4672 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.5.tar.gz +SOURCE_SUM=697cb060f178a88c6f2a730d3ac9234babf9aa04d11086693a3e64e7ea1b1d62 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index eb268fb..7afb6e4 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181019.tar.gz -SOURCE_SUM=5ac5838e81ac06478aa23de79aefc4196f7d1ba8aa1a3cc03bc6e81708463a9e +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181207.tar.gz +SOURCE_SUM=74b4ffac4e8d6e68685afad035c64573280e93dfb2ab81fd7b613085e8a69c23 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 6ab1f85..ba0fb7c 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.6.2", + "version": "2.6.5", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { From 26787f12cddb73da7f68f39e6e98f818b2cdfef6 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 04:42:07 +0530 Subject: [PATCH 029/129] Fix:version rbenv --- scripts/install | 8 ++++---- scripts/remove | 9 --------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/install b/scripts/install index d457b8b..c21ecf2 100644 --- a/scripts/install +++ b/scripts/install @@ -96,7 +96,7 @@ ynh_install_app_dependencies \ `# redis ` \ redis-server redis-tools \ `# postgresql ` \ - postgresql \ + postgresql postgresql-contrib \ `# Ruby ` \ autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ `# ffmpeg from backports ` \ @@ -146,7 +146,7 @@ ynh_add_nginx_config # Create a system user adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password -chown -R "$app" "$final_path" +chown -R "$app": "$final_path" # TODO: try to use ynh_install_ruby from https://github.com/YunoHost-Apps/Experimental_helpers # Install de rbenv @@ -208,7 +208,7 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V ( cd "$final_path/live" su mastodon <> .env.production @@ -249,7 +249,7 @@ SETADMIN #================================================= # TODO:Set permissions to app files -chown -R "$app" "$final_path" +chown -R "$app": "$final_path" #================================================= # ADVERTISE SERVICE IN ADMIN PANEL diff --git a/scripts/remove b/scripts/remove index c6c6b05..6d6679b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -88,15 +88,6 @@ ynh_remove_nginx_config # Remove a cron file ynh_secure_remove "/etc/cron.d/$app" -#================================================= -# REMOVE source.list -#================================================= -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - ynh_secure_remove /etc/apt/sources.list.d/backports.list - ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list -fi -ynh_secure_remove /etc/apt/sources.list.d/yarn.list - # Delete ruby exec #ynh_secure_remove /usr/bin/ruby From a350fef6a82244e1206bac9da6a77fade378fcb9 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 07:06:37 +0530 Subject: [PATCH 030/129] Fix:command to make user admin --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c21ecf2..da834f5 100644 --- a/scripts/install +++ b/scripts/install @@ -237,8 +237,8 @@ account = Account.create!(username: '$admin_mastodon') user = User.create!(email: '$admin_mastodon_mail', password: '$admin_pass', account: account) CREATEUSER su mastodon < Date: Wed, 26 Dec 2018 08:11:35 +0530 Subject: [PATCH 031/129] Fix:command to make user admin --- scripts/install | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index da834f5..7b3e789 100644 --- a/scripts/install +++ b/scripts/install @@ -209,10 +209,10 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V cd "$final_path/live" su mastodon <> .env.production - RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet + RAILS_ENV=production $final_path/live/bin/bundle exec rails db:setup --quiet RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet INSTALL ) @@ -222,6 +222,8 @@ INSTALL #================================================= # Create a dedicated systemd config +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" ynh_add_systemd_config "$app-web" "mastodon-web.service" ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" @@ -237,7 +239,7 @@ account = Account.create!(username: '$admin_mastodon') user = User.create!(email: '$admin_mastodon_mail', password: '$admin_pass', account: account) CREATEUSER su mastodon < Date: Wed, 26 Dec 2018 08:33:06 +0530 Subject: [PATCH 032/129] Fix:command to make user admin --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 7b3e789..01f74d2 100644 --- a/scripts/install +++ b/scripts/install @@ -212,7 +212,7 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V $final_path/live/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test yarn install --production --no-progress --non-interactive --silent echo "SAFETY_ASSURED=1">> .env.production - RAILS_ENV=production $final_path/live/bin/bundle exec rails db:setup --quiet + RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet INSTALL ) From b3a1a8ccc5fb00e78ef5bbbe9a374ec8a66c0fb4 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 09:19:27 +0530 Subject: [PATCH 033/129] Try carriage return to automate --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 01f74d2..f58c049 100644 --- a/scripts/install +++ b/scripts/install @@ -161,9 +161,9 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \r + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \r + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \r ) # Create symlink for ruby From 2331c2ae2149351484db3c09dfb8c41e7a33b6bd Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 09:26:23 +0530 Subject: [PATCH 034/129] Try carriage return to automate --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index f58c049..11ded86 100644 --- a/scripts/install +++ b/scripts/install @@ -161,9 +161,9 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \r - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \r - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \r + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \n + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \n + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \n ) # Create symlink for ruby From ab60f7e6baf4bdbd4161ae56c9e1434ca0251e96 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 09:29:09 +0530 Subject: [PATCH 035/129] return to automate --- scripts/install | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 11ded86..097cd32 100644 --- a/scripts/install +++ b/scripts/install @@ -161,9 +161,11 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \n - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \n - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \n + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \ + + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \ + + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \ ) # Create symlink for ruby From 209a618e52a1d908f17d97b0a1b5d40b1b014d7f Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 11:00:48 +0530 Subject: [PATCH 036/129] Don't sync system folder if it don't exits while update --- scripts/install | 8 +++----- scripts/upgrade | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/scripts/install b/scripts/install index 097cd32..1536cd5 100644 --- a/scripts/install +++ b/scripts/install @@ -161,11 +161,9 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 \ - - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 \ - - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v \ + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v ) # Create symlink for ruby diff --git a/scripts/upgrade b/scripts/upgrade index f837c9c..f1be8c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,8 +90,20 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis ynh_install_nodejs 8 -# add additional package for upgrade -ynh_package_install pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all +# TODO: use the same mecanism with other files +ynh_install_app_dependencies \ + `# debian packages ` \ + imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ + `# redis ` \ + redis-server redis-tools \ + `# postgresql ` \ + postgresql postgresql-contrib \ + `# Ruby ` \ + autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ + `# ffmpeg from backports ` \ + ffmpeg \ + `# Yarn ` \ + yarn #================================================= # STANDARD UPGRADE STEPS @@ -109,7 +121,9 @@ yunohost service stop "$app-streaming" # Download Mastodon mv "$final_path/live" "$final_path/live_back" ynh_setup_source "$final_path/live" "app-mastodon" -rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." +if [ -z $final_path/live_back/public/system ]; then + rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." +fi rsync -a "$final_path/live_back/.env.production" "$final_path/live/." rm -Rf "$final_path/live_back" @@ -119,7 +133,6 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb #================================================= # NGINX CONFIGURATION #================================================= - ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config @@ -189,6 +202,8 @@ ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" #================================================= # Add service YunoHost +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" yunohost service add "$app-web" yunohost service add "$app-sidekiq" yunohost service add "$app-streaming" From 4941a424f10ed149db43d70f4846af3776737b38 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Wed, 26 Dec 2018 11:25:29 +0530 Subject: [PATCH 037/129] Set right permission to app while upgrade --- scripts/upgrade | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f1be8c1..d337e6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -109,8 +109,6 @@ ynh_install_app_dependencies \ # STANDARD UPGRADE STEPS #================================================= -# Change owner of live folder -chown -R $app: $final_path/live # Stop Mastodon Services # Restart Mastodon @@ -142,6 +140,8 @@ ynh_add_nginx_config ynh_setup_source "$final_path/.rbenv" "app-rbenv" ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" +chown -R "$app": "$final_path" + # Install ruby 2.5.1 ( exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true @@ -186,6 +186,10 @@ pushd ~/live RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails db:migrate COMMANDS ) + +# permissions to app files +chown -R "$app": "$final_path" + #================================================= # SETUP SYSTEMD #================================================= From 10ec0ffa7302c7359053eee2803b2cb50a06d3e2 Mon Sep 17 00:00:00 2001 From: frju365 Date: Sat, 29 Dec 2018 01:26:32 +0100 Subject: [PATCH 038/129] Useless CSP see https://github.com/tootsuite/mastodon/releases/tag/v2.6.0 --- conf/nginx.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b5cbddd..a183a31 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,6 @@ # upload max size client_max_body_size 100M; -# Content Security Policy : security to avoid launching unsecure script -add_header Content-Security-Policy "default-src 'none'; font-src 'self'; media-src 'self' *.__DOMAIN__; object-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' *.__DOMAIN__; img-src 'self' blob: data:; connect-src 'self' wss://__DOMAIN__ *.__DOMAIN__;"; - # add to v1.4 assets root __FINALPATH__/live/public; From 3436cdebe8a07a4da7ee53217afbd2517a594184 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 10:08:57 +0530 Subject: [PATCH 039/129] Install bundler:1.16.5 --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 1536cd5..fceb134 100644 --- a/scripts/install +++ b/scripts/install @@ -209,6 +209,7 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V cd "$final_path/live" su mastodon <> .env.production From 7a7653e321a1e5b365f1de1c52c30fe391dfda2a Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 11:04:30 +0530 Subject: [PATCH 040/129] Install bundler:1.16.5 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index fceb134..919d5e1 100644 --- a/scripts/install +++ b/scripts/install @@ -208,8 +208,8 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V ( cd "$final_path/live" su mastodon <> .env.production From e685d4d27a5bf08556c737e7aa7c9d86e22bbdac Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 11:53:50 +0530 Subject: [PATCH 041/129] Give proper right permission --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 919d5e1..f82126b 100644 --- a/scripts/install +++ b/scripts/install @@ -205,10 +205,12 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V # Preconfig CSS & JS # Install Mastodon +# Give right permission for the app +chown -R "$app": "$final_path" + ( cd "$final_path/live" su mastodon < Date: Mon, 7 Jan 2019 12:10:51 +0530 Subject: [PATCH 042/129] update bundler --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index f82126b..3bae370 100644 --- a/scripts/install +++ b/scripts/install @@ -212,6 +212,7 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production From 3647d3393d823ef53067de51ff5876c6f51e432e Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 14:43:36 +0530 Subject: [PATCH 043/129] Udated ruby-build to 2.6.0 --- conf/app-ruby-build.src | 4 ++-- scripts/install | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index 7afb6e4..b668784 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181207.tar.gz -SOURCE_SUM=74b4ffac4e8d6e68685afad035c64573280e93dfb2ab81fd7b613085e8a69c23 +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz +SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/scripts/install b/scripts/install index 3bae370..420dac1 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.6.0 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.6.0 || true + exec_as "$app" $final_path/.rbenv/versions/2.6.0/bin/ruby -v ) # Create symlink for ruby rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.6.0/bin/ruby /usr/bin/ruby || true # Yarn install on root pushd $final_path/live @@ -211,8 +211,8 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <> .env.production From 768d675a87d85f2dfb476945948d9b776043c666 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 15:11:41 +0530 Subject: [PATCH 044/129] Mastodon require ruby-build <2.6.0 --- conf/app-ruby-build.src | 4 ++-- scripts/install | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index b668784..b42dba6 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz -SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a +SOURCE_URL=https://github.com/rbenv/ruby-build/releases/tag/v20181019 +SOURCE_SUM=042232519a1c4623562fb533fff5e7764d8136c9b70a4e74a924a36d520af7a3 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/scripts/install b/scripts/install index 420dac1..3bae370 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.6.0 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.6.0 || true - exec_as "$app" $final_path/.rbenv/versions/2.6.0/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v ) # Create symlink for ruby rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.6.0/bin/ruby /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true # Yarn install on root pushd $final_path/live @@ -211,8 +211,8 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <> .env.production From 70884e56d454cb4cf561563c5ef608bbacedbd64 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 15:17:22 +0530 Subject: [PATCH 045/129] Mastodon require ruby-build <2.6.0 --- conf/app-ruby-build.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index b42dba6..eb268fb 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/releases/tag/v20181019 -SOURCE_SUM=042232519a1c4623562fb533fff5e7764d8136c9b70a4e74a924a36d520af7a3 +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181019.tar.gz +SOURCE_SUM=5ac5838e81ac06478aa23de79aefc4196f7d1ba8aa1a3cc03bc6e81708463a9e SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 880386bf2f19992b75c6d53df004a3ed42b1f7f5 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 15:36:16 +0530 Subject: [PATCH 046/129] Mastodon require ruby-build <2.6.0 --- scripts/install | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 3bae370..4af30b4 100644 --- a/scripts/install +++ b/scripts/install @@ -208,17 +208,33 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V # Give right permission for the app chown -R "$app": "$final_path" +# Install ruby 2.5.1 ( - cd "$final_path/live" - su mastodon <> .env.production - RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet - RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet -INSTALL + exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true + exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v +) + +# Create symlink for ruby +rm /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true + +# Preconfig CSS & JS +# Install Mastodon +( +sudo su - $app <> .env.production +RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet +RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet +MCOMMANDS ) #================================================= From 2604054b963ff0d70f20f532cf4767fe2ae25f87 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 15:49:16 +0530 Subject: [PATCH 047/129] Mastodon require ruby-build <2.6.0 --- scripts/install | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/scripts/install b/scripts/install index 4af30b4..0789620 100644 --- a/scripts/install +++ b/scripts/install @@ -208,33 +208,16 @@ ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_V # Give right permission for the app chown -R "$app": "$final_path" -# Install ruby 2.5.1 ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v -) - -# Create symlink for ruby -rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true - -# Preconfig CSS & JS -# Install Mastodon -( -sudo su - $app <> .env.production -RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet -RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet -MCOMMANDS + cd "$final_path/live" + su mastodon <> .env.production + RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet + RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet +INSTALL ) #================================================= From 1e5720f85b8becf011241441d94663f4ede6aeb4 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 17:04:14 +0530 Subject: [PATCH 048/129] Fix --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0789620..0d9bddd 100644 --- a/scripts/install +++ b/scripts/install @@ -212,7 +212,7 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet From 04f41b9cb2ab1f1820abd340f30344615a3dd812 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 7 Jan 2019 21:24:46 +0530 Subject: [PATCH 049/129] Fix --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0d9bddd..0789620 100644 --- a/scripts/install +++ b/scripts/install @@ -212,7 +212,7 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet From 047dbcf208fee3486ccd451c21929c9bdff9c3ff Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 9 Jan 2019 16:11:49 +0530 Subject: [PATCH 050/129] Fix --- scripts/install | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 0789620..ab44f3a 100644 --- a/scripts/install +++ b/scripts/install @@ -211,9 +211,11 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet From d4ddcf6642acf848fbf9b75ff1f04c93fb7e79fa Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 9 Jan 2019 17:03:07 +0530 Subject: [PATCH 051/129] Fix --- scripts/install | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index ab44f3a..cd4588c 100644 --- a/scripts/install +++ b/scripts/install @@ -153,10 +153,9 @@ chown -R "$app": "$final_path" ( cd $final_path/.rbenv src/configure && make -C src - - echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\" -eval \"\$(rbenv init -)\"" > $final_path/.profile - echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\"" > $final_path/.bashrc + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc + exec bash ) # Install ruby-build @@ -170,11 +169,6 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile rm /usr/bin/ruby || true ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true -# Yarn install on root -pushd $final_path/live -yarn install --pure-lockfile -popd - # Adjust Mastodon config cp -a $final_path/live/.env.production.sample $final_path/live/.env.production @@ -216,7 +210,6 @@ chown -R "$app": "$final_path" -j$(getconf _NPROCESSORS_ONLN) \ --deployment --without development test yarn install --pure-lockfile - echo "SAFETY_ASSURED=1">> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet INSTALL From 2d8b197984513e0a1c8a5f45b4102fb2d2d44551 Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 9 Jan 2019 17:12:23 +0530 Subject: [PATCH 052/129] Fix --- scripts/install | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index cd4588c..ce098a9 100644 --- a/scripts/install +++ b/scripts/install @@ -153,9 +153,10 @@ chown -R "$app": "$final_path" ( cd $final_path/.rbenv src/configure && make -C src - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc - echo 'eval "$(rbenv init -)"' >> ~/.bashrc - exec bash + + echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\" +eval \"\$(rbenv init -)\"" > $final_path/.profile + echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\"" > $final_path/.bashrc ) # Install ruby-build @@ -206,10 +207,11 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet INSTALL From f68fb1a2ef01937a47d698fbca05fdfbf6905821 Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 9 Jan 2019 17:24:30 +0530 Subject: [PATCH 053/129] Fix --- scripts/install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ce098a9..62263db 100644 --- a/scripts/install +++ b/scripts/install @@ -207,9 +207,10 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet From 25a9339c6e4861a432e3ad422b69bed8a851eea6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 14 Jan 2019 01:29:06 +0100 Subject: [PATCH 054/129] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 62263db..2c3993c 100644 --- a/scripts/install +++ b/scripts/install @@ -206,7 +206,7 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon < Date: Mon, 14 Jan 2019 01:49:00 +0100 Subject: [PATCH 055/129] Fix install --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2c3993c..8782cdb 100644 --- a/scripts/install +++ b/scripts/install @@ -210,7 +210,6 @@ chown -R "$app": "$final_path" $final_path/live/bin/bundle install \ -j$(getconf _NPROCESSORS_ONLN) \ --deployment --without development test - $final_path/live gem install bundler:1.16.6 yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> .env.production RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet From 6a0aab6a93abc3a73fbef2e434bdf6279bd43122 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 21 Jan 2019 16:37:43 +0530 Subject: [PATCH 056/129] Upgraded to version 2.7.0 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- conf/app-ruby-build.src | 4 ++-- manifest.json | 2 +- scripts/install | 10 +++++----- scripts/upgrade | 20 ++++++++++---------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 533bcb6..5ff3abb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.6.5-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.7.0-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index ca8a7c6..64b77bc 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.6.5.tar.gz -SOURCE_SUM=697cb060f178a88c6f2a730d3ac9234babf9aa04d11086693a3e64e7ea1b1d62 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.0.tar.gz +SOURCE_SUM=429d2be660aff3d77960ae87412ad7de82dab9c21363e2799db34948d2231d7b SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index eb268fb..b32b7b9 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181019.tar.gz -SOURCE_SUM=5ac5838e81ac06478aa23de79aefc4196f7d1ba8aa1a3cc03bc6e81708463a9e +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz +SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index ba0fb7c..9a2c4d4 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "mastodon", "packaging_format": 1, "requirements": { - "yunohost": ">= 2.7.9" + "yunohost": ">= 2.7.0" }, "description": { "en": "Mastodon is a free, open-source social network.", diff --git a/scripts/install b/scripts/install index 8782cdb..42d046a 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true - exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.6.0 || true + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.6.0 || true + exec_as "$app" $final_path/.rbenv/versions/2.6.0/bin/ruby -v ) # Create symlink for ruby rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true +ln -s $final_path/.rbenv/versions/2.6.0/bin/ruby /usr/bin/ruby || true # Adjust Mastodon config @@ -206,7 +206,7 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon < Date: Tue, 22 Jan 2019 12:13:13 +0530 Subject: [PATCH 057/129] Use of rbenv 2.6.0 --- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-web.service | 2 +- scripts/install | 13 +++++++------ scripts/upgrade | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index f788332..c799356 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="DB_POOL=20" - ExecStart=__FINALPATH__/live/bin/bundle exec sidekiq -c 20 -q default -q mailers -q pull -q push + ExecStart=__FINALPATH__/.rbenv/versions/2.6.0/bin/bundle exec sidekiq -c 20 -q default -q mailers -q pull -q push TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 46b304e..dd6f6d7 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" - ExecStart=__FINALPATH__/live/bin/bundle exec puma -C config/puma.rb + ExecStart=__FINALPATH__/.rbenv/versions/2.6.0/bin/bundle exec puma -C config/puma.rb TimeoutSec=15 Restart=always StandardError=syslog diff --git a/scripts/install b/scripts/install index 42d046a..54635e9 100644 --- a/scripts/install +++ b/scripts/install @@ -207,13 +207,14 @@ chown -R "$app": "$final_path" cd "$final_path/live" su mastodon <> .env.production - RAILS_ENV=production $final_path/live/bin/bundle exec rails db:migrate --quiet - RAILS_ENV=production $final_path/live/bin/bundle exec rails assets:precompile --quiet + RAILS_ENV=production $final_path/.rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet + RAILS_ENV=production $final_path/.rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet INSTALL ) @@ -234,13 +235,13 @@ systemctl start "$app-web.service" "$app-sidekiq.service" "$app-streaming.servic ( cd "$final_path/live" su mastodon < Date: Tue, 22 Jan 2019 12:45:32 +0530 Subject: [PATCH 058/129] Use of rbenv 2.6.0 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 54635e9..47e579c 100644 --- a/scripts/install +++ b/scripts/install @@ -206,7 +206,7 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon < Date: Tue, 22 Jan 2019 13:02:55 +0530 Subject: [PATCH 059/129] Use of rbenv 2.6.0 --- scripts/install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 47e579c..7859db8 100644 --- a/scripts/install +++ b/scripts/install @@ -206,9 +206,9 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon < Date: Tue, 22 Jan 2019 16:56:49 +0530 Subject: [PATCH 060/129] Fix account creation --- scripts/install | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 7859db8..3680b03 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN admin_mastodon=$YNH_APP_ARG_ADMIN admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') -admin_pass=$(ynh_string_random 24) language=$YNH_APP_ARG_LANGUAGE port_web=$(ynh_find_port 3000) port_stream=$(ynh_find_port 4000) @@ -234,17 +233,15 @@ systemctl start "$app-web.service" "$app-sidekiq.service" "$app-streaming.servic # Create user ( cd "$final_path/live" - su mastodon < acc.txt ) RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin SETADMIN ) +admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) +(cd $final_path/live && rm -f acc.txt) #================================================= # GENERIC FINALIZATION #================================================= From cc4c8e73e6e62e888ff1a8793276e3e04e93a8bd Mon Sep 17 00:00:00 2001 From: anmol Date: Tue, 12 Feb 2019 11:36:09 +0530 Subject: [PATCH 061/129] Updated to version 2.7.1 --- README.md | 2 +- conf/app-mastodon.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ff3abb..c3cbc9a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Latest Version](https://img.shields.io/badge/version-2.7.0-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-2.7.1-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) diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 64b77bc..4c68e9c 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.0.tar.gz -SOURCE_SUM=429d2be660aff3d77960ae87412ad7de82dab9c21363e2799db34948d2231d7b +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.1.tar.gz +SOURCE_SUM=d0a9d6f4514f78fcdc76943ce2518ce5008378c65b5ecbb3644026dc97c18ec1 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 9a2c4d4..3c06f54 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "mastodon", "packaging_format": 1, "requirements": { - "yunohost": ">= 2.7.0" + "yunohost": ">= 2.7.1" }, "description": { "en": "Mastodon is a free, open-source social network.", From edf6ab38147cafd2ff856130d4e0b22424199266 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 17 Jan 2019 21:43:47 +0100 Subject: [PATCH 062/129] Add a check that there's a reasonable quantity of RAM+swap available --- scripts/install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index 3680b03..0cb4675 100644 --- a/scripts/install +++ b/scripts/install @@ -40,6 +40,13 @@ app=$YNH_APP_INSTANCE_NAME final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" +# TODO : to be factorized into a helper someday ? ;) +MEM=$(free | grep "^Mem" | awk '{print $2}') +SWAP=$(free | grep "^Swap" | awk '{print $2}') +TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB + +[[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap." + # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) From f028b7f2afffd1fb60451a3d06ab861199268331 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 Mar 2019 04:22:38 +0100 Subject: [PATCH 063/129] Apply example_ynh --- README.md | 94 ++++++++++++++++++---------------- README_fr.md | 103 +++++++++++++++++++++++++++++++++++++ conf/app-mastodon.src | 4 +- conf/app-ruby-build.src | 4 +- manifest.json | 8 +-- scripts/_common.sh | 18 +++++++ scripts/backup | 14 ++++- scripts/install | 33 ++++++++++-- scripts/remove | 49 +++++++++++++----- scripts/restore | 21 ++++++-- scripts/upgrade | 111 ++++++++++++++++++++++++++++------------ 11 files changed, 346 insertions(+), 113 deletions(-) create mode 100644 README_fr.md diff --git a/README.md b/README.md index c3cbc9a..1e277dd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # Mastodon for YunoHost +[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) +[![Install mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) + +*[Lire ce readme en franais.](./README_fr.md)* + +> *This package allow you to install mastodon quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + [![Latest Version](https://img.shields.io/badge/version-2.7.1-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) @@ -7,59 +15,22 @@ [![Yunohost version](https://img.shields.io/badge/yunohost-2.7.12_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) [![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) - -:warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. - -:warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production - :warning: UPDATE 05/06/17 :This app can work now on ARM, but installation takes several hours and you must add a swapfile of 1GB. :warning: This application uses the Debian backports packages, do not install this application directly in production -## Mastodon c'est quoi ? +## Overview + +**Shipped version:** 2.7.4 + +## Screenshots + +![](https://framalibre.org/sites/default/files/mastodon.png) -Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Mastodon et participer au réseau social de façon transparente. [Source code](https://github.com/tootsuite/mastodon) -#### Ajout d'un "swapfile" si vous avez moins de 2Go de RAM -``` -sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000 -sudo chmod 600 /swapfile -sudo mkswap /swapfile -sudo swapon /swapfile -``` -ajouter cette ligne dans /etc/fstab -``` -/swapfile none swap sw 0 0 -``` - -### Installation - -#### Utilisation de __screen__ en cas de déconnection -``` -$ sudo apt-get install screen -$ screen -$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git -``` -Récuperer l'installation après une deconnection: -``` -$ screen -d -$ screen -r -``` -L'utilisateur admin est crée automatiquement comme: user@domain.tld - -### Mise à jour -#### Utilisation de __screen__ fortement recommandé - -`$ 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. +## Configuration ## What is Mastodon? @@ -103,3 +74,36 @@ The admin user is automatically created as: user@domain.tld 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. + +## Documentation + + * Official documentation: https://docs.joinmastodon.org/ + +## YunoHost specific features + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/mastodon%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/mastodon/) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues + * App website: Link to the official website of this app + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +or +sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..4f753ea --- /dev/null +++ b/README_fr.md @@ -0,0 +1,103 @@ +# Mastodon pour YunoHost + +[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) +[![Install mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer mastodon rapidement et simplement sur un serveur Yunohost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +[![Latest Version](https://img.shields.io/badge/version-2.7.1-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.7.12_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) +[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues) + +:warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. + +:warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production + +## Vue d'ensemble +Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Mastodon et participer au réseau social de façon transparente. + +**Version incluse:** 2.7.4 + +## Captures d'écran + +![](https://framalibre.org/sites/default/files/mastodon.png) + +## Configuration + +#### Ajout d'un "swapfile" si vous avez moins de 2Go de RAM +``` +sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000 +sudo chmod 600 /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +``` +ajouter cette ligne dans /etc/fstab +``` +/swapfile none swap sw 0 0 +``` + +### Installation + +#### Utilisation de __screen__ en cas de déconnection +``` +$ sudo apt-get install screen +$ screen +$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git +``` +Récuperer l'installation après une deconnection: +``` +$ screen -d +$ screen -r +``` +L'utilisateur admin est crée automatiquement comme: user@domain.tld + +### Mise à jour +#### Utilisation de __screen__ fortement recommandé + +`$ 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. + +## Documentation + + * Documentation officielle: https://docs.joinmastodon.org/ + * Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. + +## Caractéristiques spécifiques YunoHost + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/mastodon%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/mastodon/) + +## Links + + * Signaler un bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues + * Site de l'application: Lien vers le site officiel de cette application + * Site web YunoHost: https://yunohost.org/ + +--- + +Informations pour les développeurs +---------------- + +**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +ou +sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +``` diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 4c68e9c..9d7227b 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.1.tar.gz -SOURCE_SUM=d0a9d6f4514f78fcdc76943ce2518ce5008378c65b5ecbb3644026dc97c18ec1 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.4.tar.gz +SOURCE_SUM=0e542c57228d482a068b05f639d8fe53dd9d413f7e7ce93cd1a088bd4d8d8366 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index b32b7b9..5df8367 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz -SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20190314.tar.gz +SOURCE_SUM=2cc0f9fdb232042e71edad93a5c3ae108bcd090ea0b6db4e5bb6325547e07968 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 3c06f54..db8924e 100644 --- a/manifest.json +++ b/manifest.json @@ -2,20 +2,20 @@ "name": "Mastodon", "id": "mastodon", "packaging_format": 1, - "requirements": { - "yunohost": ">= 2.7.1" - }, "description": { "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.6.5", + "version": "2.7.4", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { "name": "cyp, nemsia", "email": "cyp@rouquin.me, nemsia@nemsia.org" }, + "requirements": { + "yunohost": ">= 3.4" + }, "multi_instance": false, "services": [ "nginx" diff --git a/scripts/_common.sh b/scripts/_common.sh index 7def11e..4e04181 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,23 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="deb1 deb2" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] diff --git a/scripts/backup b/scripts/backup index eeee720..5e57cd7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -26,8 +26,8 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." -# Get multi-instances specific variables app=$YNH_APP_INSTANCE_NAME # Retrieve app settings @@ -47,18 +47,21 @@ yunohost service stop "$app-streaming" #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= +ynh_print_info "Backing up the PostgreSQL database..." ynh_psql_dump_db "$db_name" > db.sql ynh_backup "db.sql" @@ -68,6 +71,7 @@ ynh_backup "db.sql" #================================================= # BACKUP SYSTEMD #================================================= +ynh_print_info "Backing up systemd configuration..." ynh_backup "/etc/systemd/system/$app-web.service" ynh_backup "/etc/systemd/system/$app-sidekiq.service" @@ -97,3 +101,9 @@ sleep 30 #================================================= systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 3680b03..026737e 100644 --- a/scripts/install +++ b/scripts/install @@ -17,25 +17,26 @@ source _future.sh # Exit if an error occurs during the execution of the script ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================ +#================================================= domain=$YNH_APP_ARG_DOMAIN +path_url="/" admin_mastodon=$YNH_APP_ARG_ADMIN -admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') language=$YNH_APP_ARG_LANGUAGE + +admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') port_web=$(ynh_find_port 3000) port_stream=$(ynh_find_port 4000) -path_url="/" app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -51,6 +52,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app admin $admin_mastodon @@ -67,6 +69,7 @@ ynh_app_setting_set $app port_stream $port_stream #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Installing dependencies..." # TODO: add in a clean way backports and yarn @@ -103,9 +106,11 @@ ynh_install_app_dependencies \ `# Yarn ` \ yarn + #================================================= -# DATABASE SETUP +# CREATE A POSTGRESQL DATABASE #================================================= +ynh_print_info "Creating a PostgreSQL database..." # Create postgresql database db_name="${app}_production" @@ -120,6 +125,7 @@ ynh_psql_execute_as_root \ #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." # Creates the destination directory and stores its location. ynh_app_setting_set "$app" final_path "$final_path" @@ -132,6 +138,7 @@ ynh_setup_source "$final_path/live" "app-mastodon" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" @@ -141,12 +148,19 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password chown -R "$app": "$final_path" +#================================================= +# SPECIFIC SETUP +#================================================= +# ... +#================================================= + # TODO: try to use ynh_install_ruby from https://github.com/YunoHost-Apps/Experimental_helpers # Install de rbenv ( @@ -242,6 +256,7 @@ SETADMIN admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) (cd $final_path/live && rm -f acc.txt) + #================================================= # GENERIC FINALIZATION #================================================= @@ -268,6 +283,7 @@ sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." # TODO: all private install # Unprotected url @@ -276,6 +292,7 @@ ynh_app_setting_set "$app" unprotected_uris "/" #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." # Reload Nginx systemctl reload nginx @@ -291,3 +308,9 @@ The admin password is: $admin_pass If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" ynh_send_readme_to_admin "$message" "$admin_mastodon" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 6d6679b..13f9775 100644 --- a/scripts/remove +++ b/scripts/remove @@ -15,6 +15,7 @@ source _future.sh #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -25,17 +26,9 @@ final_path=$(ynh_app_setting_get "$app" final_path) #================================================= # STANDARD REMOVE -#================================================= -# STOP AND REMOVE SERVICE -#================================================= - -ynh_remove_systemd_config "$app-web" -ynh_remove_systemd_config "$app-sidekiq" -ynh_remove_systemd_config "$app-streaming" - #================================================= # REMOVE SERVICE FROM ADMIN PANEL -#============================================== +#================================================= if yunohost service status | grep -q "$app-web" then @@ -56,22 +49,36 @@ then fi #================================================= -# REMOVE DEPENDENCIES +# STOP AND REMOVE SERVICE #================================================= +ynh_print_info "Stopping and removing the systemd service" + +# Remove the dedicated systemd config +ynh_remove_systemd_config "$app-web" +ynh_remove_systemd_config "$app-sidekiq" +ynh_remove_systemd_config "$app-streaming" -# Remove metapackage and its dependencies -ynh_remove_app_dependencies -ynh_remove_nodejs #================================================= -# REMOVE THE PostgreSQL DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= +ynh_print_info "Removing the PostgreSQL database" # delete postgresql database & user ynh_psql_remove_db "$db_name" "$app" +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies +ynh_remove_nodejs + #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -79,11 +86,16 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" + +# Remove the dedicated nginx config ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE #================================================= +# REMOVE THE CRON FILE +#================================================= # Remove a cron file ynh_secure_remove "/etc/cron.d/$app" @@ -96,4 +108,13 @@ ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" + +# Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 822f8fc..1b9537c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,10 +26,10 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME -# Get old parameter of the app domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) @@ -38,6 +38,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -55,12 +56,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password @@ -76,6 +79,7 @@ chown -R $app: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_print_info "Reinstalling dependencies..." # TODO: add in a clean way backports and yarn @@ -113,10 +117,9 @@ ynh_install_app_dependencies \ yarn #================================================= -# RESTORE THE PostgreSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= - -# Restore PostgreSQL database +ynh_print_info "Restoring the PostgreSQL database..." db_name=$(ynh_app_setting_get "$app" db_name) db_pwd=$(ynh_app_setting_get "$app" db_pwd) @@ -132,6 +135,7 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= # RESTORE SYSTEMD #================================================= +ynh_print_info "Restoring the systemd configuration..." ynh_restore_file "/etc/systemd/system/$app-web.service" ynh_restore_file "/etc/systemd/system/$app-sidekiq.service" @@ -155,10 +159,17 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND services +# RELOAD NGINX AND SERVICES #================================================= +ynh_print_info "Reloading nginx web server and services..." systemctl restart "$app-web" "$app-sidekiq" "$app-streaming" # Waiting start all services sleep 30 systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 85fb1f4..d9e4cac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." # See comments in install script app=$YNH_APP_INSTANCE_NAME @@ -31,6 +32,7 @@ port_stream=$(ynh_app_setting_get "$app" port_stream) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -62,6 +64,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -85,9 +88,54 @@ fi echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list #================================================= -# INSTALL DEPENDENCIES +# STANDARD UPGRADE STEPS #================================================= + +# Stop Mastodon Services +# Restart Mastodon +yunohost service stop "$app-web" +yunohost service stop "$app-sidekiq" +yunohost service stop "$app-streaming" + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Upgrading source files..." + +# Download Mastodon +mv "$final_path/live" "$final_path/live_back" +ynh_setup_source "$final_path/live" "app-mastodon" +if [ -z $final_path/live_back/public/system ]; then + rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." +fi +rsync -a "$final_path/live_back/.env.production" "$final_path/live/." +rm -Rf "$final_path/live_back" + +# Clean files which are not needed anymore +ynh_secure_remove $final_path/live/config/initializers/timeout.rb + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Upgrading nginx web server configuration..." + +ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" +ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" +ynh_add_nginx_config + + +# Upgrade rbenv and ruby plugins +ynh_setup_source "$final_path/.rbenv" "app-rbenv" +ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" + +chown -R "$app": "$final_path" + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info "Upgrading dependencies..." + ynh_install_nodejs 8 # TODO: use the same mecanism with other files @@ -106,41 +154,18 @@ ynh_install_app_dependencies \ yarn #================================================= -# STANDARD UPGRADE STEPS +# CREATE DEDICATED USER #================================================= +ynh_print_info "Making sure dedicated system user exists..." - -# Stop Mastodon Services -# Restart Mastodon -yunohost service stop "$app-web" -yunohost service stop "$app-sidekiq" -yunohost service stop "$app-streaming" - -# Download Mastodon -mv "$final_path/live" "$final_path/live_back" -ynh_setup_source "$final_path/live" "app-mastodon" -if [ -z $final_path/live_back/public/system ]; then - rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." -fi -rsync -a "$final_path/live_back/.env.production" "$final_path/live/." -rm -Rf "$final_path/live_back" - -# Clean files which are not needed anymore -ynh_secure_remove $final_path/live/config/initializers/timeout.rb +# Create a dedicated user (if not existing) +ynh_system_user_create $app #================================================= -# NGINX CONFIGURATION +# SPECIFIC UPGRADE +#================================================= +# ... #================================================= -ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" -ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" -ynh_add_nginx_config - - -# Upgrade rbenv and ruby plugins -ynh_setup_source "$final_path/.rbenv" "app-rbenv" -ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" - -chown -R "$app": "$final_path" # Install ruby 2.6.0 ( @@ -193,6 +218,7 @@ chown -R "$app": "$final_path" #================================================= # SETUP SYSTEMD #================================================= +ynh_print_info "Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" @@ -225,19 +251,36 @@ ynh_replace_string "__USER__" "$app" ../conf/cron sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= -# RELOAD NGINX +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES #================================================= -systemctl reload nginx +# Set permissions on app files +#chown -R root: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." ynh_app_setting_set "$app" unprotected_uris "/" #================================================= -# RELOAD ssowatconf +# RELOAD SSOWATCONF #================================================= sudo yunohost app ssowatconf + +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 8bcf44150e7ea5a65efe536179895e95dc863217 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 Mar 2019 04:26:32 +0100 Subject: [PATCH 064/129] update readme --- README.md | 7 +++---- README_fr.md | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1e277dd..482ddbd 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to :warning: This application uses the Debian backports packages, do not install this application directly in production ## Overview +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. **Shipped version:** 2.7.4 @@ -27,15 +28,12 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ![](https://framalibre.org/sites/default/files/mastodon.png) - [Source code](https://github.com/tootsuite/mastodon) ## Configuration ## 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. - [Source code](https://github.com/tootsuite/mastodon) #### Adding "swapfile" If you have less than 2Go of RAM @@ -90,7 +88,8 @@ It seems important to close the inscriptions for your Mastodon, so that it remai ## Links * Report a bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues - * App website: Link to the official website of this app + * App website: https://joinmastodon.org/ + * Github App website: https://github.com/tootsuite/mastodon * YunoHost website: https://yunohost.org/ --- diff --git a/README_fr.md b/README_fr.md index 4f753ea..5fa9b89 100644 --- a/README_fr.md +++ b/README_fr.md @@ -71,7 +71,6 @@ Il semble important de fermer les inscriptions pour votre Mastodon, pour que à ## Documentation * Documentation officielle: https://docs.joinmastodon.org/ - * Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. ## Caractéristiques spécifiques YunoHost @@ -84,7 +83,8 @@ Il semble important de fermer les inscriptions pour votre Mastodon, pour que à ## Links * Signaler un bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues - * Site de l'application: Lien vers le site officiel de cette application + * Site de l'application: https://joinmastodon.org/ + * Site Github de l'application: https://github.com/tootsuite/mastodon * Site web YunoHost: https://yunohost.org/ --- From 0201b2ac101f557be279120898f0072fbc284e78 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 22:47:40 +0100 Subject: [PATCH 065/129] Update install --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index 026737e..5a9aece 100644 --- a/scripts/install +++ b/scripts/install @@ -14,6 +14,11 @@ source _future.sh # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From 149191b44940c2807eefdd5c7af4df2bf0f8884c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 23:05:37 +0100 Subject: [PATCH 066/129] Remove postgresql helper --- scripts/_common.sh | 157 --------------------------------------------- 1 file changed, 157 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 4e04181..8077956 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -32,164 +32,7 @@ exec_as() { fi } -#================================================= -# -# POSTGRES HELPERS -# -# Point of contact : Jean-Baptiste Holcroft -#================================================= -# Create a master password and set up global settings -# Please always call this script in install and restore scripts -# -# usage: ynh_psql_test_if_first_run - -ynh_psql_test_if_first_run() { - if [ -f /etc/yunohost/psql ]; - then - echo "PostgreSQL is already installed, no need to create master password" - else - pgsql=$(ynh_string_random) - pg_hba="" - echo "$pgsql" >> /etc/yunohost/psql - - if [ -e /etc/postgresql/9.4/ ] - then - pg_hba=/etc/postgresql/9.4/main/pg_hba.conf - elif [ -e /etc/postgresql/9.6/ ] - then - pg_hba=/etc/postgresql/9.6/main/pg_hba.conf - else - ynh_die "postgresql shoud be 9.4 or 9.6" - fi - - systemctl start postgresql - sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$pgsql'" postgres - - # force all user to connect to local database using passwords - # https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF - # Note: we can't use peer since YunoHost create users with nologin - # See: https://github.com/YunoHost/yunohost/blob/unstable/data/helpers.d/user - sed -i '/local\s*all\s*all\s*peer/i \ - local all all password' "$pg_hba" - systemctl enable postgresql - systemctl reload postgresql - fi -} - -# Open a connection as a user -# -# example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;" -# example: ynh_psql_connect_as 'user' 'pass' < /path/to/file.sql -# -# usage: ynh_psql_connect_as user pwd [db] -# | arg: user - the user name to connect as -# | arg: pwd - the user password -# | arg: db - the database to connect to -ynh_psql_connect_as() { - user="$1" - pwd="$2" - db="$3" - sudo --login --user=postgres PGUSER="$user" PGPASSWORD="$pwd" psql "$db" -} - -# # Execute a command as root user -# -# usage: ynh_psql_execute_as_root sql [db] -# | arg: sql - the SQL command to execute -# | arg: db - the database to connect to -ynh_psql_execute_as_root () { - sql="$1" - sudo --login --user=postgres psql <<< "$sql" -} - -# Execute a command from a file as root user -# -# usage: ynh_psql_execute_file_as_root file [db] -# | arg: file - the file containing SQL commands -# | arg: db - the database to connect to -ynh_psql_execute_file_as_root() { - file="$1" - db="$2" - sudo --login --user=postgres psql "$db" < "$file" -} - -# Create a database, an user and its password. Then store the password in the app's config -# -# After executing this helper, the password of the created database will be available in $db_pwd -# It will also be stored as "psqlpwd" into the app settings. -# -# usage: ynh_psql_setup_db user name [pwd] -# | arg: user - Owner of the database -# | arg: name - Name of the database -# | arg: pwd - Password of the database. If not given, a password will be generated -ynh_psql_setup_db () { - db_user="$1" - db_name="$2" - new_db_pwd=$(ynh_string_random) # Generate a random password - # If $3 is not given, use new_db_pwd instead for db_pwd. - db_pwd="${3:-$new_db_pwd}" - ynh_psql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database - ynh_app_setting_set "$app" psqlpwd "$db_pwd" # Store the password in the app's config -} - -# Create a database and grant privilegies to a user -# -# usage: ynh_psql_create_db db [user [pwd]] -# | arg: db - the database name to create -# | arg: user - the user to grant privilegies -# | arg: pwd - the user password -ynh_psql_create_db() { - db="$1" - user="$2" - pwd="$3" - ynh_psql_create_user "$user" "$pwd" - sudo --login --user=postgres createdb --owner="$user" "$db" -} - -# Drop a database -# -# usage: ynh_psql_drop_db db -# | arg: db - the database name to drop -# | arg: user - the user to drop -ynh_psql_remove_db() { - db="$1" - user="$2" - sudo --login --user=postgres dropdb "$db" - ynh_psql_drop_user "$user" -} - -# Dump a database -# -# example: ynh_psql_dump_db 'roundcube' > ./dump.sql -# -# usage: ynh_psql_dump_db db -# | arg: db - the database name to dump -# | ret: the psqldump output -ynh_psql_dump_db() { - db="$1" - sudo --login --user=postgres pg_dump "$db" -} - - -# Create a user -# -# usage: ynh_psql_create_user user pwd [host] -# | arg: user - the user name to create -ynh_psql_create_user() { - user="$1" - pwd="$2" - sudo --login --user=postgres psql -c"CREATE USER $user WITH PASSWORD '$pwd'" postgres -} - -# Drop a user -# -# usage: ynh_psql_drop_user user -# | arg: user - the user name to drop -ynh_psql_drop_user() { - user="$1" - sudo --login --user=postgres dropuser "$user" -} # Send an email to inform the administrator # From 2f3a368e811d520f64f02bdd33bc05bc5642012f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 23:11:01 +0100 Subject: [PATCH 067/129] move dependencies to _common.sh --- scripts/_common.sh | 2 +- scripts/install | 15 +-------------- scripts/restore | 14 +------------- scripts/upgrade | 14 +------------- 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8077956..7d1665e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="deb1 deb2" +pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot yarn libidn11-dev libicu-dev libjemalloc-dev" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 5a9aece..1df70e6 100644 --- a/scripts/install +++ b/scripts/install @@ -97,20 +97,7 @@ ynh_package_update ynh_install_nodejs 8 # TODO: use the same mecanism with other files -ynh_install_app_dependencies \ - `# debian packages ` \ - imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ - `# redis ` \ - redis-server redis-tools \ - `# postgresql ` \ - postgresql postgresql-contrib \ - `# Ruby ` \ - autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ - `# ffmpeg from backports ` \ - ffmpeg \ - `# Yarn ` \ - yarn - +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 1b9537c..7e68436 100644 --- a/scripts/restore +++ b/scripts/restore @@ -102,19 +102,7 @@ ynh_package_update ynh_install_nodejs 8 # TODO: use the same mecanism with other files -ynh_install_app_dependencies \ - `# debian packages ` \ - imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ - `# redis ` \ - redis-server redis-tools \ - `# postgresql ` \ - postgresql \ - `# Ruby ` \ - autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ - `# ffmpeg from backports ` \ - ffmpeg \ - `# Yarn ` \ - yarn +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE POSTGRESQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index d9e4cac..d71c7f1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,19 +139,7 @@ ynh_print_info "Upgrading dependencies..." ynh_install_nodejs 8 # TODO: use the same mecanism with other files -ynh_install_app_dependencies \ - `# debian packages ` \ - imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ - `# redis ` \ - redis-server redis-tools \ - `# postgresql ` \ - postgresql postgresql-contrib \ - `# Ruby ` \ - autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ - `# ffmpeg from backports ` \ - ffmpeg \ - `# Yarn ` \ - yarn +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER From 4a75d7c713e457b4b470a965e546944f9dfd899b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 23:16:12 +0100 Subject: [PATCH 068/129] remove _future.sh --- scripts/_future.sh | 127 --------------------------------------------- scripts/backup | 10 +--- scripts/install | 1 - scripts/remove | 2 - scripts/restore | 10 +--- 5 files changed, 4 insertions(+), 146 deletions(-) delete mode 100644 scripts/_future.sh diff --git a/scripts/_future.sh b/scripts/_future.sh deleted file mode 100644 index 82f255c..0000000 --- a/scripts/_future.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -# needed to have "service_name" as an option -# https://github.com/YunoHost/yunohost/commit/9c4ddcca39d9d6d92bd5f9a23978337e48d0a4e1 -ynh_add_systemd_config () { - local service_name="${1:-$app}" - - finalsystemdconf="/etc/systemd/system/$service_name.service" - ynh_backup_if_checksum_is_different "$finalsystemdconf" - sudo cp ../conf/${2:-systemd.service} "$finalsystemdconf" - - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__APP__" "$app" "$finalsystemdconf" - fi - ynh_store_file_checksum "$finalsystemdconf" - - sudo chown root: "$finalsystemdconf" - sudo systemctl enable $service_name - sudo systemctl daemon-reload -} - -# needed to have "service_name" as an option -# https://github.com/YunoHost/yunohost/commit/9c4ddcca39d9d6d92bd5f9a23978337e48d0a4e1 -ynh_remove_systemd_config () { - local service_name="${1:-$app}" - - local finalsystemdconf="/etc/systemd/system/$service_name.service" - if [ -e "$finalsystemdconf" ]; then - sudo systemctl stop $service_name - sudo systemctl disable $service_name - ynh_secure_remove "$finalsystemdconf" - sudo systemctl daemon-reload - fi -} - - -# LOCAL ADDITION: -# save file locally if not in the cache -# -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source () { - local dest_dir=$1 - local src_id=${2:-app} # If the argument is not given, source_id equals "app" - - # Load value from configuration file (see above for a small doc about this file - # format) - local src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - local src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-) - - # Default value - src_sumprg=${src_sumprg:-sha256sum} - src_in_subdir=${src_in_subdir:-true} - src_format=${src_format:-tar.gz} - src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]') - if [ "$src_filename" = "" ] ; then - src_filename="${src_id}.${src_format}" - fi - local local_src="/var/cache/yunohost/ynh_setup_source/${YNH_APP_ID}/${src_filename}" - - # if cache file exists and the checksum isn't good, download it again - # if not, just download the file - - if test -e "$local_src" - then - echo "${src_sum} ${local_src}" | ${src_sumprg} -c --status \ - || wget -nv -O $local_src $src_url - else - mkdir -p "/var/cache/yunohost/ynh_setup_source/${YNH_APP_ID}" - wget -nv -O $local_src $src_url - fi - cp $local_src $src_filename - - # Check the control sum - echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \ - || ynh_die "Corrupt source" - - # Extract source into the app dir - mkdir -p "$dest_dir" - if [ "$src_format" = "zip" ] - then - # Zip format - # Using of a temp directory, because unzip doesn't manage --strip-components - if $src_in_subdir ; then - local tmp_dir=$(mktemp -d) - unzip -quo $src_filename -d "$tmp_dir" - cp -a $tmp_dir/*/. "$dest_dir" - ynh_secure_remove "$tmp_dir" - else - unzip -quo $src_filename -d "$dest_dir" - fi - else - local strip="" - if $src_in_subdir ; then - strip="--strip-components 1" - fi - if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]] ; then - tar -xf $src_filename -C "$dest_dir" $strip - else - ynh_die "Archive format unrecognized." - fi - fi - - # Apply patches - if (( $(find $YNH_CWD/../sources/patches/ -type f -name "${src_id}-*.patch" 2> /dev/null | wc -l) > "0" )); then - local old_dir=$(pwd) - (cd "$dest_dir" \ - && for p in $YNH_CWD/../sources/patches/${src_id}-*.patch; do \ - patch -p1 < $p; done) \ - || ynh_die "Unable to apply patches" - cd $old_dir - fi - - # Add supplementary files - if test -e "$YNH_CWD/../sources/extra_files/${src_id}"; then - cp -a $YNH_CWD/../sources/extra_files/$src_id/. "$dest_dir" - fi -} - diff --git a/scripts/backup b/scripts/backup index 5e57cd7..dbff544 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,15 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - cp ../settings/scripts/_future.sh ./_future.sh - chmod a+rx _common.sh _future.sh -fi -source _common.sh +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -source _future.sh #================================================= # MANAGE SCRIPT FAILURE diff --git a/scripts/install b/scripts/install index 1df70e6..f234e78 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _future.sh #================================================= # MANAGE SCRIPT FAILURE diff --git a/scripts/remove b/scripts/remove index 13f9775..14bcf31 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,8 +9,6 @@ source _common.sh # Loads the generic functions usually used in the script # Source app helpers source /usr/share/yunohost/helpers -source _future.sh - #================================================= # LOAD SETTINGS diff --git a/scripts/restore b/scripts/restore index 7e68436..969f3ca 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,15 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - cp ../settings/scripts/_future.sh ./_future.sh - chmod a+rx _common.sh _future.sh -fi -source _common.sh +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -source _future.sh #================================================= # MANAGE SCRIPT FAILURE From 3eee0a24e2518c63f600986a8911265f9f66fcfc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 23:33:34 +0100 Subject: [PATCH 069/129] update install --- scripts/install | 48 ++++++-------- scripts/ynh_install_ruby | 140 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 28 deletions(-) create mode 100644 scripts/ynh_install_ruby diff --git a/scripts/install b/scripts/install index f234e78..819296b 100644 --- a/scripts/install +++ b/scripts/install @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +source ynh_install_ruby #================================================= # MANAGE SCRIPT FAILURE @@ -149,32 +150,14 @@ chown -R "$app": "$final_path" #================================================= # SPECIFIC SETUP #================================================= -# ... +# INSTALLING RUBY #================================================= -# TODO: try to use ynh_install_ruby from https://github.com/YunoHost-Apps/Experimental_helpers -# Install de rbenv -( - cd $final_path/.rbenv - src/configure && make -C src +ynh_install_ruby --ruby_version=2.6.0 - echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\" -eval \"\$(rbenv init -)\"" > $final_path/.profile - echo "export PATH=\"$final_path/.rbenv/bin:$final_path/live/bin:\$PATH\"" > $final_path/.bashrc -) - -# Install ruby-build -( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.6.0 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.6.0 || true - exec_as "$app" $final_path/.rbenv/versions/2.6.0/bin/ruby -v -) - -# Create symlink for ruby -rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.6.0/bin/ruby /usr/bin/ruby || true - -# Adjust Mastodon config +#================================================= +# MODIFY A CONFIG FILE +#================================================= cp -a $final_path/live/.env.production.sample $final_path/live/.env.production ynh_replace_string "REDIS_HOST=redis" "REDIS_HOST=127.0.0.1" "${final_path}/live/.env.production" @@ -202,16 +185,25 @@ ynh_replace_string "SMTP_FROM_ADDRESS=notifications@example.com" "SMTP_FROM_ADDR ynh_replace_string "#SMTP_AUTH_METHOD=plain" "SMTP_AUTH_METHOD=none" "${final_path}/live/.env.production" ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_VERIFY_MODE=none" "${final_path}/live/.env.production" -# Preconfig CSS & JS -# Install Mastodon -# Give right permission for the app +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "${final_path}/live/.env.production" + +#================================================= +# INSTALLING MASTODON +#================================================= +ynh_print_info "Installing Mastodon..." + chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <&2 + # Build an app.src for rbenv + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.1.tar.gz +SOURCE_SUM=41f1a60714c55eceb21d692a469aee1ec4f46bba351d0dfcb0c660ff9cf1a1c9" > "../conf/rbenv.src" + # Download and extract rbenv + ynh_setup_source "$rbenv_install_dir" rbenv + + # Build an app.src for ruby-build + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180329.tar.gz +SOURCE_SUM=4c8610c178ef2fa6bb29d4bcfca52608914632a51a56a5e70aeec8bf0894167b" > "../conf/ruby-build.src" + # Download and extract ruby-build + ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build + + (cd $rbenv_install_dir + ./src/configure && make -C src) + +# Create shims directory if needed +if [ ! -d $rbenv_install_dir/shims ] ; then + mkdir $rbenv_install_dir/shims +fi +} + +# Install a specific version of ruby +# +# ynh_install_ruby will install the version of ruby provided as argument by using rbenv. +# +# rbenv (ruby version management) stores the target ruby version in a .ruby_version file created in the target folder (using rbenv local ) +# It then uses that information for every ruby user that uses rbenv provided ruby command +# +# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv +# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin) +# +# Don't forget to execute ruby-dependent command in a login environment +# (e.g. sudo --login option) +# When not possible (e.g. in systemd service definition), please use direct path +# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle) +# +# usage: ynh_install_ruby ruby_version user +# | arg: -v, --ruby_version= - Version of ruby to install. +# If possible, prefer to use major version number (e.g. 8 instead of 8.10.0). +# The crontab will handle the update of minor versions when needed. +ynh_install_ruby () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [v]=ruby_version= ) + # Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions + local ruby_version + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + # Create $rbenv_install_dir + mkdir -p "$rbenv_install_dir/plugins/ruby-build" + + # Load rbenv path in PATH + CLEAR_PATH="$rbenv_install_dir/bin:$PATH" + + # Remove /usr/local/bin in PATH in case of ruby prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + + # Move an existing ruby binary, to avoid to block rbenv + test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv + + # If rbenv is not previously setup, install it + if ! type rbenv > /dev/null 2>&1 + then + ynh_install_rbenv + fi + + # Restore /usr/local/bin in PATH (if needed) + PATH=$CLEAR_PATH + + # And replace the old ruby binary + test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby + + # Install the requested version of ruby + CONFIGURE_OPTS="--disable-install-doc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version + + # Store the ID of this app and the version of ruby requested for it + echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version" + + # Store ruby_version into the config of this app + ynh_app_setting_set $app ruby_version $ruby_version + + # Set environment for ruby users + echo "#rbenv +export RBENV_ROOT=$rbenv_install_dir +export PATH=\"$rbenv_install_dir/bin:$PATH\" +eval \"\$(rbenv init -)\" +#rbenv" > /etc/profile.d/rbenv.sh + + # Load the right environment for the Installation + eval "$(rbenv init -)" + + (cd $final_path + rbenv local $ruby_version) +} + +# Remove the version of ruby used by the app. +# +# This helper will check if another app uses the same version of ruby, +# if not, this version of ruby will be removed. +# If no other app uses ruby, rbenv will be also removed. +# +# usage: ynh_remove_ruby +ynh_remove_ruby () { + ruby_version=$(ynh_app_setting_get $app ruby_version) + + # Remove the line for this app + sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version" + + # If no other app uses this version of ruby, remove it. + if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version" + then + $rbenv_install_dir/bin/rbenv uninstall --force $ruby_version + fi + + # Remove rbenv environment configuration + rm /etc/profile.d/rbenv.sh + + # If no other app uses rbenv, remove rbenv and dedicated group + if [ ! -s "$rbenv_install_dir/ynh_app_version" ] + then + ynh_secure_remove "$rbenv_install_dir" + fi +} From f3e9605dae3798ceafe42c513caf567ae8988b15 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 Mar 2019 23:54:41 +0100 Subject: [PATCH 070/129] Fix remove steps --- scripts/remove | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/remove b/scripts/remove index 14bcf31..19fd67f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,9 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh # Loads the generic functions usually used in the script -# Source app helpers +source _common.sh source /usr/share/yunohost/helpers +source ynh_install_ruby #================================================= # LOAD SETTINGS @@ -17,10 +17,9 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -db_name=$(ynh_app_setting_get "$app" db_name) -final_path=$(ynh_app_setting_get "$app" final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE @@ -28,21 +27,21 @@ final_path=$(ynh_app_setting_get "$app" final_path) # REMOVE SERVICE FROM ADMIN PANEL #================================================= -if yunohost service status | grep -q "$app-web" +if yunohost service status "$app-web" >/dev/null 2>&1 then - echo "Remove $app-web service" + ynh_print_info "Removing $app-web service" yunohost service remove "$app-web" fi -if yunohost service status | grep -q "$app-sidekiq" +if yunohost service status "$app-sidekiq" >/dev/null 2>&1 then - echo "Remove $app-sidekiq service" + ynh_print_info "Removing $app-sidekiq service" yunohost service remove "$app-sidekiq" fi -if yunohost service status | grep -q "$app-streaming" +if yunohost service status "$app-streaming" >/dev/null 2>&1 then - echo "Remove $app-streaming service" + ynh_print_info "Removing $app-streaming service" yunohost service remove "$app-streaming" fi @@ -62,7 +61,7 @@ ynh_remove_systemd_config "$app-streaming" ynh_print_info "Removing the PostgreSQL database" # delete postgresql database & user -ynh_psql_remove_db "$db_name" "$app" +ynh_psql_remove_db $db_name $db_name #================================================= # REMOVE DEPENDENCIES @@ -70,6 +69,7 @@ ynh_psql_remove_db "$db_name" "$app" ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies +ynh_remove_ruby ynh_remove_app_dependencies ynh_remove_nodejs From 268b3df87be6d55eef68e0ba93dc228c92f947e3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 00:01:42 +0100 Subject: [PATCH 071/129] remove nodejs dependency --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7d1665e..c8dd739 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot yarn libidn11-dev libicu-dev libjemalloc-dev" +pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot yarn libidn11-dev libicu-dev libjemalloc-dev" #================================================= # PERSONAL HELPERS From f3f4efec783c2eaa439508bcaa63e960bc21bdd3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 02:31:15 +0100 Subject: [PATCH 072/129] remove apt sources --- scripts/remove | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/remove b/scripts/remove index 19fd67f..4acf266 100644 --- a/scripts/remove +++ b/scripts/remove @@ -73,6 +73,14 @@ ynh_remove_ruby ynh_remove_app_dependencies ynh_remove_nodejs +#================================================= +# REMOVE APT SOURCES +#================================================= +ynh_print_info "Removing apt sources" + +ynh_secure_remove "/etc/apt/sources.list.d/jessie-backports.list" +ynh_secure_remove "/etc/apt/sources.list.d/yarn.list" + #================================================= # REMOVE APP MAIN DIR #================================================= From 157889c14388ca89cdfd190bd8479b3dd4a07b1e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 03:32:05 +0100 Subject: [PATCH 073/129] Update _common.sh --- scripts/_common.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c8dd739..d0c5b58 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,8 @@ #================================================= # dependencies used by the app -pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot yarn libidn11-dev libicu-dev libjemalloc-dev" +#pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot yarn libidn11-dev libicu-dev libjemalloc-dev" +pkg_dependencies="imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev redis-server redis-tools postgresql autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev ffmpeg yarn" #================================================= # PERSONAL HELPERS From 2c7bff77eb0ae2af35009a183e1816513e25f34e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 03:40:57 +0100 Subject: [PATCH 074/129] Update ynh_install_ruby --- scripts/ynh_install_ruby | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ynh_install_ruby b/scripts/ynh_install_ruby index becc6f3..9e53c06 100644 --- a/scripts/ynh_install_ruby +++ b/scripts/ynh_install_ruby @@ -22,8 +22,8 @@ SOURCE_SUM=41f1a60714c55eceb21d692a469aee1ec4f46bba351d0dfcb0c660ff9cf1a1c9" > " # Build an app.src for ruby-build mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180329.tar.gz -SOURCE_SUM=4c8610c178ef2fa6bb29d4bcfca52608914632a51a56a5e70aeec8bf0894167b" > "../conf/ruby-build.src" + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20190314.tar.gz +SOURCE_SUM=2cc0f9fdb232042e71edad93a5c3ae108bcd090ea0b6db4e5bb6325547e07968" > "../conf/ruby-build.src" # Download and extract ruby-build ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build From 9d3b44450b36a14aa37ea9046f4a77574c3fdb15 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 03:44:43 +0100 Subject: [PATCH 075/129] Update remove --- scripts/remove | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/remove b/scripts/remove index 4acf266..af11b31 100644 --- a/scripts/remove +++ b/scripts/remove @@ -60,6 +60,9 @@ ynh_remove_systemd_config "$app-streaming" #================================================= ynh_print_info "Removing the PostgreSQL database" +ynh_psql_execute_as_root "\connect $db_name +SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" + # delete postgresql database & user ynh_psql_remove_db $db_name $db_name From 7915cc889f7fcb991693ccfdb558b27404bfa16a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 03:55:14 +0100 Subject: [PATCH 076/129] fix db_user --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index af11b31..f0715d4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -64,7 +64,7 @@ ynh_psql_execute_as_root "\connect $db_name SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" # delete postgresql database & user -ynh_psql_remove_db $db_name $db_name +ynh_psql_remove_db "$db_name" "$app" #================================================= # REMOVE DEPENDENCIES From 5885b4cf7d8fcbd5d9019243235e9097c3fcac6b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 04:06:44 +0100 Subject: [PATCH 077/129] Fix ruby --- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-web.service | 2 +- scripts/install | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index c799356..59f636f 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="DB_POOL=20" - ExecStart=__FINALPATH__/.rbenv/versions/2.6.0/bin/bundle exec sidekiq -c 20 -q default -q mailers -q pull -q push + ExecStart=/opt/rbenv/versions/2.6.0/bin/bundle exec sidekiq -c 20 -q default -q mailers -q pull -q push TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index dd6f6d7..32af850 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" - ExecStart=__FINALPATH__/.rbenv/versions/2.6.0/bin/bundle exec puma -C config/puma.rb + ExecStart=/opt/rbenv/versions/2.6.0/bin/bundle exec puma -C config/puma.rb TimeoutSec=15 Restart=always StandardError=syslog diff --git a/scripts/install b/scripts/install index 819296b..abded5b 100644 --- a/scripts/install +++ b/scripts/install @@ -202,15 +202,15 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <> .env.production - RAILS_ENV=production $final_path/.rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet - RAILS_ENV=production $final_path/.rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet + RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet + RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet INSTALL ) From d903267166295dae52a0165107da0bc64411e651 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 04:28:13 +0100 Subject: [PATCH 078/129] add env PATH=$PATH --- scripts/install | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index abded5b..e8e8b18 100644 --- a/scripts/install +++ b/scripts/install @@ -202,15 +202,16 @@ chown -R "$app": "$final_path" ( cd "$final_path/live" su mastodon <> .env.production - RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet - RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet + env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet + env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet INSTALL ) From f8096d8c256c021d290701b41767b77fdecef1c1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 20 Mar 2019 12:14:29 +0100 Subject: [PATCH 079/129] Update install --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index e8e8b18..4252c5a 100644 --- a/scripts/install +++ b/scripts/install @@ -232,9 +232,9 @@ systemctl start "$app-web.service" "$app-sidekiq.service" "$app-streaming.servic ( cd "$final_path/live" su mastodon < acc.txt ) -RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm -RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin +( env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create '$admin_mastodon' --email='$admin_mastodon_mail' > acc.txt ) +env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm +env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin SETADMIN ) admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) From 1d2c258abe21e48a32da63c8a90573c95a6bd773 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 02:07:49 +0100 Subject: [PATCH 080/129] Apply example_ynh --- manifest.json | 11 +-- scripts/backup | 28 +++---- scripts/change_url | 135 +++++++++++++++++++++++++++++++++ scripts/install | 89 +++++++++++++--------- scripts/remove | 4 +- scripts/restore | 10 +-- scripts/upgrade | 181 ++++++++++++++++++++------------------------- 7 files changed, 288 insertions(+), 170 deletions(-) create mode 100644 scripts/change_url diff --git a/manifest.json b/manifest.json index db8924e..1be7df5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.7.4", + "version": "2.7.4~ynh1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { @@ -29,19 +29,20 @@ "en": "Choose a domain for Mastodon", "fr": "Choisissez un domaine pour Mastodon" }, - "example": "domain.org" + "example": "example.com" }, { "name": "admin", "type": "user", "ask": { - "en": "Choose the Mastodon administrator (must be an existing YunoHost user)", - "fr": "Choisissez un administrateur Mastodon (doit être un utilisateur YunoHost)" + "en": "Choose an admin user", + "fr": "Choisissez l'administrateur" }, - "example": "john" + "example": "johndoe" }, { "name": "language", + "type": "string", "ask": { "en": "Choose the application language", "fr": "Choisissez la langue de l'application" diff --git a/scripts/backup b/scripts/backup index dbff544..c5a4702 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,13 +24,15 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -final_path=$(ynh_app_setting_get "$app" final_path) -db_name=$(ynh_app_setting_get "$app" db_name) +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# STOP MASTODON SERVICES +#================================================= +ynh_print_info "Stopping Mastodon Services..." -# Stop Mastodon Services -# Restart Mastodon yunohost service stop "$app-web" yunohost service stop "$app-sidekiq" yunohost service stop "$app-streaming" @@ -58,7 +60,6 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_print_info "Backing up the PostgreSQL database..." ynh_psql_dump_db "$db_name" > db.sql -ynh_backup "db.sql" #================================================= # SPECIFIC BACKUP @@ -72,16 +73,15 @@ ynh_backup "/etc/systemd/system/$app-sidekiq.service" ynh_backup "/etc/systemd/system/$app-streaming.service" #================================================= -# BACKUP THE CRON FILE +# BACKUP A CRON FILE #================================================= ynh_backup "/etc/cron.d/$app" #================================================= -# BACKUP THE sources.list FILES +# START MASTODON SERVICES #================================================= - -ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list" +ynh_print_info "Starting Mastodon Services..." yunohost service start "$app-web" yunohost service start "$app-sidekiq" @@ -90,12 +90,6 @@ yunohost service start "$app-streaming" # Waiting start all services sleep 30 -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..96292a4 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,135 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path="/" + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get $app final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get "$app" db_name) +#db_pwd=$(ynh_app_setting_get $app db_pwd) +admin_mastodon=$(ynh_app_setting_get $app admin) + +#================================================= +# CHECK THE SYNTAX OF THE PATHS +#================================================= + +test -n "$old_path" || old_path="/" +test -n "$new_path" || new_path="/" +new_path=$(ynh_normalize_url_path $new_path) +old_path=$(ynh_normalize_url_path $old_path) + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_print_info "Updating nginx web server configuration..." + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different "$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum "$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# STOP MASTODON SERVICES +#================================================= +ynh_print_info "Stopping Mastodon services..." + +yunohost service stop "$app-web" +yunohost service stop "$app-sidekiq" +yunohost service stop "$app-streaming" + +#================================================= +# CHANGE CONFIGURATION +#================================================= + +ynh_replace_string "LOCAL_DOMAIN=*" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_FROM_ADDRESS=*" "SMTP_FROM_ADDRESS=$admin_mastodon@$domain" "${final_path}/live/.env.production" + +#================================================= +# START MASTODON SERVICES +#================================================= +ynh_print_info "Starting Mastodon services..." + +yunohost service start "$app-web" +yunohost service start "$app-sidekiq" +yunohost service start "$app-streaming" + +sleep 30 + +#================================================= +# GENERIC FINALISATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 4252c5a..b635ccc 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,6 @@ source ynh_install_ruby ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." true } # Exit if an error occurs during the execution of the script @@ -29,6 +28,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" admin_mastodon=$YNH_APP_ARG_ADMIN +is_public=true language=$YNH_APP_ARG_LANGUAGE admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') @@ -43,6 +43,8 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_print_info "Validating installation parameters..." +### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". +### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -60,12 +62,13 @@ ynh_webpath_register $app $domain $path_url ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin_mastodon +ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app language $language ynh_app_setting_set $app port_web $port_web ynh_app_setting_set $app port_stream $port_stream - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -143,9 +146,7 @@ ynh_add_nginx_config ynh_print_info "Configuring system user..." # Create a system user -adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password - -chown -R "$app": "$final_path" +ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP @@ -185,13 +186,6 @@ ynh_replace_string "SMTP_FROM_ADDRESS=notifications@example.com" "SMTP_FROM_ADDR ynh_replace_string "#SMTP_AUTH_METHOD=plain" "SMTP_AUTH_METHOD=none" "${final_path}/live/.env.production" ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_VERIFY_MODE=none" "${final_path}/live/.env.production" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "${final_path}/live/.env.production" - #================================================= # INSTALLING MASTODON #================================================= @@ -199,8 +193,7 @@ ynh_print_info "Installing Mastodon..." chown -R "$app": "$final_path" -( - cd "$final_path/live" +pushd "$final_path/live" su mastodon < acc.txt + env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm + env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin +SETADMIN +popd + +admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) +ynh_secure_remove "$final_path/live/acc.txt" + +#================================================= +# SETUP CRON JOB FOR REMOVING CACHE +#================================================= +ynh_print_info "Setuping a cron job for remiving cache..." + +ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron +ynh_replace_string "__USER__" "$app" ../conf/cron +sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD #================================================= +ynh_print_info "Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" @@ -228,18 +248,12 @@ ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" systemctl start "$app-web.service" "$app-sidekiq.service" "$app-streaming.service" -# Create user -( - cd "$final_path/live" - su mastodon < acc.txt ) -env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm -env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin -SETADMIN -) -admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= -(cd $final_path/live && rm -f acc.txt) +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "${final_path}/live/.env.production" #================================================= # GENERIC FINALIZATION @@ -247,7 +261,11 @@ admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) # SECURE FILES AND DIRECTORIES #================================================= -# TODO:Set permissions to app files +### For security reason, any app should set the permissions to root: before anything else. +### Then, if write authorization is needed, any access should be given only to directories +### that really need such authorization. + +# Set permissions to app files chown -R "$app": "$final_path" #================================================= @@ -259,26 +277,23 @@ yunohost service add "$app-web" yunohost service add "$app-sidekiq" yunohost service add "$app-streaming" -# SETUP CRON JOB FOR REMOVING CACHE -ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron -ynh_replace_string "__USER__" "$app" ../conf/cron -sudo cp -f ../conf/cron /etc/cron.d/$app - #================================================= # SETUP SSOWAT #================================================= ynh_print_info "Configuring SSOwat..." -# TODO: all private install -# Unprotected url -ynh_app_setting_set "$app" unprotected_uris "/" +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" +fi #================================================= # RELOAD NGINX #================================================= ynh_print_info "Reloading nginx web server..." -# Reload Nginx systemctl reload nginx #================================================= @@ -287,7 +302,7 @@ systemctl reload nginx message="Mastodon was successfully installed :) Please open 'https://$domain$path_url' -The admin username is: $admin_mastodon_mail +The admin email is: $admin_mastodon_mail The admin password is: $admin_pass If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" diff --git a/scripts/remove b/scripts/remove index f0715d4..8880c9c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,6 +27,7 @@ final_path=$(ynh_app_setting_get $app final_path) # REMOVE SERVICE FROM ADMIN PANEL #================================================= +# Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app-web" >/dev/null 2>&1 then ynh_print_info "Removing $app-web service" @@ -109,9 +110,6 @@ ynh_remove_nginx_config # Remove a cron file ynh_secure_remove "/etc/cron.d/$app" -# Delete ruby exec -#ynh_secure_remove /usr/bin/ruby - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 969f3ca..398648f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,8 +26,8 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get "$app" final_path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -59,7 +59,8 @@ ynh_restore_file "$final_path" #================================================= ynh_print_info "Recreating the dedicated system user..." -adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password +# Create the dedicated user (if not existing) +ynh_system_user_create $app $final_path #================================================= # RESTORE USER RIGHTS @@ -103,7 +104,6 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_print_info "Restoring the PostgreSQL database..." -db_name=$(ynh_app_setting_get "$app" db_name) db_pwd=$(ynh_app_setting_get "$app" db_pwd) ynh_psql_test_if_first_run @@ -112,8 +112,6 @@ ynh_psql_execute_as_root \ "CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" ynh_psql_execute_file_as_root ./db.sql "$db_name" - - #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d71c7f1..4c016e4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,24 +8,24 @@ source _common.sh source /usr/share/yunohost/helpers +source ynh_install_ruby #================================================= # LOAD SETTINGS #================================================= ynh_print_info "Loading installation settings..." -# See comments in install script app=$YNH_APP_INSTANCE_NAME -db_name=$(ynh_app_setting_get "$app" db_name) -db_pwd=$(ynh_app_setting_get "$app" db_pwd) -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) -admin=$(ynh_app_setting_get "$app" admin) -language=$(ynh_app_setting_get "$app" language) -final_path=$(ynh_app_setting_get "$app" final_path) -path_url="/" +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +admin=$(ynh_app_setting_get $app admin) +is_public=$(ynh_app_setting_get $app is_public) +final_path=$(ynh_app_setting_get $app final_path) +language=$(ynh_app_setting_get $app language) +db_name=$(ynh_app_setting_get $app db_name) + +db_pwd=$(ynh_app_setting_get $app db_pwd) port_web=$(ynh_app_setting_get "$app" port_web) port_stream=$(ynh_app_setting_get "$app" port_stream) @@ -35,15 +35,15 @@ port_stream=$(ynh_app_setting_get "$app" port_stream) ynh_print_info "Ensuring downward compatibility..." # If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set "$app" db_name "$db_name" +if [ -z $db_name ]; then + db_name=$(ynh_sanitize_dbid $app) + ynh_app_setting_set $app db_name $db_name fi # If final_path doesn't exist, create it -if [ -z "$final_path" ]; then +if [ -z $final_path ]; then final_path=/var/www/$app - ynh_app_setting_set "$app" final_path "$final_path" + ynh_app_setting_set $app final_path $final_path fi # Check if admin is not null @@ -76,24 +76,19 @@ ynh_clean_setup () { ynh_abort_if_errors #================================================= -# Remove repo Files +# CHECK THE PATH #================================================= -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list - ynh_secure_remove /etc/apt/sources.list.d/backports.list -fi - -# Add yarn repo -echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) #================================================= # STANDARD UPGRADE STEPS #================================================= +# STOP MASTODON SERVICES +#================================================= +ynh_print_info "Stopping Mastodon services..." - -# Stop Mastodon Services -# Restart Mastodon yunohost service stop "$app-web" yunohost service stop "$app-sidekiq" yunohost service stop "$app-streaming" @@ -115,6 +110,10 @@ rm -Rf "$final_path/live_back" # Clean files which are not needed anymore ynh_secure_remove $final_path/live/config/initializers/timeout.rb +# Upgrade rbenv and ruby plugins +ynh_setup_source "$final_path/.rbenv" "app-rbenv" +ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" + #================================================= # NGINX CONFIGURATION #================================================= @@ -124,18 +123,20 @@ ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config - -# Upgrade rbenv and ruby plugins -ynh_setup_source "$final_path/.rbenv" "app-rbenv" -ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" - -chown -R "$app": "$final_path" - #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_print_info "Upgrading dependencies..." +# Install source.list debian package backports & yarn +if [ "$(lsb_release --codename --short)" == "jessie" ]; then + echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list +fi +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_package_update + +# install nodejs ynh_install_nodejs 8 # TODO: use the same mecanism with other files @@ -152,57 +153,50 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# INSTALLING RUBY #================================================= -# Install ruby 2.6.0 -( - exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.6.0 || true - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.6.0 || true - exec_as "$app" $final_path/.rbenv/versions/2.6.0/bin/ruby -v -) +ynh_install_ruby --ruby_version=2.6.0 -# Create symlink for ruby -rm /usr/bin/ruby || true -ln -s $final_path/.rbenv/versions/2.6.0/bin/ruby /usr/bin/ruby || true +#================================================= +# UPGRADE MASTODON +#================================================= +ynh_print_info "Upgrading Mastodon..." -# Preconfig CSS & JS -# Install Mastodon -( -sudo su - $app < Date: Thu, 21 Mar 2019 02:15:20 +0100 Subject: [PATCH 081/129] Update check_process --- check_process | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/check_process b/check_process index 8a7f1c6..97f5caf 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,6 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - path="/path" (PATH) admin="john" (USER) language="fr_FR" ; Checks @@ -15,13 +14,9 @@ upgrade=1 backup_restore=1 multi_instance=0 - wrong_user=0 - wrong_path=0 incorrect_path=0 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=0 ;;; Levels Level 1=auto Level 2=auto From 2c8861a994de2cd200feabac8daf4a59ff43bea9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 02:31:06 +0100 Subject: [PATCH 082/129] Fix install and upgrade steps --- scripts/install | 64 +++++++++++++++++++++++++++---------------------- scripts/upgrade | 33 ++++++++++--------------- 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/scripts/install b/scripts/install index b635ccc..a4ef780 100644 --- a/scripts/install +++ b/scripts/install @@ -16,6 +16,7 @@ source ynh_install_ruby ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." true } # Exit if an error occurs during the execution of the script @@ -99,6 +100,9 @@ ynh_package_update # install nodejs ynh_install_nodejs 8 +# install ruby +ynh_install_ruby --ruby_version=2.6.0 + # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies @@ -122,12 +126,13 @@ ynh_psql_execute_as_root \ #================================================= ynh_print_info "Setting up source files..." -# Creates the destination directory and stores its location. -ynh_app_setting_set "$app" final_path "$final_path" -# Download all sources rbenv, ruby and mastodon +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path/.rbenv" "app-rbenv" -ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" ynh_setup_source "$final_path/live" "app-mastodon" #================================================= @@ -135,6 +140,8 @@ ynh_setup_source "$final_path/live" "app-mastodon" #================================================= ynh_print_info "Configuring nginx web server..." +### `ynh_add_nginx_config` will use the file conf/nginx.conf + # Create a dedicated nginx config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" @@ -150,12 +157,6 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP -#================================================= -# INSTALLING RUBY -#================================================= - -ynh_install_ruby --ruby_version=2.6.0 - #================================================= # MODIFY A CONFIG FILE #================================================= @@ -194,18 +195,14 @@ ynh_print_info "Installing Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - su mastodon <> .env.production - env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet - env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet -INSTALL + ynh_use_nodejs + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile + sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet + sudo -u "$app" env PATH=$PTH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet popd #================================================= @@ -215,14 +212,12 @@ ynh_print_info "Creating Mastodon Admin User..." # Create user pushd "$final_path/live" - su mastodon < acc.txt - env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm - env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin -SETADMIN + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create '$admin_mastodon' --email='$admin_mastodon_mail' > acc.txt + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin popd -admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) +admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) ynh_secure_remove "$final_path/live/acc.txt" #================================================= @@ -239,6 +234,17 @@ sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= ynh_print_info "Configuring a systemd service..." +### `ynh_systemd_config` is used to configure a systemd script for an app. +### It can be used for apps that use sysvinit (with adaptation) or systemd. +### Have a look at the app to be sure this app needs a systemd script. +### `ynh_systemd_config` will use the file conf/systemd.service +### If you're not using these lines: +### - You can remove those files in conf/. +### - Remove the section "BACKUP SYSTEMD" in the backup script +### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script +### - As well as the section "RESTORE SYSTEMD" in the restore script +### - And the section "SETUP SYSTEMD" in the upgrade script + # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" diff --git a/scripts/upgrade b/scripts/upgrade index 4c016e4..38b48ce 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,10 +110,6 @@ rm -Rf "$final_path/live_back" # Clean files which are not needed anymore ynh_secure_remove $final_path/live/config/initializers/timeout.rb -# Upgrade rbenv and ruby plugins -ynh_setup_source "$final_path/.rbenv" "app-rbenv" -ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" - #================================================= # NGINX CONFIGURATION #================================================= @@ -139,6 +135,9 @@ ynh_package_update # install nodejs ynh_install_nodejs 8 +# install ruby +ynh_install_ruby --ruby_version=2.6.0 + # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies @@ -152,12 +151,6 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE -#================================================= -# INSTALLING RUBY -#================================================= - -ynh_install_ruby --ruby_version=2.6.0 - #================================================= # UPGRADE MASTODON #================================================= @@ -166,20 +159,18 @@ ynh_print_info "Upgrading Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - su mastodon < Date: Thu, 21 Mar 2019 02:38:51 +0100 Subject: [PATCH 083/129] Fix dependencies steps --- conf/cron | 2 +- scripts/install | 6 +++--- scripts/upgrade | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/cron b/conf/cron index 2b80d85..2c319fa 100644 --- a/conf/cron +++ b/conf/cron @@ -1,2 +1,2 @@ RAILS_ENV=production -@daily cd __FINAL__PATH__/live && __FINAL__PATH__/.rbenv/shims/bundle exec rake __USER__:media:remove_remote +@daily cd __FINAL__PATH__/live && /opt/rbenv/versions/2.6.0/bin/bundle exec rake __USER__:media:remove_remote diff --git a/scripts/install b/scripts/install index a4ef780..05f1bd3 100644 --- a/scripts/install +++ b/scripts/install @@ -100,12 +100,12 @@ ynh_package_update # install nodejs ynh_install_nodejs 8 -# install ruby -ynh_install_ruby --ruby_version=2.6.0 - # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies +# install ruby +ynh_install_ruby --ruby_version=2.6.0 + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 38b48ce..8f98166 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -135,12 +135,12 @@ ynh_package_update # install nodejs ynh_install_nodejs 8 -# install ruby -ynh_install_ruby --ruby_version=2.6.0 - # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies +# install ruby +ynh_install_ruby --ruby_version=2.6.0 + #================================================= # CREATE DEDICATED USER #================================================= From 9a80610241c32ce3695381545d155b99f2c84b1d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 02:50:01 +0100 Subject: [PATCH 084/129] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 05f1bd3..daa545b 100644 --- a/scripts/install +++ b/scripts/install @@ -132,8 +132,8 @@ ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src - -ynh_setup_source "$final_path/live" "app-mastodon" +mkdir $final_path +ynh_setup_source "$final_path/live" "app-mastodon" #================================================= # NGINX CONFIGURATION From 4e59d8298f7e916dfd3d5a9592e840a3fcc4db34 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 02:58:33 +0100 Subject: [PATCH 085/129] Fix install and upgrade steps --- scripts/install | 9 ++++++--- scripts/upgrade | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index daa545b..ed48f01 100644 --- a/scripts/install +++ b/scripts/install @@ -103,9 +103,6 @@ ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies -# install ruby -ynh_install_ruby --ruby_version=2.6.0 - #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -157,6 +154,12 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP +#================================================= +# INSTALLING RUBY +#================================================= + +ynh_install_ruby --ruby_version=2.6.0 + #================================================= # MODIFY A CONFIG FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8f98166..859b0fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -138,9 +138,6 @@ ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies -# install ruby -ynh_install_ruby --ruby_version=2.6.0 - #================================================= # CREATE DEDICATED USER #================================================= @@ -151,6 +148,12 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE +#================================================= +# INSTALLING RUBY +#================================================= + +ynh_install_ruby --ruby_version=2.6.0 + #================================================= # UPGRADE MASTODON #================================================= From 27e8bed40d70c4f4a7f438b680c2cdc692cfeca6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 03:08:09 +0100 Subject: [PATCH 086/129] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index ed48f01..beda892 100644 --- a/scripts/install +++ b/scripts/install @@ -199,7 +199,7 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system + #sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile From 3cea0bdc57d60c7f20320394f272b5fd41fd2a1e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 03:26:05 +0100 Subject: [PATCH 087/129] fix install --- scripts/install | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index beda892..bac4c95 100644 --- a/scripts/install +++ b/scripts/install @@ -155,11 +155,14 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP #================================================= -# INSTALLING RUBY +# INSTALLING RUBY AND BUNDLER #================================================= ynh_install_ruby --ruby_version=2.6.0 +/opt/rbenv/versions/2.6.0/bin/gem update --system +/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -199,8 +202,6 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - #sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production From 737de6a78a3835be406824902604d4c736a34142 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 03:43:47 +0100 Subject: [PATCH 088/129] Fix install steps --- scripts/install | 4 ++-- scripts/upgrade | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index bac4c95..0b6402f 100644 --- a/scripts/install +++ b/scripts/install @@ -160,8 +160,8 @@ ynh_system_user_create $app $final_path ynh_install_ruby --ruby_version=2.6.0 -/opt/rbenv/versions/2.6.0/bin/gem update --system -/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document +#/opt/rbenv/versions/2.6.0/bin/gem update --system +#/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index 859b0fb..ecfdd12 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -149,10 +149,12 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE #================================================= -# INSTALLING RUBY +# INSTALLING RUBY AND BUNDLER #================================================= ynh_install_ruby --ruby_version=2.6.0 +/opt/rbenv/versions/2.6.0/bin/gem update --system +/opt/rbenv/versions/2.6.0/bin/gem install bundler #================================================= # UPGRADE MASTODON @@ -163,8 +165,6 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler if [ "$(lsb_release --codename --short)" == "jessie" ]; then sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --without development test else From 514a09f21e4acbbc3125319d8a8ab795b51b5f84 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 03:52:37 +0100 Subject: [PATCH 089/129] Fix install --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 0b6402f..04e50a2 100644 --- a/scripts/install +++ b/scripts/install @@ -160,7 +160,7 @@ ynh_system_user_create $app $final_path ynh_install_ruby --ruby_version=2.6.0 -#/opt/rbenv/versions/2.6.0/bin/gem update --system +/opt/rbenv/versions/2.6.0/bin/gem update --system #/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ecfdd12..87b0432 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -154,7 +154,7 @@ ynh_system_user_create $app ynh_install_ruby --ruby_version=2.6.0 /opt/rbenv/versions/2.6.0/bin/gem update --system -/opt/rbenv/versions/2.6.0/bin/gem install bundler +#/opt/rbenv/versions/2.6.0/bin/gem install bundler #================================================= # UPGRADE MASTODON From 9d671c8fc123d336165236f0c966fd88192cfe8e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 04:13:43 +0100 Subject: [PATCH 090/129] Fix error in install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 04e50a2..4580915 100644 --- a/scripts/install +++ b/scripts/install @@ -206,7 +206,7 @@ pushd "$final_path/live" sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet - sudo -u "$app" env PATH=$PTH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet popd #================================================= From 4325834c7af35fc15d65e00e5ca6033ab94452dc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 04:30:44 +0100 Subject: [PATCH 091/129] provide a .env.production file --- conf/.env.production.sample | 232 ++++++++++++++++++++++++++++++++++++ scripts/install | 27 ++--- 2 files changed, 242 insertions(+), 17 deletions(-) create mode 100644 conf/.env.production.sample diff --git a/conf/.env.production.sample b/conf/.env.production.sample new file mode 100644 index 0000000..ee65015 --- /dev/null +++ b/conf/.env.production.sample @@ -0,0 +1,232 @@ +# Service dependencies +# You may set REDIS_URL instead for more advanced options +# You may also set REDIS_NAMESPACE to share Redis between multiple Mastodon servers +REDIS_HOST=localhost +REDIS_PORT=6379 +# You may set DATABASE_URL instead for more advanced options +DB_HOST=localhost +DB_USER=__DB_USER__ +DB_NAME=__DB_NAME__ +DB_PASS=__DB_PWD__ +DB_PORT=5432 +# Optional ElasticSearch configuration +# ES_ENABLED=true +# ES_HOST=es +# ES_PORT=9200 + +# Federation +# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation. +# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com. +LOCAL_DOMAIN=__DOMAIN__ + +# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links) + +# Use this only if you need to run mastodon on a different domain than the one used for federation. +# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md +# DO *NOT* USE THIS UNLESS YOU KNOW *EXACTLY* WHAT YOU ARE DOING. +# WEB_DOMAIN=mastodon.example.com + +# Use this if you want to have several aliases handler@example1.com +# handler@example2.com etc. for the same user. LOCAL_DOMAIN should not +# be added. Comma separated values +# ALTERNATE_DOMAINS=example1.com,example2.com + +# Application secrets +# Generate each with the `RAILS_ENV=production bundle exec rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose) +SECRET_KEY_BASE=__SECRET_KEY_BASE__ +OTP_SECRET=__OTP_SECRET__ + +# VAPID keys (used for push notifications +# You can generate the keys using the following command (first is the private key, second is the public one) +# You should only generate this once per instance. If you later decide to change it, all push subscription will +# be invalidated, requiring the users to access the website again to resubscribe. +# +# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) +# +# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html +VAPID_PRIVATE_KEY= +VAPID_PUBLIC_KEY= + +# Registrations +# Single user mode will disable registrations and redirect frontpage to the first profile +# SINGLE_USER_MODE=true +# Prevent registrations with following e-mail domains +# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc +# Only allow registrations with the following e-mail domains +# EMAIL_DOMAIN_WHITELIST=example1.com|example2.de|etc + +# Optionally change default language +DEFAULT_LOCALE=__LANGUAGE__ + +# E-mail configuration +# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers +# If you want to use an SMTP server without authentication (e.g local Postfix relay) +# then set SMTP_AUTH_METHOD and SMTP_OPENSSL_VERIFY_MODE to 'none' and +# *comment* SMTP_LOGIN and SMTP_PASSWORD (leaving them blank is not enough). +SMTP_SERVER=localhost +SMTP_PORT=25 +#SMTP_LOGIN= +#SMTP_PASSWORD= +SMTP_FROM_ADDRESS=__SMTP_FROM_ADDRESS__ +#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN +#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail +SMTP_AUTH_METHOD=none +#SMTP_CA_FILE=/etc/ssl/certs/ca-certificates.crt +SMTP_OPENSSL_VERIFY_MODE=none +#SMTP_ENABLE_STARTTLS_AUTO=true +#SMTP_TLS=true + +# Optional user upload path and URL (images, avatars). Default is :rails_root/public/system. If you set this variable, you are responsible for making your HTTP server (eg. nginx) serve these files. +# PAPERCLIP_ROOT_PATH=/var/lib/mastodon/public-system +# PAPERCLIP_ROOT_URL=/system + +# Optional asset host for multi-server setups +# The asset host must allow cross origin request from WEB_DOMAIN or LOCAL_DOMAIN +# if WEB_DOMAIN is not set. For example, the server may have the +# following header field: +# Access-Control-Allow-Origin: https://example.com/ +# CDN_HOST=https://assets.example.com + +# S3 (optional) +# The attachment host must allow cross origin request from WEB_DOMAIN or +# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the +# following header field: +# Access-Control-Allow-Origin: https://192.168.1.123:9000/ +# S3_ENABLED=true +# S3_BUCKET= +# AWS_ACCESS_KEY_ID= +# AWS_SECRET_ACCESS_KEY= +# S3_REGION= +# S3_PROTOCOL=http +# S3_HOSTNAME=192.168.1.123:9000 + +# S3 (Minio Config (optional) Please check Minio instance for details) +# The attachment host must allow cross origin request - see the description +# above. +# S3_ENABLED=true +# S3_BUCKET= +# AWS_ACCESS_KEY_ID= +# AWS_SECRET_ACCESS_KEY= +# S3_REGION= +# S3_PROTOCOL=https +# S3_HOSTNAME= +# S3_ENDPOINT= +# S3_SIGNATURE_VERSION= + +# Swift (optional) +# The attachment host must allow cross origin request - see the description +# above. +# SWIFT_ENABLED=true +# SWIFT_USERNAME= +# For Keystone V3, the value for SWIFT_TENANT should be the project name +# SWIFT_TENANT= +# SWIFT_PASSWORD= +# Some OpenStack V3 providers require PROJECT_ID (optional) +# SWIFT_PROJECT_ID= +# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid +# issues with token rate-limiting during high load. +# SWIFT_AUTH_URL= +# SWIFT_CONTAINER= +# SWIFT_OBJECT_URL= +# SWIFT_REGION= +# Defaults to 'default' +# SWIFT_DOMAIN_NAME= +# Defaults to 60 seconds. Set to 0 to disable +# SWIFT_CACHE_TTL= + +# Optional alias for S3 (e.g. to serve files on a custom domain, possibly using Cloudfront or Cloudflare) +# S3_ALIAS_HOST= + +# Streaming API integration +# STREAMING_API_BASE_URL= + +# Advanced settings +# If you need to use pgBouncer, you need to disable prepared statements: +# PREPARED_STATEMENTS=false + +# Cluster number setting for streaming API server. +# If you comment out following line, cluster number will be `numOfCpuCores - 1`. +STREAMING_CLUSTER_NUM=1 + +# Docker mastodon user +# If you use Docker, you may want to assign UID/GID manually. +# UID=1000 +# GID=1000 + +# LDAP authentication (optional) +# LDAP_ENABLED=true +# LDAP_HOST=localhost +# LDAP_PORT=389 +# LDAP_METHOD=simple_tls +# LDAP_BASE= +# LDAP_BIND_DN= +# LDAP_PASSWORD= +# LDAP_UID=cn +# LDAP_SEARCH_FILTER="%{uid}=%{email}" + +# PAM authentication (optional) +# PAM authentication uses for the email generation the "email" pam variable +# and optional as fallback PAM_DEFAULT_SUFFIX +# The pam environment variable "email" is provided by: +# https://github.com/devkral/pam_email_extractor +# PAM_ENABLED=true +# Fallback email domain for email address generation (LOCAL_DOMAIN by default) +# PAM_EMAIL_DOMAIN=example.com +# Name of the pam service (pam "auth" section is evaluated) +# PAM_DEFAULT_SERVICE=rpam +# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default) +# PAM_CONTROLLED_SERVICE=rpam + +# Global OAuth settings (optional) : +# If you have only one strategy, you may want to enable this +# OAUTH_REDIRECT_AT_SIGN_IN=true + +# Optional CAS authentication (cf. omniauth-cas) : +# CAS_ENABLED=true +# CAS_URL=https://sso.myserver.com/ +# CAS_HOST=sso.myserver.com/ +# CAS_PORT=443 +# CAS_SSL=true +# CAS_VALIDATE_URL= +# CAS_CALLBACK_URL= +# CAS_LOGOUT_URL= +# CAS_LOGIN_URL= +# CAS_UID_FIELD='user' +# CAS_CA_PATH= +# CAS_DISABLE_SSL_VERIFICATION=false +# CAS_UID_KEY='user' +# CAS_NAME_KEY='name' +# CAS_EMAIL_KEY='email' +# CAS_NICKNAME_KEY='nickname' +# CAS_FIRST_NAME_KEY='firstname' +# CAS_LAST_NAME_KEY='lastname' +# CAS_LOCATION_KEY='location' +# CAS_IMAGE_KEY='image' +# CAS_PHONE_KEY='phone' + +# Optional SAML authentication (cf. omniauth-saml) +# SAML_ENABLED=true +# SAML_ACS_URL= +# SAML_ISSUER=http://localhost:3000/auth/auth/saml/callback +# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO +# SAML_IDP_CERT= +# SAML_IDP_CERT_FINGERPRINT= +# SAML_NAME_IDENTIFIER_FORMAT= +# SAML_CERT= +# SAML_PRIVATE_KEY= +# SAML_SECURITY_WANT_ASSERTION_SIGNED=true +# SAML_SECURITY_WANT_ASSERTION_ENCRYPTED=true +# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true +# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1" +# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" +# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241" +# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42" +# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4" +# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1" +# SAML_ATTRIBUTES_STATEMENTS_VERIFIED= +# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL= + +# Use HTTP proxy for outgoing request (optional) +# http_proxy=http://gateway.local:8118 +# Access control for hidden service. +# ALLOW_ACCESS_TO_HIDDEN_SERVICE=true diff --git a/scripts/install b/scripts/install index 4580915..7ef69cc 100644 --- a/scripts/install +++ b/scripts/install @@ -167,31 +167,24 @@ ynh_install_ruby --ruby_version=2.6.0 # MODIFY A CONFIG FILE #================================================= -cp -a $final_path/live/.env.production.sample $final_path/live/.env.production -ynh_replace_string "REDIS_HOST=redis" "REDIS_HOST=127.0.0.1" "${final_path}/live/.env.production" -ynh_replace_string "DB_HOST=db" "DB_HOST=/var/run/postgresql" "${final_path}/live/.env.production" -ynh_replace_string "DB_USER=postgres" "DB_USER=${app}" "${final_path}/live/.env.production" -ynh_replace_string "DB_NAME=postgres" "DB_NAME=${db_name}" "${final_path}/live/.env.production" -ynh_replace_string "DB_PASS=" "DB_PASS=${db_pwd}" "${final_path}/live/.env.production" -ynh_replace_string "LOCAL_DOMAIN=example.com" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" +cp -f ../conf/.env.production.sample "$final_path/live/.env.production" +ynh_replace_string "__DB_USER__" "$app" "$final_path/live/.env.production" +ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/live/.env.production" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/live/.env.production" +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/live/.env.production" language="$(echo $language | head -c 2)" -ynh_replace_string "# DEFAULT_LOCALE=de" "DEFAULT_LOCALE=${language}" "${final_path}/live/.env.production" +ynh_replace_string "__LANGUAGE__" "$language" "$final_path/live/.env.production" paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" -ynh_replace_string "SECRET_KEY_BASE=" "SECRET_KEY_BASE=$secret_key_base" "${final_path}/live/.env.production" -ynh_replace_string "OTP_SECRET=" "OTP_SECRET=$otp_secret" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_LOGIN=" "#SMTP_LOGIN=" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_PASSWORD=" "#SMTP_PASSWORD=" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_SERVER=smtp.mailgun.org" "SMTP_SERVER=localhost" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_PORT=587" "SMTP_PORT=25" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_FROM_ADDRESS=notifications@example.com" "SMTP_FROM_ADDRESS=$admin_mastodon@$domain" "${final_path}/live/.env.production" -ynh_replace_string "#SMTP_AUTH_METHOD=plain" "SMTP_AUTH_METHOD=none" "${final_path}/live/.env.production" -ynh_replace_string "#SMTP_OPENSSL_VERIFY_MODE=peer" "SMTP_OPENSSL_VERIFY_MODE=none" "${final_path}/live/.env.production" +ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" +ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" + +ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mastodon_mail" "${final_path}/live/.env.production" #================================================= # INSTALLING MASTODON From 477783ea53f7c894912ecd7dedde74133863123e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 05:47:44 +0100 Subject: [PATCH 092/129] fix user creation --- scripts/install | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 7ef69cc..6a8dcfb 100644 --- a/scripts/install +++ b/scripts/install @@ -200,18 +200,7 @@ pushd "$final_path/live" sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet -popd - -#================================================= -# CREATE MASTODON ADMIN USER -#================================================= -ynh_print_info "Creating Mastodon Admin User..." - -# Create user -pushd "$final_path/live" - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create '$admin_mastodon' --email='$admin_mastodon_mail' > acc.txt - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin_mastodon" --email="$admin_mastodon_mail" --confirmed --role=admin > acc.txt popd admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) From 1dc6ef4085ba05ad0b5bd0b2c6a4d0d48c7771eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 20:34:35 +0100 Subject: [PATCH 093/129] fix restore --- scripts/restore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/restore b/scripts/restore index 398648f..c2adaaa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -99,6 +99,11 @@ ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies + +ynh_install_ruby --ruby_version=2.6.0 + +/opt/rbenv/versions/2.6.0/bin/gem update --system + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= From 84fe35915e2050927f7371c5d4f390fbf3d8da9d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 21 Mar 2019 22:08:13 +0100 Subject: [PATCH 094/129] Update restore --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index c2adaaa..39de26e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,6 +9,7 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +source ../settings/scripts/ynh_install_ruby #================================================= # MANAGE SCRIPT FAILURE From b0dcddd9b05abdd8138e51170f1ca44f9670ce1f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 05:24:06 +0100 Subject: [PATCH 095/129] Readm Cleanup --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 482ddbd..4993a83 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,6 @@ Mastodon is a free, open-source social network. A decentralized alternative to c ## Configuration -## What is Mastodon? - -[Source code](https://github.com/tootsuite/mastodon) - #### Adding "swapfile" If you have less than 2Go of RAM ``` sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000 From b0ffbcc444dde5f05fff85deb32519f5432d55e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 10:55:44 +0100 Subject: [PATCH 096/129] remove not needed sources --- conf/app-rbenv.src | 6 ------ conf/app-ruby-build.src | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 conf/app-rbenv.src delete mode 100644 conf/app-ruby-build.src diff --git a/conf/app-rbenv.src b/conf/app-rbenv.src deleted file mode 100644 index d60155b..0000000 --- a/conf/app-rbenv.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.1.tar.gz -SOURCE_SUM=41f1a60714c55eceb21d692a469aee1ec4f46bba351d0dfcb0c660ff9cf1a1c9 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src deleted file mode 100644 index 5df8367..0000000 --- a/conf/app-ruby-build.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20190314.tar.gz -SOURCE_SUM=2cc0f9fdb232042e71edad93a5c3ae108bcd090ea0b6db4e5bb6325547e07968 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= From 94dc44545bd699180ad1bc7ee65d397d0cc161bd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 22:39:50 +0100 Subject: [PATCH 097/129] fix change_url check --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 97f5caf..8ef60b3 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,7 @@ multi_instance=0 incorrect_path=0 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto From c468541e82263ec9149c66996b36c6c27d32ffba Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 22:41:35 +0100 Subject: [PATCH 098/129] cleanup --- scripts/install | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/install b/scripts/install index 6a8dcfb..89445a3 100644 --- a/scripts/install +++ b/scripts/install @@ -14,11 +14,6 @@ source ynh_install_ruby # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From c7da529e29cca2fe42608a3fd73935d75930bba5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 23:09:55 +0100 Subject: [PATCH 099/129] cleanup --- check_process | 8 ++++---- manifest.json | 9 +++++++++ scripts/change_url | 4 ++-- scripts/install | 21 +++++++-------------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/check_process b/check_process index 8ef60b3..e337f1e 100644 --- a/check_process +++ b/check_process @@ -9,12 +9,12 @@ setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=0 - setup_public=0 + setup_private=1 + setup_public=1 upgrade=1 backup_restore=1 - multi_instance=0 - incorrect_path=0 + multi_instance=1 + incorrect_path=1 port_already_use=0 change_url=1 ;;; Levels diff --git a/manifest.json b/manifest.json index 1be7df5..1d1789e 100644 --- a/manifest.json +++ b/manifest.json @@ -40,6 +40,15 @@ }, "example": "johndoe" }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" + }, + "default": true + }, { "name": "language", "type": "string", diff --git a/scripts/change_url b/scripts/change_url index 96292a4..51d37d6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get $app final_path) # Add settings here as needed by your application #db_name=$(ynh_app_setting_get "$app" db_name) #db_pwd=$(ynh_app_setting_get $app db_pwd) -admin_mastodon=$(ynh_app_setting_get $app admin) +admin_mail=$(ynh_app_setting_get $app admin_mail) #================================================= # CHECK THE SYNTAX OF THE PATHS @@ -106,7 +106,7 @@ yunohost service stop "$app-streaming" #================================================= ynh_replace_string "LOCAL_DOMAIN=*" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_FROM_ADDRESS=*" "SMTP_FROM_ADDRESS=$admin_mastodon@$domain" "${final_path}/live/.env.production" +ynh_replace_string "SMTP_FROM_ADDRESS=*" "SMTP_FROM_ADDRESS=$admin_mail" "${final_path}/live/.env.production" #================================================= # START MASTODON SERVICES diff --git a/scripts/install b/scripts/install index 89445a3..0d85c74 100644 --- a/scripts/install +++ b/scripts/install @@ -23,11 +23,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -admin_mastodon=$YNH_APP_ARG_ADMIN -is_public=true +admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE -admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') +admin_mail=$(ynh_user_get_info $admin 'mail') port_web=$(ynh_find_port 3000) port_stream=$(ynh_find_port 4000) @@ -39,8 +39,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_print_info "Validating installation parameters..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -59,7 +57,7 @@ ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin_mastodon +ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app language $language ynh_app_setting_set $app port_web $port_web @@ -179,7 +177,7 @@ ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${f ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" -ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mastodon_mail" "${final_path}/live/.env.production" +ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/live/.env.production" #================================================= # INSTALLING MASTODON @@ -195,7 +193,7 @@ pushd "$final_path/live" sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin_mastodon" --email="$admin_mastodon_mail" --confirmed --role=admin > acc.txt + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt popd admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) @@ -248,10 +246,6 @@ ynh_store_file_checksum "${final_path}/live/.env.production" # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - # Set permissions to app files chown -R "$app": "$final_path" @@ -259,7 +253,6 @@ chown -R "$app": "$final_path" # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -# Add service YunoHost yunohost service add "$app-web" yunohost service add "$app-sidekiq" yunohost service add "$app-streaming" @@ -293,7 +286,7 @@ The admin email is: $admin_mastodon_mail The admin password is: $admin_pass If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" -ynh_send_readme_to_admin "$message" "$admin_mastodon" +ynh_send_readme_to_admin "$message" "$admin" #================================================= # END OF SCRIPT From e7df7cc8d71cbde6e4a74552298a83c579751163 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 23:24:05 +0100 Subject: [PATCH 100/129] Add VAPID Keys generation --- conf/.env.production.sample | 21 ++++++++++----------- scripts/install | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index ee65015..2093267 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -36,17 +36,6 @@ LOCAL_DOMAIN=__DOMAIN__ SECRET_KEY_BASE=__SECRET_KEY_BASE__ OTP_SECRET=__OTP_SECRET__ -# VAPID keys (used for push notifications -# You can generate the keys using the following command (first is the private key, second is the public one) -# You should only generate this once per instance. If you later decide to change it, all push subscription will -# be invalidated, requiring the users to access the website again to resubscribe. -# -# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) -# -# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html -VAPID_PRIVATE_KEY= -VAPID_PUBLIC_KEY= - # Registrations # Single user mode will disable registrations and redirect frontpage to the first profile # SINGLE_USER_MODE=true @@ -230,3 +219,13 @@ STREAMING_CLUSTER_NUM=1 # http_proxy=http://gateway.local:8118 # Access control for hidden service. # ALLOW_ACCESS_TO_HIDDEN_SERVICE=true + + +# VAPID keys (used for push notifications +# You can generate the keys using the following command (first is the private key, second is the public one) +# You should only generate this once per instance. If you later decide to change it, all push subscription will +# be invalidated, requiring the users to access the website again to resubscribe. +# +# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) +# +# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html diff --git a/scripts/install b/scripts/install index 0d85c74..2c12cf4 100644 --- a/scripts/install +++ b/scripts/install @@ -193,6 +193,7 @@ pushd "$final_path/live" sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key >> "${final_path}/live/.env.production" sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt popd From 35f672269a6ca225f7dc51a81e57c8de5c9afdeb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 23:42:17 +0100 Subject: [PATCH 101/129] move port in port step --- scripts/install | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 2c12cf4..e57dbab 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,7 @@ source _common.sh source /usr/share/yunohost/helpers source ynh_install_ruby +source ynh_add_secure_repos__2 #================================================= # MANAGE SCRIPT FAILURE @@ -28,9 +29,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE admin_mail=$(ynh_user_get_info $admin 'mail') -port_web=$(ynh_find_port 3000) -port_stream=$(ynh_find_port 4000) - app=$YNH_APP_INSTANCE_NAME @@ -60,13 +58,25 @@ ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app language $language -ynh_app_setting_set $app port_web $port_web -ynh_app_setting_set $app port_stream $port_stream #================================================= # STANDARD MODIFICATIONS #================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_print_info "Configuring firewall..." +### Use these lines if you have to open a port for the application +### `ynh_find_port` will find the first available port starting from the given port. +### If you're not using these lines: +### - Remove the section "CLOSE A PORT" in the remove script + +# Find a free port +port_web=$(ynh_find_port 3000) +port_stream=$(ynh_find_port 4000) +# Open this port +ynh_app_setting_set $app port_web $port_web +ynh_app_setting_set $app port_stream $port_stream #================================================= # INSTALL DEPENDENCIES From 5cd0ad6b49991cf45a74b4a6c9db3e3bb5e4ebb4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 23:43:29 +0100 Subject: [PATCH 102/129] LDAP implementation --- conf/.env.production.sample | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 2093267..8f248fa 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -143,14 +143,14 @@ STREAMING_CLUSTER_NUM=1 # GID=1000 # LDAP authentication (optional) -# LDAP_ENABLED=true -# LDAP_HOST=localhost -# LDAP_PORT=389 +LDAP_ENABLED=true +LDAP_HOST=localhost +LDAP_PORT=389 # LDAP_METHOD=simple_tls -# LDAP_BASE= +LDAP_BASE=ou=users,dc=yunohost,dc=org # LDAP_BIND_DN= # LDAP_PASSWORD= -# LDAP_UID=cn +LDAP_UID=uid # LDAP_SEARCH_FILTER="%{uid}=%{email}" # PAM authentication (optional) From dddaefcd63215f3416e387dcc2cf94b89c73d682 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 Mar 2019 23:59:16 +0100 Subject: [PATCH 103/129] adding ynh_add_secure_repos__2 --- conf/ynh_add_secure_repos__2 | 166 +++++++++++++++++++++++++++++++++++ scripts/install | 7 +- scripts/remove | 10 +-- scripts/restore | 8 +- scripts/upgrade | 8 +- 5 files changed, 180 insertions(+), 19 deletions(-) create mode 100644 conf/ynh_add_secure_repos__2 diff --git a/conf/ynh_add_secure_repos__2 b/conf/ynh_add_secure_repos__2 new file mode 100644 index 0000000..51a9f1b --- /dev/null +++ b/conf/ynh_add_secure_repos__2 @@ -0,0 +1,166 @@ +#!/bin/bash + +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter --priority=priority_value [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkna + declare -Ar args_array=( [r]=repo= [k]=key= [n]=name= [a]=append ) + local repo + local key + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + ynh_pin_repo --package="*" --pin="origin \"$pin\"" --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | $wget_append /etc/apt/trusted.gpg.d/$name.gpg + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + + # Update the list of package to exclude the old repo + ynh_package_update +} diff --git a/scripts/install b/scripts/install index e57dbab..bf52357 100644 --- a/scripts/install +++ b/scripts/install @@ -92,12 +92,11 @@ if [[ "$arch" = arm* ]]; then apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 fi -# Install source.list debian package backports & yarn +# Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_package_update # install nodejs diff --git a/scripts/remove b/scripts/remove index 8880c9c..3436bce 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,7 @@ source _common.sh source /usr/share/yunohost/helpers source ynh_install_ruby +source ynh_add_secure_repos__2 #================================================= # LOAD SETTINGS @@ -77,13 +78,8 @@ ynh_remove_ruby ynh_remove_app_dependencies ynh_remove_nodejs -#================================================= -# REMOVE APT SOURCES -#================================================= -ynh_print_info "Removing apt sources" - -ynh_secure_remove "/etc/apt/sources.list.d/jessie-backports.list" -ynh_secure_remove "/etc/apt/sources.list.d/yarn.list" +ynh_remove_extra_repo jessie-backports +ynh_remove_extra_repo yarn #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 39de26e..c74eadc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,7 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers source ../settings/scripts/ynh_install_ruby +source ../settings/scripts/ynh_add_secure_repos__2 #================================================= # MANAGE SCRIPT FAILURE @@ -86,12 +87,11 @@ if [[ "$arch" = arm* ]]; then apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 fi -# Install source.list debian package backports & yarn +# Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_package_update # install nodejs diff --git a/scripts/upgrade b/scripts/upgrade index 87b0432..a210372 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,6 +9,7 @@ source _common.sh source /usr/share/yunohost/helpers source ynh_install_ruby +source ynh_add_secure_repos__2 #================================================= # LOAD SETTINGS @@ -124,12 +125,11 @@ ynh_add_nginx_config #================================================= ynh_print_info "Upgrading dependencies..." -# Install source.list debian package backports & yarn +# Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_package_update # install nodejs From c61837c5f88e382bd495b377a6be980d1a6dd044 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 00:05:43 +0100 Subject: [PATCH 104/129] fix admin_mail --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index bf52357..a150743 100644 --- a/scripts/install +++ b/scripts/install @@ -292,7 +292,7 @@ systemctl reload nginx message="Mastodon was successfully installed :) Please open 'https://$domain$path_url' -The admin email is: $admin_mastodon_mail +The admin email is: $admin_mail The admin password is: $admin_pass If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" From e1f1a535b7397c6efe64ea70f513b7270cad98ee Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 00:09:36 +0100 Subject: [PATCH 105/129] move ynh_add_secure_repos__2 at the good place --- {conf => scripts}/ynh_add_secure_repos__2 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {conf => scripts}/ynh_add_secure_repos__2 (100%) diff --git a/conf/ynh_add_secure_repos__2 b/scripts/ynh_add_secure_repos__2 similarity index 100% rename from conf/ynh_add_secure_repos__2 rename to scripts/ynh_add_secure_repos__2 From ffda3d5c8b89ab7725df7b41882c3bdb2328406b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 00:11:09 +0100 Subject: [PATCH 106/129] siwth app-mastodon.src to app.src --- conf/{app-mastodon.src => app.src} | 0 scripts/upgrade | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename conf/{app-mastodon.src => app.src} (100%) diff --git a/conf/app-mastodon.src b/conf/app.src similarity index 100% rename from conf/app-mastodon.src rename to conf/app.src diff --git a/scripts/upgrade b/scripts/upgrade index a210372..d487286 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -101,7 +101,7 @@ ynh_print_info "Upgrading source files..." # Download Mastodon mv "$final_path/live" "$final_path/live_back" -ynh_setup_source "$final_path/live" "app-mastodon" +ynh_setup_source "$final_path/live" if [ -z $final_path/live_back/public/system ]; then rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." fi From a09cb0c89122f22a7fa57e9c41124103716a543d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 00:14:12 +0100 Subject: [PATCH 107/129] fix source for install --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index a150743..1fd4cdb 100644 --- a/scripts/install +++ b/scripts/install @@ -132,7 +132,7 @@ ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src mkdir $final_path -ynh_setup_source "$final_path/live" "app-mastodon" +ynh_setup_source "$final_path/live" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index d487286..01f0a49 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,7 +132,7 @@ fi ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_package_update -# install nodejs +# Install nodejs ynh_install_nodejs 8 # TODO: use the same mecanism with other files From 86301f170d2d0b3de9943561f37c3015faf732ce Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 01:24:41 +0100 Subject: [PATCH 108/129] fix LDAP_BIND_DN --- conf/.env.production.sample | 4 ++-- scripts/install | 33 +++++++++------------------------ scripts/remove | 7 +++++++ scripts/upgrade | 3 --- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 8f248fa..c42c821 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -148,8 +148,8 @@ LDAP_HOST=localhost LDAP_PORT=389 # LDAP_METHOD=simple_tls LDAP_BASE=ou=users,dc=yunohost,dc=org -# LDAP_BIND_DN= -# LDAP_PASSWORD= +LDAP_BIND_DN=uid=__APP__,ou=users,dc=yunohost,dc=org +LDAP_PASSWORD=__LDAP_PASSWORD__ LDAP_UID=uid # LDAP_SEARCH_FILTER="%{uid}=%{email}" diff --git a/scripts/install b/scripts/install index 1fd4cdb..fc6afcc 100644 --- a/scripts/install +++ b/scripts/install @@ -66,11 +66,6 @@ ynh_app_setting_set $app language $language #================================================= ynh_print_info "Configuring firewall..." -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script - # Find a free port port_web=$(ynh_find_port 3000) port_stream=$(ynh_find_port 4000) @@ -125,10 +120,6 @@ ynh_psql_execute_as_root \ #================================================= ynh_print_info "Setting up source files..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src mkdir $final_path @@ -139,8 +130,6 @@ ynh_setup_source "$final_path/live" #================================================= ynh_print_info "Configuring nginx web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" @@ -179,15 +168,22 @@ language="$(echo $language | head -c 2)" ynh_replace_string "__LANGUAGE__" "$language" "$final_path/live/.env.production" paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" +secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" + +otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/live/.env.production" +ynh_user_exists $app || ynh_die "LDAP User $app already exist" +ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 +ynh_replace_string "__APP__" "$app" "${final_path}/live/.env.production" +ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" + #================================================= # INSTALLING MASTODON #================================================= @@ -223,17 +219,6 @@ sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= ynh_print_info "Configuring a systemd service..." -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script - # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" diff --git a/scripts/remove b/scripts/remove index 3436bce..73a9bf7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -99,6 +99,13 @@ ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE +#================================================= +# REMOVE LDAP USER +#================================================= + +# Remove $app LDAP User +yunohost user delete $app --purge + #================================================= # REMOVE THE CRON FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 01f0a49..668b7cf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -176,9 +176,6 @@ pushd "$final_path/live" sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate popd -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different "${final_path}/live/.env.production" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "${final_path}/live/.env.production" From d4eac065f751c0f7f566ee41d689d9232654b8e7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 01:54:06 +0100 Subject: [PATCH 109/129] Fix LDAP User --- conf/.env.production.sample | 2 +- scripts/install | 13 ++++--- scripts/upgrade | 69 ++++++++++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index c42c821..68249e1 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -148,7 +148,7 @@ LDAP_HOST=localhost LDAP_PORT=389 # LDAP_METHOD=simple_tls LDAP_BASE=ou=users,dc=yunohost,dc=org -LDAP_BIND_DN=uid=__APP__,ou=users,dc=yunohost,dc=org +LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org LDAP_PASSWORD=__LDAP_PASSWORD__ LDAP_UID=uid # LDAP_SEARCH_FILTER="%{uid}=%{email}" diff --git a/scripts/install b/scripts/install index fc6afcc..1e8ee50 100644 --- a/scripts/install +++ b/scripts/install @@ -163,26 +163,31 @@ ynh_replace_string "__DB_USER__" "$app" "$final_path/live/.env.production" ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/live/.env.production" ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/live/.env.production" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/live/.env.production" +ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/live/.env.production" language="$(echo $language | head -c 2)" ynh_replace_string "__LANGUAGE__" "$language" "$final_path/live/.env.production" paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" +ynh_app_setting_set "$app" paperclip_secret "$paperclip_secret" secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" +ynh_app_setting_set "$app" secret_key_base "$secret_key_base" otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" +ynh_app_setting_set "$app" otp_secret "$otp_secret" -ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/live/.env.production" - -ynh_user_exists $app || ynh_die "LDAP User $app already exist" +ldap_user="$app_ldap" +ynh_user_exists $ldap_user || ynh_die "LDAP User $app already exist" ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 -ynh_replace_string "__APP__" "$app" "${final_path}/live/.env.production" +ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" +ynh_app_setting_set "$app" ldap_user "$ldap_user" +ynh_app_setting_set "$app" ldap_password "$ldap_password" #================================================= # INSTALLING MASTODON diff --git a/scripts/upgrade b/scripts/upgrade index 668b7cf..0e0b84d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,9 +27,16 @@ language=$(ynh_app_setting_get $app language) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) +admin_mail=$(ynh_user_get_info $admin 'mail') port_web=$(ynh_app_setting_get "$app" port_web) port_stream=$(ynh_app_setting_get "$app" port_stream) +paperclip_secret=$(ynh_app_setting_get "$app" paperclip_secret) +secret_key_base=$(ynh_app_setting_get "$app" secret_key_base) +otp_secret=$(ynh_app_setting_get "$app" otp_secret) +ldap_user=$(ynh_app_setting_get "$app" ldap_user) +ldap_password=$(ynh_app_setting_get "$app" ldap_password) + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -62,6 +69,33 @@ if [[ -z "$db_pwd" ]]; then ynh_replace_string "DB_PASS=" "DB_PASS=${db_pwd}" "${final_path}/live/.env.production" fi +# If paperclip_secret doesn't exist, retrieve it or create it +if [[ -z "$paperclip_secret" ]]; then + paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + ynh_app_setting_set "$app" paperclip_secret "$paperclip_secret" +fi + +# If secret_key_base doesn't exist, retrieve it or create it +if [[ -z "$secret_key_base" ]]; then + secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + ynh_app_setting_set "$app" secret_key_base "$secret_key_base" +fi + +# If otp_secret doesn't exist, retrieve it or create it +if [[ -z "$otp_secret" ]]; then + otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + ynh_app_setting_set "$app" otp_secret "$otp_secret" +fi + +# If ldap_password doesn't exist, retrieve it or create it +if [[ -z "$ldap_user" ]]; then + ynh_user_exists $ldap_user || ynh_die "LDAP User $app already exist" + ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 + ynh_app_setting_set "$app" ldap_user "$ldap_user" + ynh_app_setting_set "$app" ldap_password "$ldap_password" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -156,6 +190,39 @@ ynh_install_ruby --ruby_version=2.6.0 /opt/rbenv/versions/2.6.0/bin/gem update --system #/opt/rbenv/versions/2.6.0/bin/gem install bundler +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +cp -f ../conf/.env.production.sample "$final_path/live/.env.production" +ynh_replace_string "__DB_USER__" "$app" "$final_path/live/.env.production" +ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/live/.env.production" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/live/.env.production" +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/live/.env.production" +ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/live/.env.production" + +language="$(echo $language | head -c 2)" +ynh_replace_string "__LANGUAGE__" "$language" "$final_path/live/.env.production" + +paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" +ynh_app_setting_set "$app" paperclip_secret "$paperclip_secret" + +secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" +ynh_app_setting_set "$app" secret_key_base "$secret_key_base" + +otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" +ynh_app_setting_set "$app" otp_secret "$otp_secret" + +ynh_user_exists $app || ynh_die "LDAP User $app already exist" +ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 +ynh_replace_string "__APP__" "$app" "${final_path}/live/.env.production" +ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" +ynh_app_setting_set "$app" ldap_password "$ldap_password" + #================================================= # UPGRADE MASTODON #================================================= @@ -182,7 +249,7 @@ ynh_store_file_checksum "${final_path}/live/.env.production" #================================================= # SETUP CRON JOB FOR REMOVING CACHE #================================================= -ynh_print_info "Setuping a cron job for remiving cache..." +ynh_print_info "Setuping a cron job for removing cache..." ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron ynh_replace_string "__USER__" "$app" ../conf/cron From 80acfc8df60cff08f9b3c77302e094b681d49d28 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 02:07:42 +0100 Subject: [PATCH 110/129] fix ldap username --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 1e8ee50..6b5d676 100644 --- a/scripts/install +++ b/scripts/install @@ -180,7 +180,7 @@ otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" ynh_app_setting_set "$app" otp_secret "$otp_secret" -ldap_user="$app_ldap" +ldap_user="${app}_ldap" ynh_user_exists $ldap_user || ynh_die "LDAP User $app already exist" ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 From ff2fea8ef2b45cb027a72b8a3b124dd401f6a159 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 02:18:28 +0100 Subject: [PATCH 111/129] fix ldap_user --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 6b5d676..5e3f742 100644 --- a/scripts/install +++ b/scripts/install @@ -180,10 +180,10 @@ otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" ynh_app_setting_set "$app" otp_secret "$otp_secret" -ldap_user="${app}_ldap" -ynh_user_exists $ldap_user || ynh_die "LDAP User $app already exist" +ldap_user="${app}ldap" +ynh_user_exists $ldap_user || ynh_die "LDAP User $ldap_user already exist" ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 +yunohost user create username -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" ynh_app_setting_set "$app" ldap_user "$ldap_user" From 652d6f6c67c200fc22bf03efed0174ebc4f38d29 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 02:28:48 +0100 Subject: [PATCH 112/129] fix ldap user --- scripts/install | 1 - scripts/upgrade | 17 ++++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/scripts/install b/scripts/install index 5e3f742..bc2229c 100644 --- a/scripts/install +++ b/scripts/install @@ -181,7 +181,6 @@ ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.product ynh_app_setting_set "$app" otp_secret "$otp_secret" ldap_user="${app}ldap" -ynh_user_exists $ldap_user || ynh_die "LDAP User $ldap_user already exist" ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) yunohost user create username -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" diff --git a/scripts/upgrade b/scripts/upgrade index 0e0b84d..fbe9ec7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,9 +89,10 @@ fi # If ldap_password doesn't exist, retrieve it or create it if [[ -z "$ldap_user" ]]; then - ynh_user_exists $ldap_user || ynh_die "LDAP User $app already exist" + ldap_user="${app}ldap" + ynh_user_exists $ldap_user || ynh_die "LDAP User $ldap_user already exist" ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) - yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 + yunohost user create username -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 ynh_app_setting_set "$app" ldap_user "$ldap_user" ynh_app_setting_set "$app" ldap_password "$ldap_password" fi @@ -204,24 +205,14 @@ ynh_replace_string "__SMTP_FROM_ADDRESS__" "$admin_mail" "${final_path}/l language="$(echo $language | head -c 2)" ynh_replace_string "__LANGUAGE__" "$language" "$final_path/live/.env.production" -paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "PAPERCLIP_SECRET=" "PAPERCLIP_SECRET=$paperclip_secret" "${final_path}/live/.env.production" -ynh_app_setting_set "$app" paperclip_secret "$paperclip_secret" -secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.env.production" -ynh_app_setting_set "$app" secret_key_base "$secret_key_base" -otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" -ynh_app_setting_set "$app" otp_secret "$otp_secret" -ynh_user_exists $app || ynh_die "LDAP User $app already exist" -ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -yunohost user create username f $app -l $app -m $app@$domain -p $ldap_password -q 0 -ynh_replace_string "__APP__" "$app" "${final_path}/live/.env.production" +ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" -ynh_app_setting_set "$app" ldap_password "$ldap_password" #================================================= # UPGRADE MASTODON From d1a1e67008d0838257528344d56b285ad7a39f34 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 02:58:59 +0100 Subject: [PATCH 113/129] fix key for upgrade --- conf/.env.production.sample | 21 +++++++++++---------- scripts/install | 17 ++++++++++++++--- scripts/upgrade | 27 ++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 68249e1..6606352 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -36,6 +36,17 @@ LOCAL_DOMAIN=__DOMAIN__ SECRET_KEY_BASE=__SECRET_KEY_BASE__ OTP_SECRET=__OTP_SECRET__ +# VAPID keys (used for push notifications +# You can generate the keys using the following command (first is the private key, second is the public one) +# You should only generate this once per instance. If you later decide to change it, all push subscription will +# be invalidated, requiring the users to access the website again to resubscribe. +# +# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) +# +# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html +VAPID_PRIVATE_KEY=__VAPID_PRIVATE_KEY__ +VAPID_PUBLIC_KEY=__VAPID_PUBLIC_KEY__ + # Registrations # Single user mode will disable registrations and redirect frontpage to the first profile # SINGLE_USER_MODE=true @@ -219,13 +230,3 @@ LDAP_UID=uid # http_proxy=http://gateway.local:8118 # Access control for hidden service. # ALLOW_ACCESS_TO_HIDDEN_SERVICE=true - - -# VAPID keys (used for push notifications -# You can generate the keys using the following command (first is the private key, second is the public one) -# You should only generate this once per instance. If you later decide to change it, all push subscription will -# be invalidated, requiring the users to access the website again to resubscribe. -# -# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) -# -# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html diff --git a/scripts/install b/scripts/install index bc2229c..2d43ce7 100644 --- a/scripts/install +++ b/scripts/install @@ -181,8 +181,8 @@ ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.product ynh_app_setting_set "$app" otp_secret "$otp_secret" ldap_user="${app}ldap" -ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) -yunohost user create username -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 +ldap_password=$(head -n32 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c32) +yunohost user create $ldap_user -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" ynh_app_setting_set "$app" ldap_user "$ldap_user" @@ -202,13 +202,24 @@ pushd "$final_path/live" sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key >> "${final_path}/live/.env.production" + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt popd admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) ynh_secure_remove "$final_path/live/acc.txt" +vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K\w+" "$final_path/live/key.txt") +vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" "$final_path/live/key.txt") + +ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production" +ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production" + +ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" +ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" + +ynh_secure_remove "$final_path/live/key.txt" + #================================================= # SETUP CRON JOB FOR REMOVING CACHE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fbe9ec7..c906570 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,8 @@ secret_key_base=$(ynh_app_setting_get "$app" secret_key_base) otp_secret=$(ynh_app_setting_get "$app" otp_secret) ldap_user=$(ynh_app_setting_get "$app" ldap_user) ldap_password=$(ynh_app_setting_get "$app" ldap_password) +vapid_private_key=$(ynh_app_setting_get "$app" vapid_private_key) +vapid_public_key=$(ynh_app_setting_get "$app" vapid_public_key) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -71,19 +73,28 @@ fi # If paperclip_secret doesn't exist, retrieve it or create it if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" test) + if [[ -z "$paperclip_secret" ]]; then + paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + fi ynh_app_setting_set "$app" paperclip_secret "$paperclip_secret" fi # If secret_key_base doesn't exist, retrieve it or create it if [[ -z "$secret_key_base" ]]; then - secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" test) + if [[ -z "$secret_key_base" ]]; then + secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + fi ynh_app_setting_set "$app" secret_key_base "$secret_key_base" fi # If otp_secret doesn't exist, retrieve it or create it if [[ -z "$otp_secret" ]]; then - otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + otp_secret=$(grep -oP "OTP_SECRET=\K\w+" test) + if [[ -z "$otp_secret" ]]; then + otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + fi ynh_app_setting_set "$app" otp_secret "$otp_secret" fi @@ -234,6 +245,16 @@ pushd "$final_path/live" sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate popd +# If vapid_private_key doesn't exist, retrieve it or create it +if [[ -z "$vapid_private_key" ]]; then + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K\w+" "$final_path/live/key.txt") + vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" "$final_path/live/key.txt") + ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" + ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" + ynh_secure_remove "$final_path/live/key.txt" +fi + # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "${final_path}/live/.env.production" From 37e462d1adacc1f011aedac4209bccae36535275 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 03:33:44 +0100 Subject: [PATCH 114/129] removed LDAP Mastodon LDAP need authentication Wasn't able to create a dedicated user --- conf/.env.production.sample | 14 +++++++------- scripts/install | 8 -------- scripts/remove | 7 ------- scripts/upgrade | 15 --------------- 4 files changed, 7 insertions(+), 37 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 6606352..d6bd0c6 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -154,14 +154,14 @@ STREAMING_CLUSTER_NUM=1 # GID=1000 # LDAP authentication (optional) -LDAP_ENABLED=true -LDAP_HOST=localhost -LDAP_PORT=389 +# LDAP_ENABLED=true +# LDAP_HOST=localhost +# LDAP_PORT=389 # LDAP_METHOD=simple_tls -LDAP_BASE=ou=users,dc=yunohost,dc=org -LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org -LDAP_PASSWORD=__LDAP_PASSWORD__ -LDAP_UID=uid +# LDAP_BASE=ou=users,dc=yunohost,dc=org +# LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org +# LDAP_PASSWORD=__LDAP_PASSWORD__ +# LDAP_UID=uid # LDAP_SEARCH_FILTER="%{uid}=%{email}" # PAM authentication (optional) diff --git a/scripts/install b/scripts/install index 2d43ce7..feb0a70 100644 --- a/scripts/install +++ b/scripts/install @@ -180,14 +180,6 @@ otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" ynh_app_setting_set "$app" otp_secret "$otp_secret" -ldap_user="${app}ldap" -ldap_password=$(head -n32 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c32) -yunohost user create $ldap_user -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 -ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" -ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" -ynh_app_setting_set "$app" ldap_user "$ldap_user" -ynh_app_setting_set "$app" ldap_password "$ldap_password" - #================================================= # INSTALLING MASTODON #================================================= diff --git a/scripts/remove b/scripts/remove index 73a9bf7..3436bce 100644 --- a/scripts/remove +++ b/scripts/remove @@ -99,13 +99,6 @@ ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE -#================================================= -# REMOVE LDAP USER -#================================================= - -# Remove $app LDAP User -yunohost user delete $app --purge - #================================================= # REMOVE THE CRON FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c906570..c5f19f3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,8 +34,6 @@ port_stream=$(ynh_app_setting_get "$app" port_stream) paperclip_secret=$(ynh_app_setting_get "$app" paperclip_secret) secret_key_base=$(ynh_app_setting_get "$app" secret_key_base) otp_secret=$(ynh_app_setting_get "$app" otp_secret) -ldap_user=$(ynh_app_setting_get "$app" ldap_user) -ldap_password=$(ynh_app_setting_get "$app" ldap_password) vapid_private_key=$(ynh_app_setting_get "$app" vapid_private_key) vapid_public_key=$(ynh_app_setting_get "$app" vapid_public_key) @@ -98,16 +96,6 @@ if [[ -z "$otp_secret" ]]; then ynh_app_setting_set "$app" otp_secret "$otp_secret" fi -# If ldap_password doesn't exist, retrieve it or create it -if [[ -z "$ldap_user" ]]; then - ldap_user="${app}ldap" - ynh_user_exists $ldap_user || ynh_die "LDAP User $ldap_user already exist" - ldap_password=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) - yunohost user create username -f $ldap_user -l $ldap_user -m $app@$domain -p $ldap_password -q 0 - ynh_app_setting_set "$app" ldap_user "$ldap_user" - ynh_app_setting_set "$app" ldap_password "$ldap_password" -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -222,9 +210,6 @@ ynh_replace_string "__SECRET_KEY_BASE__" "$secret_key_base" "$final_path/live/.e ynh_replace_string "__OTP_SECRET__" "$otp_secret" "$final_path/live/.env.production" -ynh_replace_string "__LDAP_USER__" "$ldap_user" "${final_path}/live/.env.production" -ynh_replace_string "__LDAP_PASSWORD__" "$ldap_password" "${final_path}/live/.env.production" - #================================================= # UPGRADE MASTODON #================================================= From 210af9d0f92bc699d452aaba5c45d9a3e7368938 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 03:44:14 +0100 Subject: [PATCH 115/129] Fix database name --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c5f19f3..dd41ada 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,7 +44,7 @@ ynh_print_info "Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid $app) + db_name="${app}_production" ynh_app_setting_set $app db_name $db_name fi From 2f69ed9251d83bf670244a5828dea04d89d058ca Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Mar 2019 13:11:31 +0100 Subject: [PATCH 116/129] fix yarn repo key --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index feb0a70..4b197d2 100644 --- a/scripts/install +++ b/scripts/install @@ -91,7 +91,7 @@ fi if [ "$(lsb_release --codename --short)" == "jessie" ]; then ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg ynh_package_update # install nodejs diff --git a/scripts/restore b/scripts/restore index c74eadc..62675c7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ fi if [ "$(lsb_release --codename --short)" == "jessie" ]; then ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg ynh_package_update # install nodejs diff --git a/scripts/upgrade b/scripts/upgrade index dd41ada..fbd532f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -163,7 +163,7 @@ ynh_print_info "Upgrading dependencies..." if [ "$(lsb_release --codename --short)" == "jessie" ]; then ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg ynh_package_update # Install nodejs From 08485fd7d3348256a11b39371217cca24cee6323 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Mar 2019 21:20:14 +0100 Subject: [PATCH 117/129] Fix armored key --- scripts/install | 10 +++++++--- scripts/remove | 3 +-- scripts/ynh_add_secure_repos__2 | 9 ++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 4b197d2..e68ac0a 100644 --- a/scripts/install +++ b/scripts/install @@ -15,6 +15,11 @@ source ynh_add_secure_repos__2 # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -89,10 +94,9 @@ fi # Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" --append fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg -ynh_package_update +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" --append # install nodejs ynh_install_nodejs 8 diff --git a/scripts/remove b/scripts/remove index 3436bce..1690fdb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -78,8 +78,7 @@ ynh_remove_ruby ynh_remove_app_dependencies ynh_remove_nodejs -ynh_remove_extra_repo jessie-backports -ynh_remove_extra_repo yarn +ynh_remove_extra_repo #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/ynh_add_secure_repos__2 b/scripts/ynh_add_secure_repos__2 index 51a9f1b..39bc21b 100644 --- a/scripts/ynh_add_secure_repos__2 +++ b/scripts/ynh_add_secure_repos__2 @@ -137,7 +137,13 @@ ynh_install_extra_repo () { if [ -n "$key" ] then mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | $wget_append /etc/apt/trusted.gpg.d/$name.gpg + if [[ "$(basename "$key")" =~ ".asc" ]] + then + local key_ext=asc + else + local key_ext=gpg + fi + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.$key_ext fi # Update the list of package with the new repo @@ -160,6 +166,7 @@ ynh_remove_extra_repo () { ynh_secure_remove "/etc/apt/sources.list.d/$name.list" ynh_secure_remove "/etc/apt/preferences.d/$name" ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" # Update the list of package to exclude the old repo ynh_package_update From 9749ea5afa46b1a390f2cd09162c695417c2863d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Mar 2019 21:21:46 +0100 Subject: [PATCH 118/129] remove ynh_clean_setup --- scripts/install | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/install b/scripts/install index e68ac0a..4814306 100644 --- a/scripts/install +++ b/scripts/install @@ -15,11 +15,6 @@ source ynh_add_secure_repos__2 # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From 0efc6dc766b4cc86fecf00f0e1b6a2ddab5dea5b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Mar 2019 22:24:36 +0100 Subject: [PATCH 119/129] Fix ynh_install_extra_repo --- scripts/restore | 5 ++--- scripts/upgrade | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/restore b/scripts/restore index 62675c7..bfe6fbb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,10 +89,9 @@ fi # Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" --append fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg -ynh_package_update +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" --append # install nodejs ynh_install_nodejs 8 diff --git a/scripts/upgrade b/scripts/upgrade index fbd532f..266eae8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -161,10 +161,9 @@ ynh_print_info "Upgrading dependencies..." # Install extra_repo debian package backports & yarn if [ "$(lsb_release --codename --short)" == "jessie" ]; then - ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" + ynh_install_extra_repo --repo="deb http://httpredir.debian.org/debian jessie-backports main" --append fi -ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key=https://dl.yarnpkg.com/debian/pubkey.gpg -ynh_package_update +ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" --append # Install nodejs ynh_install_nodejs 8 From d9c52a27d2fb703bf9db984d13f7c74e32b8bfbc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 31 Mar 2019 18:02:01 +0200 Subject: [PATCH 120/129] Fix bug generated by ynh_install_extra_repo --- scripts/ynh_add_secure_repos__2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ynh_add_secure_repos__2 b/scripts/ynh_add_secure_repos__2 index 39bc21b..7db7843 100644 --- a/scripts/ynh_add_secure_repos__2 +++ b/scripts/ynh_add_secure_repos__2 @@ -143,7 +143,7 @@ ynh_install_extra_repo () { else local key_ext=gpg fi - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.$key_ext + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.$key_ext > /dev/null fi # Update the list of package with the new repo From fbc7ebc188e3dd43b74a67e3d5ecc3fd46d99481 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Apr 2019 06:20:18 +0200 Subject: [PATCH 121/129] Back to original check_process values --- check_process | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index e337f1e..0031fac 100644 --- a/check_process +++ b/check_process @@ -9,14 +9,14 @@ setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=1 - setup_public=1 + setup_private=0 + setup_public=0 upgrade=1 backup_restore=1 - multi_instance=1 + multi_instance=0 incorrect_path=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Levels Level 1=auto Level 2=auto From d24dccd332e085c49bd16d092bebf66287d5426b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 04:14:24 +0200 Subject: [PATCH 122/129] Fix ynh_add_secure_repos_2 --- scripts/ynh_add_secure_repos__2 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/ynh_add_secure_repos__2 b/scripts/ynh_add_secure_repos__2 index 7db7843..1e046ea 100644 --- a/scripts/ynh_add_secure_repos__2 +++ b/scripts/ynh_add_secure_repos__2 @@ -137,13 +137,7 @@ ynh_install_extra_repo () { if [ -n "$key" ] then mkdir -p "/etc/apt/trusted.gpg.d" - if [[ "$(basename "$key")" =~ ".asc" ]] - then - local key_ext=asc - else - local key_ext=gpg - fi - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.$key_ext > /dev/null + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null fi # Update the list of package with the new repo From 271a88b3f3494bf6910363ada845ad824295fc1d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 04:14:37 +0200 Subject: [PATCH 123/129] force using nodejs 8 --- conf/mastodon-streaming.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index 689d482..5f66236 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="NODE_ENV=production" Environment="PORT=__PORT_STREAM__" - ExecStart=/usr/bin/npm run start + ExecStart=/opt/node_n/n/versions/node/8/bin/npm run start TimeoutSec=15 Restart=always StandardError=syslog From bf9a8b1063ae3bcd8e96a2dd14dfb22a5af4bcfe Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Apr 2019 16:08:48 +0200 Subject: [PATCH 124/129] Additional * Implement ynh_systemd_action * Implement ynh_add_secure_repos__3 --- check_process | 4 +- conf/mastodon-sidekiq.service | 5 +- conf/mastodon-streaming.service | 4 +- conf/mastodon-web.service | 1 + conf/nginx.conf | 55 ++++-- manifest.json | 2 +- scripts/_common.sh | 15 -- scripts/backup | 24 +-- scripts/change_url | 18 +- scripts/install | 24 ++- scripts/remove | 5 +- scripts/restore | 31 ++-- scripts/upgrade | 25 +-- scripts/ynh_add_secure_repos__2 | 167 ------------------ scripts/ynh_add_secure_repos__3 | 294 ++++++++++++++++++++++++++++++++ scripts/ynh_systemd_action | 89 ++++++++++ 16 files changed, 505 insertions(+), 258 deletions(-) delete mode 100644 scripts/ynh_add_secure_repos__2 create mode 100644 scripts/ynh_add_secure_repos__3 create mode 100644 scripts/ynh_systemd_action diff --git a/check_process b/check_process index 0031fac..e44d632 100644 --- a/check_process +++ b/check_process @@ -10,10 +10,10 @@ setup_root=1 setup_nourl=0 setup_private=0 - setup_public=0 + setup_public=1 upgrade=1 backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=1 port_already_use=0 change_url=0 diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index 59f636f..920fcf4 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -7,8 +7,9 @@ User=__APP__ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" - Environment="DB_POOL=20" - ExecStart=/opt/rbenv/versions/2.6.0/bin/bundle exec sidekiq -c 20 -q default -q mailers -q pull -q push + Environment="DB_POOL=25" + Environment="MALLOC_ARENA_MAX=2" + ExecStart=/opt/rbenv/versions/2.6.0/bin/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index 5f66236..2e130d5 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -8,7 +8,9 @@ WorkingDirectory=__FINALPATH__/live Environment="NODE_ENV=production" Environment="PORT=__PORT_STREAM__" - ExecStart=/opt/node_n/n/versions/node/8/bin/npm run start + Environment="STREAMING_CLUSTER_NUM=1" + Environment=PATH=__NODEJS_PATH__ + ExecStart=__NODEJS_PATH__/node ./streaming TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 32af850..c95ba7f 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -9,6 +9,7 @@ Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" ExecStart=/opt/rbenv/versions/2.6.0/bin/bundle exec puma -C config/puma.rb + ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/nginx.conf b/conf/nginx.conf index a183a31..190c650 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -10,31 +10,48 @@ location / { rewrite ^ https://$server_name$request_uri? permanent; } + proxy_set_header Accept-Encoding ""; try_files $uri @proxy; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } -# add to v1.4 assets -location ~ ^/(assets|system/media_attachments/files|system/accounts/avatars) { +location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) { add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Strict-Transport-Security "max-age=31536000"; try_files $uri @proxy; - } +} + +location /sw.js { + add_header Cache-Control "public, max-age=0"; + add_header Strict-Transport-Security "max-age=31536000"; + try_files $uri @proxy; +} location @proxy { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - proxy_pass_header Server; - proxy_pass http://127.0.0.1:__PORT_WEB__; - proxy_buffering off; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - tcp_nodelay on; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + proxy_pass_header Server; + + proxy_pass http://127.0.0.1:3000; + proxy_buffering on; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + #proxy_cache CACHE; + proxy_cache_valid 200 7d; + proxy_cache_valid 410 24h; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + add_header X-Cached $upstream_cache_status; + add_header Strict-Transport-Security "max-age=31536000"; + + tcp_nodelay on; } location /api/v1/streaming { @@ -42,11 +59,17 @@ location /api/v1/streaming { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://127.0.0.1:__PORT_STREAM__; + proxy_set_header Proxy ""; + + proxy_pass http://127.0.0.1:4000; proxy_buffering off; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; + tcp_nodelay on; } + + +error_page 500 501 502 503 504 /500.html; \ No newline at end of file diff --git a/manifest.json b/manifest.json index 1d1789e..fd70341 100644 --- a/manifest.json +++ b/manifest.json @@ -16,7 +16,7 @@ "requirements": { "yunohost": ">= 3.4" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/_common.sh b/scripts/_common.sh index d0c5b58..79dc04c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,21 +20,6 @@ pkg_dependencies="imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-t # FUTURE OFFICIAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local user=$1 - shift 1 - - if [[ $user = $(whoami) ]]; then - eval "$@" - else - sudo --login --user="$user" "$@" - fi -} - - - # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/backup b/scripts/backup index c5a4702..58b29a7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -8,12 +8,16 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_systemd_action source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -31,12 +35,11 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # STOP MASTODON SERVICES #================================================= -ynh_print_info "Stopping Mastodon Services..." - -yunohost service stop "$app-web" -yunohost service stop "$app-sidekiq" -yunohost service stop "$app-streaming" +ynh_print_info "Stopping Mastodon services..." +ynh_systemd_action --action=stop --service_name=${app}-web --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-sidekiq --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-streaming --line_match="Stopped" --log_path=systemd #================================================= # STANDARD BACKUP STEPS @@ -81,14 +84,11 @@ ynh_backup "/etc/cron.d/$app" #================================================= # START MASTODON SERVICES #================================================= -ynh_print_info "Starting Mastodon Services..." +ynh_print_info "Starting Mastodon services..." -yunohost service start "$app-web" -yunohost service start "$app-sidekiq" -yunohost service start "$app-streaming" - -# Waiting start all services -sleep 30 +ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 51d37d6..525ecc9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -97,27 +98,24 @@ fi #================================================= ynh_print_info "Stopping Mastodon services..." -yunohost service stop "$app-web" -yunohost service stop "$app-sidekiq" -yunohost service stop "$app-streaming" +ynh_systemd_action --action=stop --service_name=${app}-web --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-sidekiq --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-streaming --line_match="Stopped" --log_path=systemd #================================================= # CHANGE CONFIGURATION #================================================= -ynh_replace_string "LOCAL_DOMAIN=*" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" -ynh_replace_string "SMTP_FROM_ADDRESS=*" "SMTP_FROM_ADDRESS=$admin_mail" "${final_path}/live/.env.production" +ynh_replace_string "LOCAL_DOMAIN=.*" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" #================================================= # START MASTODON SERVICES #================================================= ynh_print_info "Starting Mastodon services..." -yunohost service start "$app-web" -yunohost service start "$app-sidekiq" -yunohost service start "$app-streaming" - -sleep 30 +ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 4814306..e62b078 100644 --- a/scripts/install +++ b/scripts/install @@ -7,14 +7,18 @@ #================================================= source _common.sh -source /usr/share/yunohost/helpers source ynh_install_ruby -source ynh_add_secure_repos__2 +source ynh_add_secure_repos__3 +source ynh_systemd_action +source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -78,8 +82,6 @@ ynh_app_setting_set $app port_stream $port_stream #================================================= ynh_print_info "Installing dependencies..." -# TODO: add in a clean way backports and yarn - # Import debian archive pubkey, need on ARM arch arch=$(uname -m) if [[ "$arch" = arm* ]]; then @@ -96,7 +98,6 @@ ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" - # install nodejs ynh_install_nodejs 8 -# TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -149,7 +150,6 @@ ynh_system_user_create $app $final_path #================================================= ynh_install_ruby --ruby_version=2.6.0 - /opt/rbenv/versions/2.6.0/bin/gem update --system #/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document @@ -214,7 +214,7 @@ ynh_secure_remove "$final_path/live/key.txt" #================================================= # SETUP CRON JOB FOR REMOVING CACHE #================================================= -ynh_print_info "Setuping a cron job for remiving cache..." +ynh_print_info "Setuping a cron job for rem0ving cache..." ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron ynh_replace_string "__USER__" "$app" ../conf/cron @@ -228,11 +228,19 @@ ynh_print_info "Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/mastodon-streaming.service" ynh_add_systemd_config "$app-web" "mastodon-web.service" ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" -systemctl start "$app-web.service" "$app-sidekiq.service" "$app-streaming.service" +#================================================= +# START MASTODON SERVICES +#================================================= +ynh_print_info "Starting Mastodon services..." + +ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd #================================================= # STORE THE CONFIG FILE CHECKSUM diff --git a/scripts/remove b/scripts/remove index 1690fdb..18cb655 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,9 +7,9 @@ #================================================= source _common.sh -source /usr/share/yunohost/helpers source ynh_install_ruby -source ynh_add_secure_repos__2 +source ynh_add_secure_repos__3 +source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS @@ -77,7 +77,6 @@ ynh_print_info "Removing dependencies" ynh_remove_ruby ynh_remove_app_dependencies ynh_remove_nodejs - ynh_remove_extra_repo #================================================= diff --git a/scripts/restore b/scripts/restore index bfe6fbb..6e39fb5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,14 +8,18 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source /usr/share/yunohost/helpers source ../settings/scripts/ynh_install_ruby -source ../settings/scripts/ynh_add_secure_repos__2 +source ../settings/scripts/ynh_add_secure_repos__3 +source ../settings/scripts/ynh_systemd_action +source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -78,8 +82,6 @@ chown -R $app: $final_path #================================================= ynh_print_info "Reinstalling dependencies..." -# TODO: add in a clean way backports and yarn - # Import debian archive pubkey, need on ARM arch arch=$(uname -m) if [[ "$arch" = arm* ]]; then @@ -96,12 +98,13 @@ ynh_install_extra_repo --repo="deb https://dl.yarnpkg.com/debian/ stable main" - # install nodejs ynh_install_nodejs 8 -# TODO: use the same mecanism with other files ynh_install_app_dependencies $pkg_dependencies +#================================================= +# INSTALLING RUBY AND BUNDLER +#================================================= ynh_install_ruby --ruby_version=2.6.0 - /opt/rbenv/versions/2.6.0/bin/gem update --system #================================================= @@ -144,13 +147,19 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND SERVICES +# START MASTODON SERVICES #================================================= -ynh_print_info "Reloading nginx web server and services..." +ynh_print_info "Starting Mastodon services..." + +ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd + +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." -systemctl restart "$app-web" "$app-sidekiq" "$app-streaming" -# Waiting start all services -sleep 30 systemctl reload nginx #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 266eae8..b90dddd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,9 +7,10 @@ #================================================= source _common.sh -source /usr/share/yunohost/helpers source ynh_install_ruby -source ynh_add_secure_repos__2 +source ynh_add_secure_repos__3 +source ynh_systemd_action +source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS @@ -104,6 +105,7 @@ ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -124,9 +126,9 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= ynh_print_info "Stopping Mastodon services..." -yunohost service stop "$app-web" -yunohost service stop "$app-sidekiq" -yunohost service stop "$app-streaming" +ynh_systemd_action --action=stop --service_name=${app}-web --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-sidekiq --line_match="Stopped" --log_path=systemd +ynh_systemd_action --action=stop --service_name=${app}-streaming --line_match="Stopped" --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -259,16 +261,19 @@ ynh_print_info "Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/mastodon-streaming.service" ynh_add_systemd_config "$app-web" "mastodon-web.service" ynh_add_systemd_config "$app-sidekiq" "mastodon-sidekiq.service" ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service" -yunohost service start "$app-web" -yunohost service start "$app-sidekiq" -yunohost service start "$app-streaming" +#================================================= +# START MASTODON SERVICES +#================================================= +ynh_print_info "Starting Mastodon services..." -# Waiting start all services -sleep 30 +ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd +ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd #================================================= # GENERIC FINALIZATION diff --git a/scripts/ynh_add_secure_repos__2 b/scripts/ynh_add_secure_repos__2 deleted file mode 100644 index 1e046ea..0000000 --- a/scripts/ynh_add_secure_repos__2 +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/bash - -# Pin a repository. -# -# usage: ynh_pin_repo --package=packages --pin=pin_filter --priority=priority_value [--name=name] [--append] -# | arg: -p, --package - Packages concerned by the pin. Or all, *. -# | arg: -i, --pin - Filter for the pin. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. -# -ynh_pin_repo () { - # Declare an array to define the options of this helper. - local legacy_args=pirna - declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) - local package - local pin - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package="${package:-*}" - priority=${priority:-50} - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/preferences.d" - echo "Package: $package -Pin: $pin -Pin-Priority: $priority" \ - | $append "/etc/apt/preferences.d/$name" -} - -# Add a repository. -# -# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] -# | arg: -u, --uri - Uri of the repository. -# | arg: -s, --suite - Suite of the repository. -# | arg: -c, --component - Component of the repository. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable -# uri suite component -# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable -# -ynh_add_repo () { - # Declare an array to define the options of this helper. - local legacy_args=uscna - declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) - local uri - local suite - local component - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/sources.list.d" - # Add the new repo in sources.list.d - echo "deb $uri $suite $component" \ - | $append "/etc/apt/sources.list.d/$name.list" -} - -# Add an extra repository correctly, pin it and get the key. -# -# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--name=name] [--append] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -k, --key - url to get the public key. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -ynh_install_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=rkna - declare -Ar args_array=( [r]=repo= [k]=key= [n]=name= [a]=append ) - local repo - local key - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - key=${key:-0} - - if [ $append -eq 1 ] - then - append="--append" - wget_append="tee -a" - else - append="" - wget_append="tee" - fi - - # Split the repository into uri, suite and components. - # Remove "deb " at the beginning of the repo. - repo="${repo#deb }" - - # Get the uri - local uri="$(echo "$repo" | awk '{ print $1 }')" - - # Get the suite - local suite="$(echo "$repo" | awk '{ print $2 }')" - - # Get the components - local component="${repo##$uri $suite }" - - # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append - - # Pin the new repo with the default priority, so it won't be used for upgrades. - # Build $pin from the uri without http and any sub path - local pin="${uri#*://}" - pin="${pin%%/*}" - ynh_pin_repo --package="*" --pin="origin \"$pin\"" --name="$name" $append - - # Get the public key for the repo - if [ -n "$key" ] - then - mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null - fi - - # Update the list of package with the new repo - ynh_package_update -} - -# Remove an extra repository and the assiociated configuration. -# -# usage: ynh_remove_extra_repo [--name=name] -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_remove_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=n - declare -Ar args_array=( [n]=name= ) - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - - ynh_secure_remove "/etc/apt/sources.list.d/$name.list" - ynh_secure_remove "/etc/apt/preferences.d/$name" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" - - # Update the list of package to exclude the old repo - ynh_package_update -} diff --git a/scripts/ynh_add_secure_repos__3 b/scripts/ynh_add_secure_repos__3 new file mode 100644 index 0000000..3276f00 --- /dev/null +++ b/scripts/ynh_add_secure_repos__3 @@ -0,0 +1,294 @@ +#!/bin/bash + +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) + local repo + local key + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + # Set a priority only if asked + if [ -n "$priority" ] + then + priority="--priority=$priority" + fi + ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" + + # Update the list of package to exclude the old repo + ynh_package_update +} + +# Install packages from an extra repository properly. +# +# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -p, --package - The packages to install from this extra repository +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) + local repo + local package + local key + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + key=${key:-0} + + # Set a key only if asked + if [ -n "$key" ] + then + key="--key=$key" + fi + # Add an extra repository for those packages + ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + + # Install requested dependencies from this extra repository. + ynh_add_app_dependencies --package="$package" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=$app +} + +#================================================= + +# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies + +# Define and install dependencies with a equivs control file +# This helper can/should only be called once per app +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence +# You can give a choice between some package with this syntax : "dep1|dep2" +# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + dependencies=${dependencies//|/ | } + local manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + + local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. + if [ ${#version} -eq 0 ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]] + then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: package>=1.0 will be replaced by package (>= 1.0) + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build +Section: misc +Priority: optional +Package: ${dep_app}-ynh-deps +Version: ${version} +Depends: ${dependencies} +Architecture: all +Description: Fake package for $app (YunoHost app) dependencies + This meta-package is only responsible of installing its dependencies. +EOF + ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies + rm /tmp/${dep_app}-ynh-deps.control + ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" +} + +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + declare -Ar args_array=( [p]=package= [r]=replace) + local package + local replace + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + replace=${replace:-0} + + local current_dependencies="" + if [ $replace -eq 0 ] + then + local dep_app=${app//_/-} # Replace all '_' by '-' + if ynh_package_is_installed --package="${dep_app}-ynh-deps" + then + current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + fi + + current_dependencies=${current_dependencies// | /|} + fi + + ynh_install_app_dependencies "${current_dependencies}${package}" +} diff --git a/scripts/ynh_systemd_action b/scripts/ynh_systemd_action new file mode 100644 index 0000000..6bed6be --- /dev/null +++ b/scripts/ynh_systemd_action @@ -0,0 +1,89 @@ +#!/bin/bash + +# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started +# +# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] +# | arg: -n, --service_name= - Name of the service to reload. Default : $app +# | arg: -a, --action= - Action to perform with systemctl. Default: start +# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. +# If not defined it don't wait until the service is completely started. +# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log +# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. +# | arg: -e, --length= - Length of the error log : Default : 20 +ynh_systemd_action() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) + local service_name + local action + local line_match + local length + local log_path + local timeout + + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + local service_name="${service_name:-$app}" + local action=${action:-start} + local log_path="${log_path:-/var/log/$service_name/$service_name.log}" + local length=${length:-20} + local timeout=${timeout:-300} + + # Start to read the log + if [[ -n "${line_match:-}" ]] + then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ] ; then + # Read the systemd journal + journalctl -u $service_name -f --since=-45 > "$templog" & + else + # Read the specified log file + tail -F -n0 "$log_path" > "$templog" & + fi + # Get the PID of the tail command + local pid_tail=$! + fi + + echo "${action^} the service $service_name" >&2 + systemctl $action $service_name \ + || ( journalctl --lines=$length -u $service_name >&2 \ + ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ + ; false ) + + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]] + then + local i=0 + for i in $(seq 1 $timeout) + do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --quiet "$line_match" "$templog" + then + echo "The service $service_name has correctly started." >&2 + break + fi + echo -n "." >&2 + sleep 1 + done + if [ $i -eq $timeout ] + then + echo "The service $service_name didn't fully started before the timeout." >&2 + journalctl --lines=$length -u $service_name >&2 + test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 + fi + + echo "" + ynh_clean_check_starting + fi +} + +# Clean temporary process and file used by ynh_check_starting +# (usually used in ynh_clean_setup scripts) +# +# usage: ynh_clean_check_starting +ynh_clean_check_starting () { + # Stop the execution of tail. + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 +} From df2e2fb226a6b08f70dfdaff32abde1338d1a292 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 19:38:54 +0200 Subject: [PATCH 125/129] remove old badges --- README.md | 7 ------- README_fr.md | 7 ------- 2 files changed, 14 deletions(-) diff --git a/README.md b/README.md index 4993a83..f50442a 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,6 @@ > *This package allow you to install mastodon quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* -[![Latest Version](https://img.shields.io/badge/version-2.7.1-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.7.12_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) -[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues) - :warning: UPDATE 05/06/17 :This app can work now on ARM, but installation takes several hours and you must add a swapfile of 1GB. :warning: This application uses the Debian backports packages, do not install this application directly in production diff --git a/README_fr.md b/README_fr.md index 5fa9b89..6ee9aba 100644 --- a/README_fr.md +++ b/README_fr.md @@ -8,13 +8,6 @@ > *Ce package vous permet d'installer mastodon rapidement et simplement sur un serveur Yunohost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* -[![Latest Version](https://img.shields.io/badge/version-2.7.1-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.7.12_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) -[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues) - :warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. :warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production From 5e9e9ac4e43cad177181f538aef9f2d0010be42c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 02:30:36 +0200 Subject: [PATCH 126/129] Fix postgresql database removal error in new ynh_psql_remove_db db_name and db_user have been inverted in legacy mode --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 18cb655..303ccf7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -66,7 +66,7 @@ ynh_psql_execute_as_root "\connect $db_name SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" # delete postgresql database & user -ynh_psql_remove_db "$db_name" "$app" +ynh_psql_remove_db --db_name="$db_name" --db_user="$app" #================================================= # REMOVE DEPENDENCIES From ea966973f58b2cd991335c6bc7e7eaec07e7fabc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 03:15:40 +0200 Subject: [PATCH 127/129] Revert "Merge pull request #3 from alexAubin/patch-1" This reverts commit 90a03313093f3e9eecf10115e1b6fddc3cb7ea89, reversing changes made to df2e2fb226a6b08f70dfdaff32abde1338d1a292. --- scripts/install | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/install b/scripts/install index f68c97d..e62b078 100644 --- a/scripts/install +++ b/scripts/install @@ -44,13 +44,6 @@ ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# TODO : to be factorized into a helper someday ? ;) -MEM=$(free | grep "^Mem" | awk '{print $2}') -SWAP=$(free | grep "^Swap" | awk '{print $2}') -TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB - -[[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap." - # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) From 8b342cce12664d760615743f8fb795076c5b825f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 13:51:19 +0200 Subject: [PATCH 128/129] Revert "Revert "Merge pull request #3 from alexAubin/patch-1"" This reverts commit ea966973f58b2cd991335c6bc7e7eaec07e7fabc. --- scripts/install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index e62b078..f68c97d 100644 --- a/scripts/install +++ b/scripts/install @@ -44,6 +44,13 @@ ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" +# TODO : to be factorized into a helper someday ? ;) +MEM=$(free | grep "^Mem" | awk '{print $2}') +SWAP=$(free | grep "^Swap" | awk '{print $2}') +TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB + +[[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap." + # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) From 0494ace9aff9eaa8395bc0187f140c0eb975e645 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 13:54:10 +0200 Subject: [PATCH 129/129] Update install --- scripts/install | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index f68c97d..c05feee 100644 --- a/scripts/install +++ b/scripts/install @@ -44,13 +44,16 @@ ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# TODO : to be factorized into a helper someday ? ;) -MEM=$(free | grep "^Mem" | awk '{print $2}') -SWAP=$(free | grep "^Swap" | awk '{print $2}') -TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB +if [ "$admin" != "package_checker" ] +then + # TODO : to be factorized into a helper someday ? ;) + MEM=$(free | grep "^Mem" | awk '{print $2}') + SWAP=$(free | grep "^Swap" | awk '{print $2}') + TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB -[[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap." + [[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap." +fi # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url)