Skip to content

Commit

Permalink
Merge pull request #22 from YunoHost-Apps/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
autra authored Sep 12, 2020
2 parents c27edb1 + 2ad9f59 commit d3f8ba0
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 64 deletions.
1 change: 1 addition & 0 deletions check_process
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
setup_nourl=0
upgrade=1
upgrade=1 from_commit=0.7.13.0-ynh1
upgrade=1 from_commit=0.7.13.0-ynh2
backup_restore=1
multi_instance=1
port_already_use=0
Expand Down
1 change: 0 additions & 1 deletion conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ location / {
}

# Include SSOWAT user panel.
# TODO check that
include conf.d/yunohost_panel.conf.inc;
}

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"fr": "Service de réseau social distribué"
},
"license": "AGPL-3.0",
"version": "0.7.13.0~ynh1",
"version": "0.7.14.0~ynh1",
"maintainer": {
"name": "rafi59",
"email": ""
},
"requirements": {
"yunohost": ">= 3.6.0"
"yunohost": ">= 3.7.0"
},
"multi_instance": true,
"services": [
Expand Down
5 changes: 3 additions & 2 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/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 nodejs 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"

pkg_dependencies="build-essential cmake libssl-dev libcurl4-openssl-dev libxml2-dev libxslt-dev imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server nodejs 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"
current_tag="v0.7.14.0"
16 changes: 8 additions & 8 deletions scripts/bundle_app
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
pushd $final_path/diaspora
# here we *absolutely* need bash (not dash) because dash does not understand what rvm puts in .profile
# (wtf rvm for assuming everybody uses bash as default shell??)
# we also need a login shell to make sure .profile is loaded
sudo -u $app /bin/bash --login << EOF
rvm use --default 2.4
rvm 2.4 do gem install bundler:1.17.3
echo 2.6.6 > .ruby-version # overwrite 2.4 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
sudo -u $app /bin/bash --login << EOF
sudo -u $app --login << EOF
cd diaspora
RAILS_ENV=production bundle exec rake db:migrate
EOF

#=================================================
# ASSETS PRECOMPILATION
#=================================================
sudo -u $app /bin/bash --login << EOF
sudo -u $app --login << EOF
cd diaspora
RAILS_ENV=production bin/rake assets:precompile
EOF
popd
Expand Down
27 changes: 8 additions & 19 deletions scripts/create_services
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,11 @@ systemctl daemon-reload
systemd-tmpfiles --create
systemctl enable ${app}.target ${app}_sidekiq.service ${app}_web.service
systemctl restart ${app}.target

# wait for startup
timeout=100
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 --extended-regexp --quiet "listening on addr" "$final_path/diaspora/log/unicorn-stderr.log"
then
ynh_print_info --message="Diaspora* is up and running\!"
break
fi
if [ $i -eq 3 ]; then
echo -n "Please wait, diaspora* is starting" >&2
fi
if [ $i -ge 3 ]; then
echo -n "." >&2
fi
sleep 1
done
ynh_systemd_action --service_name=${app}_web.service \
--action=restart\
--log_path="$final_path/diaspora/log/production.log" \
--line_match="Starting processing"
ynh_systemd_action --service_name=${app}_sidekiq.service \
--action=restart\
--log_path="$final_path/diaspora/log/unicorn-stderr.log" \
--line_match="listening on addr"
12 changes: 3 additions & 9 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ can_remove_db=0
can_remove_home=0
can_remove_user=0

# flag to make clean_setup display rvm log if rvm build has failed
should_display_rvm_log=0

#=================================================
# GENERIC START
#=================================================
Expand All @@ -28,10 +25,7 @@ source /usr/share/yunohost/helpers
#=================================================
# Exit if an error occurs during the execution of the script
ynh_clean_setup() {
# print rvm logs
if [ $should_display_rvm_log -eq 1 ]; then
find $final_path/.rvm/log/ -name make.log -exec cat {} \;
fi
ynh_clean_check_starting
}
ynh_abort_if_errors

Expand Down Expand Up @@ -101,15 +95,15 @@ chown $app:www-data $final_path
# INSTALL RVM AND RUBY FOR CURRENT USER
#=================================================
ynh_script_progression --message="Installing rvm and ruby..." --weight=240
source ./install_rvm_ruby
source ./install_ruby

#=================================================
# 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=16
sudo -u $app git clone https://github.com/diaspora/diaspora.git -b v0.7.13.0
sudo -u $app git clone https://github.com/diaspora/diaspora.git -b $current_tag
popd

#=================================================
Expand Down
18 changes: 18 additions & 0 deletions scripts/install_ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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
git fetch
popd
else
git clone https://github.com/YunoHost-Apps/Experimental_helpers.git
fi
pushd Experimental_helpers
git checkout 606b60cf6bb3906d32020392f0a824d1f9971e96
source ./ynh_install_ruby/ynh_install_ruby
popd
popd
ynh_install_ruby --ruby_version=2.6.6

17 changes: 0 additions & 17 deletions scripts/install_rvm_ruby

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/remove
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ if [ $can_remove_user -eq 1 ]; then
ynh_system_user_delete $app
fi

#=================================================
# REMOVE RUBY
#=================================================
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 APP MAIN DIR
#=================================================
Expand Down
7 changes: 5 additions & 2 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pushd $(readlink -f ../settings/scripts)
#=================================================

# Exit if an error occurs during the execution of the script
ynh_clean_setup() {
ynh_clean_check_starting
}
ynh_abort_if_errors

#=================================================
Expand Down Expand Up @@ -69,15 +72,15 @@ chown $app:www-data $final_path
# INSTALL RVM AND RUBY FOR CURRENT USER
#=================================================
ynh_script_progression --message="Reinstalling rvm and ruby..." --weight=50
source ./install_rvm_ruby
source ./install_ruby

#=================================================
# 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=16
sudo -u $app git clone https://github.com/diaspora/diaspora.git -b v0.7.13.0
sudo -u $app git clone https://github.com/diaspora/diaspora.git -b $current_tag
popd

#=================================================
Expand Down
74 changes: 70 additions & 4 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#=================================================

# IMPORT GENERIC HELPERS
source _common.sh
source /usr/share/yunohost/helpers

#=================================================
Expand All @@ -20,17 +21,82 @@ 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
}
ynh_abort_if_errors


