1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

Merge pull request #9 from YunoHost-Apps/testing

Final Cleanup
This commit is contained in:
yalh76 2019-04-15 03:22:46 +02:00 committed by GitHub
commit fc083cd7e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 157 deletions

View file

@ -2,7 +2,7 @@
[![Integration level](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon)
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mobilizon_ynh%20(yalh76)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mobilizon_ynh%20(yalh76)/)
[![Install mobilizon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mobilizon)
[![Install Mobilizon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mobilizon)
> *This package allow you to install Mobilizon 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.*

View file

@ -1,12 +1,11 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
language="fr"
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
port="666" (PORT)
name="My Mobilizon"
; Checks
pkg_linter=1
setup_sub_dir=0
@ -34,10 +33,5 @@
Level 9=0
Level 10=0
;;; Options
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&
Email=yalh@yahoo.com
Notification=all

1
conf/.yarnrc Normal file
View file

@ -0,0 +1 @@
network-timeout 600000

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/master/6bf903f9d79dc4f24c35d9e21ebe45abbc0924ed.gz
SOURCE_SUM=074081bd8b688056d7a938d64dfd9da2b7c1d463d4f5bb86a1ddcceec6201cda
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/master/6bf903f9d79dc4f24c35d9e21ebe45abbc0924ed.tar.gz
SOURCE_SUM=a5cfbdc58a7f7262f7d9b86b151f28097ba5cbacbd227663ebd3b154f06a91eb
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -6,14 +6,14 @@
"en": "Your federated organization and mobilization platform.",
"fr": "Votre plateforme fédérée d'organisation et de mobilisation."
},
"version": "0.1.0-2019-04-12~ynh1",
"version": "0.1.0-2019-04-12~ynh2",
"url": "https://joinmobilizon.org/",
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "yalh76"
},
"requirements": {
"yunohost": ">= 3.4"
"yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [

View file

@ -17,7 +17,7 @@
- [ ] **Approval (LGTM)**
*Code review and approval have to be from a member of @YunoHost/apps group*
- **CI succeeded** :
[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/wikijs_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/wikijs_ynh%20-BRANCH-/)
[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/mobilizon_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/mobilizon_ynh%20-BRANCH-/)
*Please replace '-BRANCH-' in this link by the name of the branch used.*
*If the PR is from a forked repository. Please provide public results from package_check.*
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.

View file

@ -6,9 +6,7 @@
# dependencies used by the app
pkg_dependencies="postgresql postgresql-contrib openssl make git postgis "
# build-essential inotify-tools postgresql-client
extra_pkg_dependencies="elixir esl-erlang"
# erlang-dev erlang-tools erlang-parsetools
#=================================================
# PERSONAL HELPERS

View file

@ -8,7 +8,6 @@
#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
#=================================================
@ -57,13 +56,6 @@ ynh_psql_dump_db "$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_print_info "Backing up logrotate configuration..."
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_systemd_action
source ynh_add_secure_repos__3
source /usr/share/yunohost/helpers
@ -83,6 +82,8 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 10
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
#=================================================
# INSTALL EXTRA DEPENDENCIES
#=================================================
@ -172,13 +173,16 @@ ynh_replace_string "__NAME__" "$name" "../conf/prod.exs"
ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "../conf/prod.exs"
cp ../conf/prod.exs "$final_path/$app/config/prod.exs"
# Temprary YARN fix for package material-design-icons
cp ../conf/.yarnrc "$final_path/$app/.yarnrc"
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
pushd $final_path/$app/js
ynh_use_nodejs
sudo -u $app env PATH=$PATH npm install
sudo -u $app env PATH=$PATH npm run build
sudo -u $app env PATH=$PATH yarn install
sudo -u $app env PATH=$PATH yarn run build
popd
pushd $final_path/$app
@ -224,21 +228,12 @@ ynh_store_file_checksum "$config"
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Configuring log rotation..."
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
#yunohost service add $app --log "/var/log/$app/APP.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for Mobilizon" --log "/var/log/$app/$app.log"
yunohost service add $app --description "$app daemon for Mobilizon"
#=================================================
# SETUP SSOWAT

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
@ -20,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
@ -58,7 +58,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';"
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db "$db_name" "$db_name"
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
#=================================================
# REMOVE DEPENDENCIES
@ -86,14 +86,6 @@ ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_print_info "Removing logrotate configuration"
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================

View file

@ -8,7 +8,6 @@
#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 ../settings/scripts/ynh_add_secure_repos__3
source /usr/share/yunohost/helpers
@ -34,6 +33,7 @@ path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get $app db_pwd)
#=================================================
@ -88,6 +88,8 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 10
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
#=================================================
# REINSTALL EXTRA DEPENDENCIES
#=================================================
@ -102,8 +104,7 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
db_user=$db_name
ynh_psql_create_user "$app" "$db_pwd"
ynh_psql_create_user "$db_user" "$db_pwd"
ynh_psql_execute_as_root "CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $db_user;"
ynh_psql_execute_as_root "\connect $db_name
create extension if not exists postgis;"
@ -126,13 +127,7 @@ systemctl daemon-reload
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --description "$app daemon for Mobilizon" --log "/var/log/$app/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file "/etc/logrotate.d/$app"
yunohost service add $app --description "$app daemon for Mobilizon"
#=================================================
# GENERIC FINALIZATION

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_systemd_action
source ynh_add_secure_repos__3
source /usr/share/yunohost/helpers
@ -185,14 +184,6 @@ ynh_backup_if_checksum_is_different "$config"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$config"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SETUP SYSTEMD
#=================================================

View file

@ -1,89 +0,0 @@
#!/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
}