mirror of
https://github.com/YunoHost-Apps/diaspora_ynh.git
synced 2024-09-03 18:26:13 +02:00
Apply last example_ynh
This commit is contained in:
parent
f620f2571e
commit
077e18d742
22 changed files with 858 additions and 1741 deletions
|
@ -1,25 +1,23 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
admin_password="pass"
|
||||
domain="domain.tld"
|
||||
admin="john"
|
||||
password="1Strong-Password"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0 # not supported upstream
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=0.7.16.0-ynh1
|
||||
upgrade=1 from_commit=0.7.16.0-ynh1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
change_url=0 # not supported upstream
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
|
||||
|
|
7
conf/app.src
Normal file
7
conf/app.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://github.com/diaspora/diaspora/archive/refs/tags/v0.7.17.0.tar.gz
|
||||
SOURCE_SUM=d54f339c1f8da70a87e11240d07dab2645a5ffefa6dc2daf0cf893f84aef0564
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
|
@ -2,8 +2,8 @@ postgresql: &postgresql
|
|||
adapter: postgresql
|
||||
host: "localhost"
|
||||
port: 5432
|
||||
username: "{{ app }}"
|
||||
password: "{{ db_pass }}"
|
||||
username: "__DB_USER__"
|
||||
password: "__DB_PWD__"
|
||||
encoding: unicode
|
||||
|
||||
mysql: &mysql
|
||||
|
@ -42,7 +42,7 @@ development:
|
|||
database: diaspora_development
|
||||
production:
|
||||
<<: *combined
|
||||
database: {{ app }}
|
||||
database: __DB_NAME__
|
||||
test:
|
||||
<<: *combined
|
||||
database: diaspora_test
|
||||
|
|
|
@ -36,7 +36,7 @@ configuration: ## Section
|
|||
## However changing http to https is okay and has no consequences.
|
||||
## If you do change the URL, you will have to start again as the URL
|
||||
## will be hardcoded into the database.
|
||||
url: "https://{{ domain }}"
|
||||
url: "https://__DOMAIN__"
|
||||
|
||||
## Set the bundle of certificate authorities (CA) certificates.
|
||||
## This is specific to your operating system.
|
||||
|
@ -176,10 +176,10 @@ configuration: ## Section
|
|||
#listen: 'unix:tmp/diaspora.sock'
|
||||
#listen: 'unix:/run/diaspora/diaspora.sock'
|
||||
#listen: '127.0.0.1:3000'
|
||||
listen: unix:/run/{{ app }}/diaspora.sock
|
||||
listen: unix:/run/__APP__/diaspora.sock
|
||||
|
||||
## Set the path for the PID file of the unicorn master process (default=tmp/pids/web.pid)
|
||||
pid: '/run/{{ app }}/diaspora.pid'
|
||||
pid: '/run/__APP__/diaspora.pid'
|
||||
|
||||
## Rails environment (default='development').
|
||||
## The environment in which the server should be started by default.
|
||||
|
@ -553,7 +553,7 @@ configuration: ## Section
|
|||
enable: true
|
||||
|
||||
## Sender address used in mail sent by Diaspora.
|
||||
sender_address: 'no-reply@{{ domain }}'
|
||||
sender_address: 'no-reply@__DOMAIN__'
|
||||
|
||||
## This selects which mailer should be used. Use 'smtp' for a smtp
|
||||
## connection or 'sendmail' to use the sendmail binary.
|
||||
|
@ -606,10 +606,10 @@ configuration: ## Section
|
|||
## This doesn't make the user an admin but is used when a generic
|
||||
## admin contact is needed, much like the postmaster role in mail
|
||||
## systems. Set only the username, NOT the full ID.
|
||||
account: "{{ admin }}"
|
||||
account: "__ADMIN__"
|
||||
|
||||
## E-mail address to contact the administrator.
|
||||
podmin_email: '{{ admin_email }}'
|
||||
podmin_email: '__ADMIN_MAIL__'
|
||||
|
||||
## Settings related to relays
|
||||
relay: ## Section
|
||||
|
|
|
@ -3,29 +3,32 @@ Description=Diaspora social network (sidekiq - instance __APP__)
|
|||
PartOf=__APP__.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Environment=RAILS_ENV=production
|
||||
WorkingDirectory=__FINALPATH__/diaspora
|
||||
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="__LD_PRELOAD__"
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||
ExecStart=__FINAL_PATH__/live/bin/bundle exec sidekiq
|
||||
Restart=always
|
||||
|
||||
# Sandboxing options to harden security
|
||||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
NoNewPrivileges=yes
|
||||
NoNewPrivileges=no
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
#PrivateDevices=yes
|
||||
#RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
||||
#RestrictNamespaces=yes
|
||||
#RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
ProtectSystem=full
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
#ProtectKernelModules=yes
|
||||
#ProtectKernelTunables=yes
|
||||
#LockPersonality=yes
|
||||
#SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
# Denying access to capabilities that should not be relevant for webapps
|
||||
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
|
||||
|
|
|
@ -3,11 +3,14 @@ Description=Diaspora social network (unicorn - instance __APP__)
|
|||
PartOf=__APP__.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Environment=RAILS_ENV=production
|
||||
WorkingDirectory=__FINALPATH__/diaspora
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="__LD_PRELOAD__"
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||
PIDFile=/run/__APP__/diaspora.pid
|
||||
ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
|
||||
ExecStart=__FINAL_PATH__/live/bin/bundle exec unicorn -c config/unicorn.rb -E production
|
||||
ExecReload=/bin/kill -USR2 $MAINPID
|
||||
Restart=always
|
||||
|
||||
|
@ -18,7 +21,7 @@ Restart=always
|
|||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
|
@ -41,6 +44,5 @@ CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
|
|||
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
|
||||
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=__APP__.target
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,8 @@
|
|||
# Proxy if requested file not found
|
||||
location / {
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
root __FINALPATH__/diaspora/public;
|
||||
# Path to source
|
||||
alias __FINALPATH__/live/public/ ;
|
||||
|
||||
# Configure maximum picture size
|
||||
# Note that Diaspora has a client side check set at 4M
|
||||
|
@ -11,12 +12,12 @@ location / {
|
|||
# Proxy if requested file not found
|
||||
try_files $uri @diaspora;
|
||||
|
||||
location /assets/ {
|
||||
location __PATH__/assets/ {
|
||||
expires max;
|
||||
more_set_headers 'Cache-Control: public';
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBFglzSYBEADfGIe+NZMt2ymkKz6QvgG7Kwu54s5E/rikRNRKviysO7O3NWC8
|
||||
P6FQ80kf4s1OhMF+//xnQTXiqFyjCFqftbEM2ApK9YHTUoVFF8I6Ed3uRxP9H3fO
|
||||
dkn3nkvWjSUNo35DkBpGtV6XcMRqHbjGWtjahfrYuqa4oh4ZbY3i3kxUIWTKar+U
|
||||
k7FEigw2znfRjgDT1aX9gLfq2z7GzBwO73HcX4oDJ2Q+T2g/IJ5SusUF2SoEUEUE
|
||||
+phi9h3JGJ/AxX9/rRPJHWeluPKOdkhmFe/Qb+gote82LUlZx5R6XwfifByVqeNf
|
||||
CQY9vQlRa/pNZ23QFmDFc35M6HLI3YwFkSlsJ9BWWuHe+y+/SVg6c85U0Hg4f1nY
|
||||
+a4l7W1BeXlroritweWGZ2kvaAfDYXvjMRFe9v+sOn/eJ585glGHMhcGVAa00AR0
|
||||
5qPHOaz6FURwnlVOXBswTD6c0foLcxPcB/sUqCCB0T1/kxtDZUDHgnNQofeisTYN
|
||||
vpVN/aXAACzkVthvG1E84IQD5mVh69fedNhdYzvyF1Zd54XZC2fr3ZNbL/1vpA+7
|
||||
nl+mf4ZcaGToTwEuovAzdR8eVymu5+yCBmpojWgn+VNz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gMkqI75CXLuKwPJoqGZ8MOMvr
|
||||
AiD8zJxEHqYE7QnreiDS1/WTHh7nLkA/+ISmVWiLRa3qhmMqi35Z/4Ev2nPBZ4M2
|
||||
ToDdydSnuEhSC3rlyJ9Du724UsKBBoH/LiRp4yMv6Y7b4lH4orONriEjjb1X3Ln3
|
||||
Dcp83Zho3ANvhjWz2lL4XRzCLnUdYwV56872vH3AeSAvjfgbf5oYlLhXgMUXsNF/
|
||||
2YBn1UOcqwKgmOGl8capSPz2+q/sGjYLIMQ6pA5XKHrI8FjdON2AYxrSRb8RBBAW
|
||||
hFvJNrAwzAqorolYtNkAfXgU0kayY9SXElQBsNnU/9EcW6/eqfZPWzHgTRXV6yvC
|
||||
OAygYHVwad62iQMzFGSamQYcinnwZccRuRNRCYHzIjB9tCOMe2qa5pjPeYMTk8vK
|
||||
9yrYeRzBeQFMQXQgRZV8GcN8E/qBBc85qGZWRw8XeXpqBo08teH81jnjbbw+uZrl
|
||||
ItFD89SDex93x3lKKaBo31AAqmYx5hOEG4q2cOh33kB9WOozqLf0UjUQOyBpN+Cu
|
||||
/PK2WJKMqBfFjpef34eIMVOzhxp/oQ4xVQD+H27ExayutgIvExrFBeRU1RxhwRAW
|
||||
fiC0aDWzK4QuWnmZG1oSv7hLIMChvUM39Oo/Jz1BYTVfCRWMQZeX/ncaZCSBM/MM
|
||||
iWTuv7mXY0bNG+s=
|
||||
=SF+D
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
0
doc/DESCRIPTION.md
Normal file
0
doc/DESCRIPTION.md
Normal file
0
doc/DESCRIPTION_fr.md
Normal file
0
doc/DESCRIPTION_fr.md
Normal file
|
@ -25,11 +25,10 @@
|
|||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"postgresql"
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain"
|
||||
|
@ -39,7 +38,7 @@
|
|||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "admin_password",
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Admin password. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').",
|
||||
|
|
|
@ -1,5 +1,47 @@
|
|||
#!/bin/bash
|
||||
pkg_dependencies="build-essential cmake libssl-dev libcurl4-dev libxml2-dev libxslt-dev imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server postgresql bison "
|
||||
ruby_build_dependencies="bison libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev libjemalloc-dev"
|
||||
|
||||
current_tag="v0.7.17.0"
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="cmake imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server postgresql"
|
||||
build_pkg_dependencies="libffi-dev libgdbm-dev libncurses5-dev libyaml-dev pkg-config sqlite3 libgmp-dev libssl-dev"
|
||||
|
||||
ruby_version=2.6.6
|
||||
nodejs_version=14
|
||||
bundler_version=1.17.3
|
||||
|
||||
# Workaround for Mastodon on Bullseye
|
||||
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
|
||||
if [ "$(lsb_release --codename --short)" = "bullseye" ]; then
|
||||
case $YNH_ARCH in
|
||||
amd64)
|
||||
arch="x86_64"
|
||||
;;
|
||||
arm64)
|
||||
arch="aarch64"
|
||||
;;
|
||||
armel|armhf)
|
||||
arch="arm"
|
||||
;;
|
||||
i386)
|
||||
arch="i386"
|
||||
;;
|
||||
esac
|
||||
ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so"
|
||||
else
|
||||
ld_preload=""
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -6,12 +6,17 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -23,42 +28,44 @@ ynh_print_info --message="Loading installation settings..."
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
# clean folder
|
||||
ynh_secure_remove --file="$final_path/backup"
|
||||
mkdir -p $final_path/backup
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP DIASPORA DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backup Diaspora DB..."
|
||||
|
||||
db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
dump_file="$final_path/backup/$app.dump"
|
||||
pg_dump -d "dbname=$app user=$app password=$db_pass host=localhost" -Fc -f $dump_file
|
||||
ynh_backup --src_path="$dump_file"
|
||||
|
||||
#=================================================
|
||||
# BACKUP DIASPORA UPLOADS
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
if [ -x $final_path/diaspora/public/uploads ]; then
|
||||
ynh_backup --src_path="$final_path/diaspora/public/uploads"
|
||||
else
|
||||
echo "uploads folder does not exist. Skipping."
|
||||
fi
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP CONF FILES
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path/diaspora/config/database.yml"
|
||||
ynh_backup --src_path="$final_path/diaspora/config/diaspora.yml"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app_web.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app_sidekiq.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
pushd $final_path/diaspora
|
||||
echo 2.6.6 > .ruby-version # overwrite 2.6 default from diaspora because rbenv does not understand it
|
||||
sudo -u $app --login << EOF
|
||||
gem install bundler:1.17.3
|
||||
cd diaspora
|
||||
script/configure_bundler
|
||||
bin/bundle install --full-index --with=postgresql
|
||||
EOF
|
||||
# for some reason rake logs a lot in stderr (tried --quiet, didn't change anything)
|
||||
# redirecting it to stdout to have a saner log on yunohost side
|
||||
sudo -u $app /bin/bash -l << EOF
|
||||
source /usr/share/yunohost/helpers
|
||||
ynh_use_nodejs
|
||||
cd diaspora
|
||||
RAILS_ENV=production bundle exec rake db:migrate 2>&1
|
||||
EOF
|
||||
|
||||
#=================================================
|
||||
# ASSETS PRECOMPILATION
|
||||
#=================================================
|
||||
|
||||
sudo -u $app /bin/bash << EOF
|
||||
source /usr/share/yunohost/helpers
|
||||
ynh_use_nodejs
|
||||
cd diaspora
|
||||
RAILS_ENV=production bin/rake assets:precompile 2>&1
|
||||
EOF
|
||||
popd
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#!/bin/bash
|
||||
# sidekiq
|
||||
echo $app $final_path
|
||||
install -T --mode=0644 -v ../conf/diaspora_sidekiq.service /etc/systemd/system/${app}_sidekiq.service
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/systemd/system/${app}_sidekiq.service
|
||||
ynh_replace_string --match_string=__FINALPATH__ --replace_string=$final_path --target_file=/etc/systemd/system/${app}_sidekiq.service
|
||||
# web
|
||||
install -T --mode=0644 -v ../conf/diaspora_web.service /etc/systemd/system/${app}_web.service
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/systemd/system/${app}_web.service
|
||||
ynh_replace_string --match_string=__FINALPATH__ --replace_string=$final_path --target_file=/etc/systemd/system/${app}_web.service
|
||||
# tmp files
|
||||
install -T --mode=0644 -v ../conf/diaspora.tmpfiles.d /etc/tmpfiles.d/${app}.conf
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/tmpfiles.d/${app}.conf
|
||||
# target unit
|
||||
install -T --mode=0644 -v ../conf/diaspora.target /etc/systemd/system/${app}.target
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/systemd/system/${app}.target
|
||||
# reload, create, enable and start stuff
|
||||
systemctl daemon-reload
|
||||
systemd-tmpfiles --create
|
||||
systemctl enable ${app}.target ${app}_sidekiq.service ${app}_web.service
|
||||
systemctl restart ${app}.target
|
||||
ynh_systemd_action --service_name=${app}_web.service \
|
||||
--action=restart\
|
||||
--log_path="$final_path/diaspora/log/production.log" \
|
||||
--line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name=${app}_sidekiq.service \
|
||||
--action=restart\
|
||||
--log_path="systemd" \
|
||||
--line_match="Running in ruby"
|
234
scripts/install
234
scripts/install
|
@ -1,16 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TODO
|
||||
# - which service to register to ynuhosto? diaspora.target only ? All of them ?
|
||||
# - a setting to enable / disable registration
|
||||
# - say something about the registration to https://the-federation.info/
|
||||
# - ...
|
||||
|
||||
## vars for remove script
|
||||
can_remove_db=0
|
||||
can_remove_home=0
|
||||
can_remove_user=0
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
@ -18,15 +7,17 @@ can_remove_user=0
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_clean_setup() {
|
||||
ynh_clean_check_starting
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
|
@ -34,158 +25,177 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url="/"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
admin_email=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
final_path=/var/www/$app
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
# check path availability
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
can_remove_home=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=/
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Saving app settings..." --weight=1
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=/
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies
|
||||
|
||||
#=================================================
|
||||
# CHECK DB AVAILABILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Check DB availability"
|
||||
# now that we have psql for sure, test db existence
|
||||
ynh_script_progression --message="Checking DB availability" --weight=1
|
||||
ynh_psql_database_exists --database $app && ynh_die --message="There is already a database: $app"
|
||||
can_remove_db=1
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating user..." --weight=1
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path --use_shell
|
||||
can_remove_user=1
|
||||
mkdir -p $final_path
|
||||
chmod 0750 $final_path -R
|
||||
chown $app:www-data $final_path
|
||||
|
||||
#=================================================
|
||||
# INSTALL RVM, RUBY AND NODE FOR CURRENT USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing rvm and ruby... (will take a long time)" --weight=20
|
||||
source ./install_ruby
|
||||
ynh_script_progression --message="Installing node" --weight=10
|
||||
ynh_install_nodejs --nodejs_version=14
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
# Download, check integrity, unucompress and patch the source from app.src
|
||||
pushd $final_path
|
||||
ynh_script_progression --message="Download the sources..." --weight=10
|
||||
ynh_exec_warn_less sudo -u $app git clone https://github.com/diaspora/diaspora.git -b $current_tag
|
||||
popd
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating database..." --weight=1
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_exec_warn_less ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
|
||||
db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
#=================================================
|
||||
# EXPORT VARIABLES FOR TEMPLATING
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
export app
|
||||
export domain
|
||||
export db_pass
|
||||
export final_path
|
||||
export admin
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE DIASPORA
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configure diaspora..." --weight=1
|
||||
ynh_render_template ../conf/diaspora.yml $final_path/diaspora/config/diaspora.yml
|
||||
ynh_render_template ../conf/database.yml $final_path/diaspora/config/database.yml
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||
#=================================================
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$final_path/diaspora/config/diaspora.yml"
|
||||
ynh_store_file_checksum --file="$final_path/diaspora/config/database.yml"
|
||||
|
||||
#=================================================
|
||||
# Bundle the ruby app
|
||||
#=================================================
|
||||
ynh_script_progression --message="Precompile assets (will take a long time)..." --weight=40
|
||||
source ./bundle_app
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
# Create a dedicated nginx config
|
||||
ynh_script_progression --message="configure nginx..." --weight=1
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
# Create a dedicated systemd config
|
||||
ynh_script_progression --message="configure systemd unit..." --weight=1
|
||||
source ./create_services
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/diaspora.yml" --destination="$final_path/live/config/diaspora.yml"
|
||||
ynh_add_config --template="../conf/database.yml" --destination="$final_path/live/config/database.yml"
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
yunohost service add $app.target \
|
||||
--log $final_path/diaspora/log/production.log \
|
||||
$final_path/diaspora/log/unicorn-stderr.log\
|
||||
$final_path/diaspora/log/unicorn-stdout.log\
|
||||
$final_path/diaspora/log/sidekiq.log\
|
||||
--description "Diaspora service (unicorn web and sidekiq)"
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_permission_update --permission "main" --add visitors
|
||||
|
||||
#=================================================
|
||||
# CREATE AN ADMIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Create admin..." --weight=1
|
||||
pushd $final_path/diaspora
|
||||
sudo -u $app /bin/bash --login << EOF
|
||||
RAILS_ENV=production bundle exec rails console << END
|
||||
user = User.build({username: '$admin', email: '$admin_email', password: '$admin_password', password_confirmation: '$admin_password' })
|
||||
pushd $final_path/live
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install bundler:$bundler_version
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload script/configure_bundler
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --full-index --with=postgresql
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate 2>&1
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/rake assets:precompile 2>&1
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails console << END
|
||||
user = User.build({username: '$admin', email: '$admin_mail', password: '$password', password_confirmation: '$password' })
|
||||
user.save
|
||||
user.seed_aspects
|
||||
Role.add_admin user.person
|
||||
END
|
||||
EOF
|
||||
popd
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_package_autoremove
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_add_systemd_config --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_add_systemd_config --service="${app}_web" --template="diaspora_web.service"
|
||||
|
||||
# tmp files
|
||||
install -T --mode=0644 -v ../conf/diaspora.tmpfiles.d /etc/tmpfiles.d/${app}.conf
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/tmpfiles.d/${app}.conf
|
||||
|
||||
# target unit
|
||||
install -T --mode=0644 -v ../conf/diaspora.target /etc/systemd/system/${app}.target
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/systemd/system/${app}.target
|
||||
|
||||
# reload, create, enable and start stuff
|
||||
systemctl daemon-reload
|
||||
systemd-tmpfiles --create
|
||||
systemctl enable ${app}.target --quiet
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app.target \
|
||||
--log $final_path/live/log/production.log \
|
||||
$final_path/live/log/unicorn-stderr.log\
|
||||
$final_path/live/log/unicorn-stdout.log\
|
||||
$final_path/live/log/sidekiq.log\
|
||||
--description "Diaspora service (unicorn web and sidekiq)"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
systemctl restart ${app}.target
|
||||
ynh_systemd_action --service_name=${app}_web.service --action=restart --log_path="$final_path/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name=${app}_sidekiq.service --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/bash
|
||||
# some stuff we don't care about really.
|
||||
# clone ynh_experimental helpers
|
||||
pushd $final_path
|
||||
if [ -x Experimental_helpers ]; then
|
||||
pushd Experimental_helpers
|
||||
ynh_exec_warn_less git fetch
|
||||
popd
|
||||
else
|
||||
ynh_exec_warn_less git clone https://github.com/YunoHost-Apps/Experimental_helpers.git
|
||||
fi
|
||||
pushd Experimental_helpers
|
||||
ynh_exec_warn_less git checkout d05b4db
|
||||
source ./ynh_install_ruby/ynh_install_ruby
|
||||
popd
|
||||
popd
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=2.6.6
|
||||
|
113
scripts/remove
113
scripts/remove
|
@ -7,105 +7,94 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
can_remove_db=${can_remove_db:=1}
|
||||
can_remove_home=${can_remov_home:=1}
|
||||
can_remove_user=${can_remove_user:=1}
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Load settings"
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
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=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app.target >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app.target service integration..."
|
||||
yunohost service remove $app.target
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove services"
|
||||
yunohost service remove $app.target
|
||||
systemctl stop ${app}.target ${app}_sidekiq.service ${app}_web.service
|
||||
systemctl disable ${app}.target ${app}_sidekiq.service ${app}_web.service --quiet
|
||||
ynh_secure_remove --file="/etc/systemd/system/${app}_web.service"
|
||||
ynh_secure_remove --file="/etc/systemd/system/${app}_sidekiq.service"
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
systemctl stop ${app}.target
|
||||
systemctl disable ${app}.target --quiet
|
||||
ynh_remove_systemd_config --service="$app_web"
|
||||
ynh_remove_systemd_config --service="$app_sidekiq"
|
||||
ynh_secure_remove --file="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_secure_remove --file="/etc/systemd/system/${app}.target"
|
||||
ynh_secure_remove --file="/run/${app}"
|
||||
systemctl daemon-reload
|
||||
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
if yunohost service status | grep -q $app
|
||||
then
|
||||
echo "Remove $app service"
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
if [ $can_remove_db -eq 1 ]; then
|
||||
ynh_script_progression --message="Remove database"
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db $db_name $db_name
|
||||
fi
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove app dependencies" --weight=10
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove nginx config"
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=10
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_ruby
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
if [ $can_remove_user -eq 1 ]; then
|
||||
ynh_script_progression --message="Remove $app user"
|
||||
# Delete a system user
|
||||
# because we use gpg, sometimes rogue processes (gpg an d dirmngr) stays a bit,
|
||||
# preventing the deletion of the user. Hence we kill all processes belonging to $app
|
||||
pkill -9 -u `id -u $app`
|
||||
ynh_system_user_delete $app
|
||||
fi
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# REMOVE RUBY
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove ruby (if this is the last app using it)"
|
||||
source $final_path/Experimental_helpers/ynh_install_ruby/ynh_install_ruby
|
||||
ynh_remove_ruby
|
||||
|
||||
#=================================================
|
||||
# REMOVE NODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove nodejs for this app"
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
if [ $can_remove_home -eq 1 ]; then
|
||||
ynh_script_progression --message="Remove $final_path"
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
|
|
174
scripts/restore
174
scripts/restore
|
@ -1,33 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
## vars for remove script
|
||||
can_remove_db=0
|
||||
can_remove_home=0
|
||||
can_remove_user=0
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# 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_install_ruby__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
pushd $(readlink -f ../settings/scripts)
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_clean_setup() {
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -43,103 +40,110 @@ ynh_script_progression --message="Validating restoration parameters..."
|
|||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
can_remove_home=1
|
||||
|
||||
#=================================================
|
||||
# Reinstall dependencies
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies
|
||||
|
||||
# now that we have psql for sure, test db existence
|
||||
ynh_script_progression --message="Checking DB availability" --weight=1
|
||||
ynh_psql_database_exists --database $app && ynh_die --message="There is already a database: $app"
|
||||
can_remove_db=1
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# Restoring dedicated USER
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user..." --weight=1
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path --use_shell
|
||||
can_remove_user=1
|
||||
mkdir -p $final_path
|
||||
chmod 0750 $final_path -R
|
||||
chown $app:www-data $final_path
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
|
||||
#=================================================
|
||||
# INSTALL RVM, RUBY AND NODE FOR CURRENT USER
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling rbenv and ruby..." --weight=10
|
||||
source ./install_ruby
|
||||
ynh_script_progression --message="Reinstalling node" --weight=10
|
||||
ynh_install_nodejs --nodejs_version=14
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
# Download, check integrity, unucompress and patch the source from app.src
|
||||
pushd $final_path
|
||||
ynh_script_progression --message="Download the sources..." --weight=5
|
||||
ynh_exec_warn_less sudo -u $app git clone https://github.com/diaspora/diaspora.git -b $current_tag
|
||||
pushd $final_path/live
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install bundler:$bundler_version
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload script/configure_bundler
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --full-index --with=postgresql
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# Restore files
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restore the files" --weight=5
|
||||
ynh_restore_file --origin_path=/var/www/diaspora/diaspora/config/database.yml
|
||||
ynh_restore_file --origin_path=/var/www/diaspora/diaspora/config/diaspora.yml
|
||||
ynh_restore_file --not_mandatory --origin_path=/var/www/diaspora/diaspora/public/uploads/
|
||||
# restoring somewhere postgres can read
|
||||
ynh_restore_file --origin_path=/var/www/diaspora/backup/diaspora.dump --dest_path=/tmp/diaspora.dump
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
||||
systemctl enable "$app_web" "$app_sidekiq" "$app.target" --quiet
|
||||
|
||||
#=================================================
|
||||
# Restore database
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating and restoring database..." --weight=5
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_psql_test_if_first_run
|
||||
db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pass
|
||||
ynh_script_progression --message="Restoring database..."
|
||||
sudo -u postgres pg_restore \
|
||||
--single-transaction \
|
||||
--dbname=$app \
|
||||
/tmp/diaspora.dump
|
||||
ynh_secure_remove --file=/tmp/diaspora.dump
|
||||
|
||||
#=================================================
|
||||
# Bundle the ruby app
|
||||
#=================================================
|
||||
ynh_script_progression --message="Precompile assets..." --weight=5
|
||||
source ./bundle_app
|
||||
|
||||
#=================================================
|
||||
# Restore nginx conf files
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreate nginx config from source"
|
||||
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# Restore services
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restore services..."
|
||||
|
||||
source ./create_services
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app.target \
|
||||
--log $final_path/diaspora/log/production.log \
|
||||
$final_path/diaspora/log/unicorn-stderr.log\
|
||||
$final_path/diaspora/log/unicorn-stdout.log\
|
||||
$final_path/diaspora/log/sidekiq.log\
|
||||
--log $final_path/live/log/production.log \
|
||||
$final_path/live/log/unicorn-stderr.log\
|
||||
$final_path/live/log/unicorn-stdout.log\
|
||||
$final_path/live/log/sidekiq.log\
|
||||
--description "Diaspora service (unicorn web and sidekiq)"
|
||||
|
||||
popd
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
systemctl restart ${app}.target
|
||||
ynh_systemd_action --service_name=${app}_web.service --action=restart --log_path="$final_path/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name=${app}_sidekiq.service --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
|
|
231
scripts/upgrade
231
scripts/upgrade
|
@ -6,8 +6,8 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -17,56 +17,53 @@ ynh_script_progression --message="Loading installation settings..."
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
admin=$(ynh_app_setting_get --app $app --key admin)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
ynh_clean_setup() {
|
||||
ynh_clean_check_starting
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="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
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# Migrate legacy permissions to new system
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
if ynh_legacy_permissions_exists
|
||||
then
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
systemctl stop $app.target
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# Check upgrade type
|
||||
#=================================================
|
||||
ynh_script_progression --message="Check upgrade type..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# Stop services
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stop services..."
|
||||
|
||||
systemctl stop $app.target
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies
|
||||
|
||||
#=================================================
|
||||
# INSTALL NODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Install node"
|
||||
ynh_install_nodejs --nodejs_version=14
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
# migrate from rvm to rbenv
|
||||
ynh_script_progression --message="Remove rvm if needed..."
|
||||
if [ -e "$final_path/.rvm" ]; then
|
||||
|
@ -74,8 +71,6 @@ if [ -e "$final_path/.rvm" ]; then
|
|||
rvm implode --force
|
||||
EOF
|
||||
fi
|
||||
ynh_script_progression --message="Install ruby"
|
||||
source ./install_ruby
|
||||
|
||||
# remove old gpg keys for rvm
|
||||
ynh_script_progression --message="Remove old rvm keys..."
|
||||
|
@ -90,47 +85,135 @@ if gpg --list-keys piotr.kuczynski@gmail.com >/dev/null 2>&1; then
|
|||
ynh_secure_remove "$final_path/piotr.kuczynski@gmail.com.pgp"
|
||||
fi
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ];
|
||||
then
|
||||
upgrade_message="Upgrading this app and upstream to $current_tag"
|
||||
else
|
||||
upgrade_message="Shallow upgrade of yunohost app"
|
||||
fi
|
||||
ynh_script_progression --message=$upgrade_message
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# revert local change to .ruby-version
|
||||
pushd $final_path/diaspora
|
||||
git checkout -- .ruby-version
|
||||
git fetch
|
||||
git checkout $current_tag
|
||||
popd
|
||||
source ./bundle_app
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
yunohost service add $app.target \
|
||||
--log $final_path/diaspora/log/production.log \
|
||||
$final_path/diaspora/log/unicorn-stderr.log\
|
||||
$final_path/diaspora/log/unicorn-stdout.log\
|
||||
$final_path/diaspora/log/sidekiq.log\
|
||||
--description "Diaspora service (unicorn web and sidekiq)"
|
||||
|
||||
#=================================================
|
||||
# restart services
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreate and start services..."
|
||||
|
||||
source ./create_services
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
# Create a dedicated nginx config
|
||||
ynh_script_progression --message="configure nginx..." --weight=1
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
|
||||
pushd $final_path/live
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install bundler:$bundler_version
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload script/configure_bundler
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --full-index --with=postgresql
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate 2>&1
|
||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/rake assets:precompile 2>&1
|
||||
popd
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_package_autoremove
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/diaspora.yml" --destination="$final_path/live/config/diaspora.yml"
|
||||
ynh_add_config --template="../conf/database.yml" --destination="$final_path/live/config/database.yml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
|
||||
ynh_add_systemd_config --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_add_systemd_config --service="${app}_web" --template="diaspora_web.service"
|
||||
|
||||
# tmp files
|
||||
install -T --mode=0644 -v ../conf/diaspora.tmpfiles.d /etc/tmpfiles.d/${app}.conf
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/tmpfiles.d/${app}.conf
|
||||
|
||||
# target unit
|
||||
install -T --mode=0644 -v ../conf/diaspora.target /etc/systemd/system/${app}.target
|
||||
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file=/etc/systemd/system/${app}.target
|
||||
|
||||
# reload, create, enable and start stuff
|
||||
systemctl daemon-reload
|
||||
systemd-tmpfiles --create
|
||||
systemctl enable ${app}.target --quiet
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app.target \
|
||||
--log $final_path/live/log/production.log \
|
||||
$final_path/live/log/unicorn-stderr.log\
|
||||
$final_path/live/log/unicorn-stdout.log\
|
||||
$final_path/live/log/sidekiq.log\
|
||||
--description "Diaspora service (unicorn web and sidekiq)"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
systemctl restart ${app}.target
|
||||
ynh_systemd_action --service_name=${app}_web.service \
|
||||
--action=restart\
|
||||
--log_path="$final_path/live/log/production.log" \
|
||||
--line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name=${app}_sidekiq.service \
|
||||
--action=restart\
|
||||
--log_path="systemd" \
|
||||
--line_match="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
310
scripts/ynh_install_ruby__2
Normal file
310
scripts/ynh_install_ruby__2
Normal file
|
@ -0,0 +1,310 @@
|
|||
#!/bin/bash
|
||||
|
||||
ynh_ruby_try_bash_extension() {
|
||||
if [ -x src/configure ]; then
|
||||
src/configure && make -C src || {
|
||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
rbenv_install_dir="/opt/rbenv"
|
||||
ruby_version_path="$rbenv_install_dir/versions"
|
||||
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
|
||||
export RBENV_ROOT="$rbenv_install_dir"
|
||||
export rbenv_root="$rbenv_install_dir"
|
||||
|
||||
ruby_dependencies=""
|
||||
build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
||||
pkg_dependencies="$pkg_dependencies $ruby_dependencies"
|
||||
build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||
|
||||
# Load the version of Ruby for an app, and set variables.
|
||||
#
|
||||
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
|
||||
# This helper will provide alias and variables to use in your scripts.
|
||||
#
|
||||
# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby`
|
||||
# Those alias will use the correct version installed for the app
|
||||
# For example: use `ynh_gem install` instead of `gem install`
|
||||
#
|
||||
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby`
|
||||
# And propagate $PATH to sudo with $ynh_ruby_load_path
|
||||
# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install`
|
||||
#
|
||||
# $PATH contains the path of the requested version of Ruby.
|
||||
# However, $PATH is duplicated into $ruby_path to outlast any manipulation of $PATH
|
||||
# You can use the variable `$ynh_ruby_load_path` to quickly load your Ruby version
|
||||
# in $PATH for an usage into a separate script.
|
||||
# Exemple: $ynh_ruby_load_path $final_path/script_that_use_gem.sh`
|
||||
#
|
||||
#
|
||||
# Finally, to start a Ruby service with the correct version, 2 solutions
|
||||
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
||||
# In such situation, you need to load PATH
|
||||
# `Environment="__YNH_RUBY_LOAD_PATH__"`
|
||||
# `ExecStart=__FINALPATH__/my_app`
|
||||
# You will replace __YNH_RUBY_LOAD_PATH__ with $ynh_ruby_load_path
|
||||
#
|
||||
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
||||
# `ExecStart=__YNH_RUBY__ my_app run`
|
||||
# You will replace __YNH_RUBY__ with $ynh_ruby
|
||||
#
|
||||
#
|
||||
# one other variable is also available
|
||||
# - $ruby_path: The absolute path to Ruby binaries for the chosen version.
|
||||
#
|
||||
# usage: ynh_use_ruby
|
||||
#
|
||||
# Requires YunoHost version 3.2.2 or higher.
|
||||
ynh_use_ruby () {
|
||||
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||
|
||||
# Get the absolute path of this version of Ruby
|
||||
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
|
||||
# Allow alias to be used into bash script
|
||||
shopt -s expand_aliases
|
||||
|
||||
# Create an alias for the specific version of Ruby and a variable as fallback
|
||||
ynh_ruby="$ruby_path/ruby"
|
||||
alias ynh_ruby="$ynh_ruby"
|
||||
# And gem
|
||||
ynh_gem="$ruby_path/gem"
|
||||
alias ynh_gem="$ynh_gem"
|
||||
|
||||
# Load the path of this version of Ruby in $PATH
|
||||
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
||||
PATH="$ruby_path:$PATH"
|
||||
fi
|
||||
# Create an alias to easily load the PATH
|
||||
ynh_ruby_load_path="PATH=$PATH"
|
||||
|
||||
# Sets the local application-specific Ruby version
|
||||
pushd $final_path
|
||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||
popd
|
||||
}
|
||||
|
||||
# Install a specific version of Ruby
|
||||
#
|
||||
# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv.
|
||||
#
|
||||
# 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=ruby_version
|
||||
# | arg: -v, --ruby_version= - Version of ruby to install.
|
||||
#
|
||||
# Requires YunoHost version 3.2.2 or higher.
|
||||
ynh_install_ruby () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=v
|
||||
local -A args_array=( [v]=ruby_version= )
|
||||
local ruby_version
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
# Load rbenv path in PATH
|
||||
local 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
|
||||
|
||||
# Install or update rbenv
|
||||
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
||||
if [ -n "$rbenv" ]; then
|
||||
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
|
||||
pushd "${rbenv%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||
ynh_print_info --message="Trying to update with git..."
|
||||
git pull -q --tags origin master
|
||||
ynh_ruby_try_bash_extension
|
||||
else
|
||||
ynh_print_info --message="Reinstalling rbenv with git..."
|
||||
cd ..
|
||||
ynh_secure_remove --file=$rbenv_install_dir
|
||||
mkdir -p $rbenv_install_dir
|
||||
cd $rbenv_install_dir
|
||||
git init -q
|
||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||
git checkout -q -b master origin/master
|
||||
ynh_ruby_try_bash_extension
|
||||
rbenv=$rbenv_install_dir/bin/rbenv
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing rbenv with git..."
|
||||
mkdir -p $rbenv_install_dir
|
||||
pushd $rbenv_install_dir
|
||||
git init -q
|
||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||
git checkout -q -b master origin/master
|
||||
ynh_ruby_try_bash_extension
|
||||
rbenv=$rbenv_install_dir/bin/rbenv
|
||||
popd
|
||||
fi
|
||||
|
||||
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||
if [ -n "$ruby_build" ]; then
|
||||
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
|
||||
pushd "${ruby_build%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||
ynh_print_info --message="Trying to update rbenv with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing ruby-build with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
||||
fi
|
||||
|
||||
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||
if [ -n "$rbenv_alias" ]; then
|
||||
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
|
||||
pushd "${rbenv_alias%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||
ynh_print_info --message="Trying to update rbenv-aliases with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing rbenv-aliases with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
||||
fi
|
||||
|
||||
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||
if [ -n "$rbenv_latest" ]; then
|
||||
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
|
||||
pushd "${rbenv_latest%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing xxenv-latest with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
||||
fi
|
||||
|
||||
# Enable caching
|
||||
mkdir -p "${rbenv_install_dir}/cache"
|
||||
|
||||
# Create shims directory if needed
|
||||
mkdir -p "${rbenv_install_dir}/shims"
|
||||
|
||||
# Restore /usr/local/bin in PATH
|
||||
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
|
||||
local final_ruby_version=$(rbenv latest --print $ruby_version)
|
||||
if ! [ -n "$final_ruby_version" ]; then
|
||||
final_ruby_version=$ruby_version
|
||||
fi
|
||||
ynh_print_info --message="Installing Ruby-$final_ruby_version"
|
||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
|
||||
|
||||
# Store ruby_version into the config of this app
|
||||
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
||||
|
||||
# Remove app virtualenv
|
||||
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
then
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
fi
|
||||
|
||||
# Create app virtualenv
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
|
||||
# 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 environment
|
||||
eval "$(rbenv init -)"
|
||||
}
|
||||
|
||||
# Remove the version of Ruby used by the app.
|
||||
#
|
||||
# This helper will also cleanup Ruby versions
|
||||
#
|
||||
# usage: ynh_remove_ruby
|
||||
ynh_remove_ruby () {
|
||||
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||
|
||||
# Load rbenv path in PATH
|
||||
local 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:@@')
|
||||
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
|
||||
# Remove the line for this app
|
||||
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
}
|
||||
|
||||
# Remove no more needed versions of Ruby used by the app.
|
||||
#
|
||||
# This helper will check what Ruby version are no more required,
|
||||
# and uninstall them
|
||||
# If no app uses Ruby, rbenv will be also removed.
|
||||
#
|
||||
# usage: ynh_cleanup_ruby
|
||||
ynh_cleanup_ruby () {
|
||||
|
||||
# List required Ruby versions
|
||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||
local required_ruby_versions=""
|
||||
for installed_app in $installed_apps
|
||||
do
|
||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||
if [[ $installed_app_ruby_version ]]
|
||||
then
|
||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove no more needed Ruby versions
|
||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||
for installed_ruby_version in $installed_ruby_versions
|
||||
do
|
||||
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
|
||||
then
|
||||
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
|
||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||
fi
|
||||
done
|
||||
|
||||
# If none Ruby version is required
|
||||
if [[ ! $required_ruby_versions ]]
|
||||
then
|
||||
# Remove rbenv environment configuration
|
||||
ynh_print_info --message="Removing of rbenv-$rbenv_version"
|
||||
ynh_secure_remove --file="$rbenv_install_dir"
|
||||
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
|
||||
fi
|
||||
}
|
Loading…
Reference in a new issue