#=================================================
# Check upgrade type
#=================================================
ynh_script_progression --message="Check upgrade type..."
upgrade_type=$(ynh_check_app_version_changed)
# nothing to do yet!!

#=================================================
# 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

#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# migrate from rvm to rbenv
ynh_script_progression --message="Remove rvm..."
if [ -e "$final_path/.rvm" ]; then
sudo -u $app --login << EOF
rvm implode --force
EOF
fi
source ./install_ruby
# remove old gpg keys for rvm
ynh_script_progression --message="Remove old rvm keys..."
if gpg --list-keys [email protected] >/dev/null 2>&1; then
ynh_print_info --message="Found mpapis key: deleting"
sudo -u $app gpg --delete-keys [email protected]
ynh_secure_remove "$final_path/[email protected]"
fi
if gpg --list-keys [email protected] >/dev/null 2>&1; then
ynh_print_info --message="Found piotr.kuczynski: deleting"
sudo -u $app gpg --delete-keys [email protected]
ynh_secure_remove "$final_path/[email protected]"
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
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# do something!
echo "to be implemented"
# revert local change to .ruby-version
pushd $final_path/diaspora
git checkout -- .ruby-version
git fetch
git checkout $current_tag
popd
source ./bundle_app
fi

#=================================================
# restart services
#=================================================
ynh_script_progression --message="Recreate and start services..."
source ./create_services

#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_script_progression --message="configure nginx..." --weight=1
ynh_add_nginx_config


0 comments on commit d3f8ba0

Please sign in to comment.