mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
Upgrade 1.6.1; last helpers, use n instead of nvm
This commit is contained in:
parent
6eda414995
commit
77e207c3b6
12 changed files with 322 additions and 234 deletions
|
@ -41,3 +41,7 @@ Ce package etherpad intègre les plugins suivant:
|
|||
Le support ldap étant absent sur le plugin mypads, aucun utilisateur n'est créé par défaut.
|
||||
Il est nécessaire de se connecter à l'interface d'administration pour créer les premiers utilisateurs.
|
||||
Le login et le mot de passe administrateur sont ceux choisis en moment de l'installation.
|
||||
|
||||
**Voir l'état du package:**
|
||||
*[Dernier rapport hebdomadaire](https://forum.yunohost.org/t/rapport-hebdomadaire-dintegration-continue/2297)*
|
||||
*[Dernier test d'intégration continue](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Community%29/lastBuild/consoleFull)*
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
multi_instance=0
|
||||
incorrect_path=0
|
||||
port_already_use=1 (9001)
|
||||
change_url=0
|
||||
;; Test abiword
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
|
@ -43,3 +44,6 @@
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=down
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
SOURCE_URL=https://github.com/ether/etherpad-lite/archive/1.6.0.tar.gz
|
||||
SOURCE_SUM=9ff1ef760e8285a1cd117d9bb576398b
|
||||
ARCH_FORMAT=tar.gz
|
||||
SOURCE_URL=https://github.com/ether/etherpad-lite/archive/1.6.1.tar.gz
|
||||
SOURCE_SUM=2de5cf27933cf687dcca9ea2350e38d4
|
||||
SOURCE_SUM_PRG=md5sum
|
||||
ARCH_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
"ip": "127.0.0.1",
|
||||
"port" : __PORT__,
|
||||
|
||||
// Option to hide/show the settings.json in admin page, default option is set to true
|
||||
"showSettingsInAdminPage" : true,
|
||||
|
||||
/*
|
||||
// Node native SSL support
|
||||
// this is disabled by default
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"en": "Framapad clone, a online editor providing collaborative editing in real-time.",
|
||||
"fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel."
|
||||
},
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"url": "https://framapad.org",
|
||||
"license": "Apache-2.0",
|
||||
"maintainer": {
|
||||
|
|
|
@ -6,45 +6,23 @@
|
|||
#=================================================
|
||||
#=================================================
|
||||
|
||||
YNH_EXECUTION_DIR="."
|
||||
|
||||
ynh_backup_abstract () {
|
||||
# A intégrer à ynh_backup directement.
|
||||
ynh_backup "$@"
|
||||
echo "$2" "$1" >> backup_list
|
||||
}
|
||||
|
||||
ynh_restore_file () {
|
||||
file_and_dest=$(grep "^$1" backup_list)
|
||||
backup_file=${file_and_dest%% *}
|
||||
backup_dest=${file_and_dest#* }
|
||||
if [ -f "$backup_dest" ]; then
|
||||
ynh_die "There is already a file at this path: $backup_dest"
|
||||
fi
|
||||
if test -d "$backup_file"; then
|
||||
sudo cp -a "$backup_file/." "$backup_dest"
|
||||
else
|
||||
sudo cp -a "$backup_file" "$backup_dest"
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_fpm_config () {
|
||||
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_compare_checksum_config "$finalphpconf" 1
|
||||
ynh_backup_if_checksum_is_different "$finalphpconf" 1
|
||||
sudo cp ../conf/php-fpm.conf "$finalphpconf"
|
||||
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
|
||||
ynh_replace_string "__USER__" "$app" "$finalphpconf"
|
||||
sudo chown root: "$finalphpconf"
|
||||
ynh_store_checksum_config "$finalphpconf"
|
||||
ynh_store_file_checksum "$finalphpconf"
|
||||
|
||||
if [ -e "../conf/php-fpm.ini" ]
|
||||
then
|
||||
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
ynh_compare_checksum_config "$finalphpini" 1
|
||||
ynh_backup_if_checksum_is_different "$finalphpini" 1
|
||||
sudo cp ../conf/php-fpm.ini "$finalphpini"
|
||||
sudo chown root: "$finalphpini"
|
||||
ynh_store_checksum_config "$finalphpini"
|
||||
ynh_store_file_checksum "$finalphpini"
|
||||
fi
|
||||
|
||||
sudo systemctl reload php5-fpm
|
||||
|
@ -58,7 +36,7 @@ ynh_remove_fpm_config () {
|
|||
|
||||
ynh_nginx_config () {
|
||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_compare_checksum_config "$finalnginxconf" 1
|
||||
ynh_backup_if_checksum_is_different "$finalnginxconf" 1
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
|
@ -78,7 +56,7 @@ ynh_nginx_config () {
|
|||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
|
||||
fi
|
||||
ynh_store_checksum_config "$finalnginxconf"
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
|
||||
sudo systemctl reload nginx
|
||||
}
|
||||
|
@ -88,37 +66,9 @@ ynh_remove_nginx_config () {
|
|||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
ynh_store_checksum_config () {
|
||||
config_file_checksum=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_set $app $config_file_checksum $(sudo md5sum "$1" | cut -d' ' -f1)
|
||||
}
|
||||
|
||||
ynh_compare_checksum_config () {
|
||||
current_config_file=$1
|
||||
compress_backup=${2:-0} # If $2 is empty, compress_backup will set at 0
|
||||
config_file_checksum=checksum_${current_config_file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
checksum_value=$(ynh_app_setting_get $app $config_file_checksum)
|
||||
if [ -n "$checksum_value" ]
|
||||
then # Proceed only if a value was stocked into the app config
|
||||
if ! echo "$checksum_value $current_config_file" | sudo md5sum -c --status
|
||||
then # If the checksum is now different
|
||||
backup_config_file="$current_config_file.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')"
|
||||
if [ $compress_backup -eq 1 ]
|
||||
then
|
||||
sudo tar --create --gzip --file "$backup_config_file.tar.gz" "$current_config_file" # Backup the current config file and compress
|
||||
backup_config_file="$backup_config_file.tar.gz"
|
||||
else
|
||||
sudo cp -a "$current_config_file" "$backup_config_file" # Backup the current config file
|
||||
fi
|
||||
echo "Config file $current_config_file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_config_file" >&2
|
||||
echo "$backup_config_file" # Return the name of the backup file
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_systemd_config () {
|
||||
finalsystemdconf="/etc/systemd/system/$app.service"
|
||||
ynh_compare_checksum_config "$finalsystemdconf" 1
|
||||
ynh_backup_if_checksum_is_different "$finalsystemdconf" 1
|
||||
sudo cp ../conf/systemd.service "$finalsystemdconf"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
|
@ -129,7 +79,7 @@ ynh_systemd_config () {
|
|||
if test -n "${app:-}"; then
|
||||
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
|
||||
fi
|
||||
ynh_store_checksum_config "$finalsystemdconf"
|
||||
ynh_store_file_checksum "$finalsystemdconf"
|
||||
|
||||
sudo chown root: "$finalsystemdconf"
|
||||
sudo systemctl enable $app
|
||||
|
@ -153,7 +103,16 @@ ynh_remove_systemd_config () {
|
|||
#=================================================
|
||||
|
||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
||||
if sudo yunohost app --help | grep --quiet url-available
|
||||
then
|
||||
# Check availability of a web path
|
||||
ynh_webpath_available $domain $path_url
|
||||
# Register/book a web path for an app
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
else
|
||||
# Use the legacy command
|
||||
sudo yunohost app checkurl $domain$path_url -a $app
|
||||
fi
|
||||
}
|
||||
|
||||
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
|
@ -238,6 +197,14 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
|||
fi
|
||||
}
|
||||
|
||||
# Ce helper est temporaire et sert de remplacement à la véritable fonction ynh_restore_file. Le temps qu'elle arrive...
|
||||
ynh_restore_file () {
|
||||
if [ -f "$1" ]; then
|
||||
ynh_die "There is already a file at this path: $1"
|
||||
fi
|
||||
sudo cp -a "${YNH_APP_BACKUP_DIR}$1" "$1"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# PACKAGE CHECK BYPASSING...
|
||||
#=================================================
|
||||
|
@ -255,81 +222,88 @@ sudo_path () {
|
|||
}
|
||||
|
||||
# INFOS
|
||||
# nvm utilise la variable PATH pour stocker le path de la version de node à utiliser.
|
||||
# n (Node version management) utilise la variable PATH pour stocker le path de la version de node à utiliser.
|
||||
# C'est ainsi qu'il change de version
|
||||
# En attendant une généralisation de root, il est possible d'utiliser sudo aevc le helper temporaire sudo_path
|
||||
# En attendant une généralisation de root, il est possible d'utiliser sudo avec le helper temporaire sudo_path
|
||||
# Il permet d'utiliser sudo en gardant le $PATH modifié
|
||||
# ynh_install_nodejs installe la version de nodejs demandée en argument, avec nvm
|
||||
# ynh_install_nodejs installe la version de nodejs demandée en argument, avec n
|
||||
# ynh_use_nodejs active une version de nodejs dans le script courant
|
||||
# 3 variables sont mises à disposition, et 2 sont stockées dans la config de l'app
|
||||
# - nodejs_path: Le chemin absolu de cette version de node
|
||||
# Utilisé pour des appels directs à npm ou node.
|
||||
# Utilisé pour des appels directs à node.
|
||||
# - nodejs_version: Simplement le numéro de version de nodejs pour cette application
|
||||
# - nodejs_use_version: Un alias pour charger une version de node dans le shell courant.
|
||||
# Utilisé pour démarrer un service ou un script qui utilise node ou npm
|
||||
# Dans ce cas, c'est $PATH qui contient le chemin de la version de node. Il doit être propagé sur les autres shell si nécessaire.
|
||||
|
||||
nvm_install_dir="/opt/nvm"
|
||||
n_install_dir="/opt/node_n"
|
||||
ynh_use_nodejs () {
|
||||
nodejs_path=$(ynh_app_setting_get $app nodejs_path)
|
||||
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
|
||||
|
||||
# And store the command to use a specific version of node. Equal to `nvm use version`
|
||||
nodejs_use_version="source $nvm_install_dir/nvm.sh; nvm use \"$nodejs_version\""
|
||||
load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH+=\":$n_install_dir/bin\""
|
||||
|
||||
# Desactive set -u for this script.
|
||||
set +u
|
||||
eval $nodejs_use_version
|
||||
set -u
|
||||
nodejs_use_version="n $nodejs_version"
|
||||
|
||||
# "Load" a version of node
|
||||
eval $load_n_path; $nodejs_use_version
|
||||
eval $load_n_path; sudo env "PATH=$PATH" $nodejs_use_version
|
||||
|
||||
# Get the absolute path of this version of node
|
||||
nodejs_path="$(n bin $nodejs_version)"
|
||||
|
||||
# Make an alias for node use
|
||||
ynh_node_exec="eval $load_n_path; n use $nodejs_version"
|
||||
sudo_ynh_node_exec="eval $load_n_path; sudo env \"PATH=$PATH\" n use $nodejs_version"
|
||||
}
|
||||
|
||||
ynh_install_nodejs () {
|
||||
# Use n, https://github.com/tj/n to manage the nodejs versions
|
||||
local nodejs_version="$1"
|
||||
local nvm_install_script="https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh"
|
||||
local n_install_script="https://git.io/n-install"
|
||||
|
||||
local nvm_exec="source $nvm_install_dir/nvm.sh; nvm"
|
||||
# Create $n_install_dir
|
||||
sudo mkdir -p "$n_install_dir"
|
||||
|
||||
sudo mkdir -p "$nvm_install_dir"
|
||||
# Load n path in PATH
|
||||
PATH+=":$n_install_dir/bin"
|
||||
|
||||
# If nvm is not previously setup, install it
|
||||
"$nvm_exec --version" > /dev/null 2>&1 || \
|
||||
( cd "$nvm_install_dir"
|
||||
echo "Installation of NVM"
|
||||
sudo wget --no-verbose "$nvm_install_script" -O- | sudo NVM_DIR="$nvm_install_dir" bash > /dev/null)
|
||||
# If n is not previously setup, install it
|
||||
n --version > /dev/null 2>&1 || \
|
||||
( echo "Installation of N - Node.js version management" >&2; \
|
||||
curl -sL $n_install_script | sudo N_PREFIX="$n_install_dir" bash -s -- -y $nodejs_version )
|
||||
|
||||
# Install the requested version of nodejs
|
||||
sudo su -c "$nvm_exec install \"$nodejs_version\" > /dev/null"
|
||||
# Install the requested version of nodejs (except for the first installation of n, which installed the requested version of node.)
|
||||
sudo env "PATH=$PATH" n $nodejs_version
|
||||
|
||||
# Use the real installed version. Sometimes slightly different
|
||||
nodejs_version=$(node --version | cut -c2-)
|
||||
|
||||
# Store the ID of this app and the version of node requested for it
|
||||
echo "$YNH_APP_ID:$nodejs_version" | sudo tee --append "$nvm_install_dir/ynh_app_version"
|
||||
echo "$YNH_APP_ID:$nodejs_version" | sudo tee --append "$n_install_dir/ynh_app_version"
|
||||
|
||||
# Get the absolute path of this version of node
|
||||
nodejs_path="$(dirname "$(sudo su -c "$nvm_exec which \"$nodejs_version\"")")"
|
||||
|
||||
# Store nodejs_path and nodejs_version into the config of this app
|
||||
ynh_app_setting_set $app nodejs_path $nodejs_path
|
||||
# Store nodejs_version into the config of this app
|
||||
ynh_app_setting_set $app nodejs_version $nodejs_version
|
||||
|
||||
ynh_use_nodejs
|
||||
}
|
||||
|
||||
ynh_remove_nodejs () {
|
||||
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
|
||||
ynh_use_nodejs
|
||||
|
||||
# Remove the line for this app
|
||||
sudo sed --in-place "/$YNH_APP_ID:$nodejs_version/d" "$nvm_install_dir/ynh_app_version"
|
||||
sudo sed --in-place "/$YNH_APP_ID:$nodejs_version/d" "$n_install_dir/ynh_app_version"
|
||||
|
||||
# If none another app uses this version of nodejs, remove it.
|
||||
if ! grep --quiet "$nodejs_version" "$nvm_install_dir/ynh_app_version"
|
||||
if ! grep --quiet "$nodejs_version" "$n_install_dir/ynh_app_version"
|
||||
then
|
||||
sudo su -c "source $nvm_install_dir/nvm.sh; nvm deactivate; nvm uninstall \"$nodejs_version\" > /dev/null"
|
||||
n rm $nodejs_version
|
||||
fi
|
||||
|
||||
# If none another app uses nvm, remove nvm and clean the root's bashrc file
|
||||
if [ ! -s "$nvm_install_dir/ynh_app_version" ]
|
||||
# If none another app uses n, remove n
|
||||
if [ ! -s "$n_install_dir/ynh_app_version" ]
|
||||
then
|
||||
ynh_secure_remove "$nvm_install_dir"
|
||||
sudo sed --in-place "/NVM_DIR/d" /root/.bashrc
|
||||
ynh_secure_remove "$n_install_dir"
|
||||
sudo sed --in-place "/N_PREFIX/d" /root/.bashrc
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -385,13 +359,15 @@ function ynh_mysql_user_exists()
|
|||
# After executing this helper, the password of the created database will be available in $db_pwd
|
||||
# It will also be stored as "mysqlpwd" into the app settings.
|
||||
#
|
||||
# usage: ynh_mysql_setup_db user name
|
||||
# usage: ynh_mysql_setup_db user name [pwd]
|
||||
# | arg: user - Owner of the database
|
||||
# | arg: name - Name of the database
|
||||
# | arg: pwd - Password of the database. If not given, a password will be generated
|
||||
ynh_mysql_setup_db () {
|
||||
local db_user="$1"
|
||||
local db_name="$2"
|
||||
db_pwd=$(ynh_string_random) # Generate a random password
|
||||
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
||||
db_pwd="${3:-$new_db_pwd}"
|
||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database
|
||||
ynh_app_setting_set $app mysqlpwd $db_pwd # Store the password in the app's config
|
||||
}
|
||||
|
@ -427,8 +403,8 @@ ynh_mysql_remove_db () {
|
|||
# usage: ynh_make_valid_dbid name
|
||||
# | arg: name - name to correct
|
||||
# | ret: the corrected name
|
||||
ynh_make_valid_dbid () {
|
||||
dbid=${1//[-.]/_} # Mariadb doesn't support - and . in the name of databases. It will be replace by _
|
||||
ynh_sanitize_dbid () {
|
||||
dbid=${1//[-.]/_} # We should avoid having - and . in the name of databases. They are replaced by _
|
||||
echo $dbid
|
||||
}
|
||||
|
||||
|
@ -487,7 +463,7 @@ ynh_install_app_dependencies () {
|
|||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||
version=$(sudo grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||
dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
|
||||
if ynh_package_is_installed "${dep_app}-ynh-deps"; then
|
||||
|
@ -730,6 +706,7 @@ ynh_secure_remove () {
|
|||
# usage: ynh_setup_source dest_dir [source_id]
|
||||
# | arg: dest_dir - Directory where to setup sources
|
||||
# | arg: source_id - Name of the app, if the package contains more than one app
|
||||
YNH_EXECUTION_DIR="."
|
||||
ynh_setup_source () {
|
||||
local dest_dir=$1
|
||||
local src_id=${2:-app} # If the argument is not given, source_id equal "app"
|
||||
|
@ -755,7 +732,7 @@ ynh_setup_source () {
|
|||
|
||||
if test -e "$local_src"
|
||||
then # Use the local source file if it is present
|
||||
sudo cp $local_src $src_filename
|
||||
cp $local_src $src_filename
|
||||
else # If not, download the source
|
||||
wget -nv -O $src_filename $src_url
|
||||
fi
|
||||
|
@ -772,7 +749,7 @@ ynh_setup_source () {
|
|||
# Using of a temp directory, because unzip doesn't manage --strip-components
|
||||
if $src_in_subdir ; then
|
||||
local tmp_dir=$(mktemp -d)
|
||||
unzip -quo $src_filename -d "$tmp_dir"
|
||||
sudo unzip -quo $src_filename -d "$tmp_dir"
|
||||
sudo cp -a $tmp_dir/*/. "$dest_dir"
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
else
|
||||
|
@ -795,16 +772,81 @@ ynh_setup_source () {
|
|||
local old_dir=$(pwd)
|
||||
(cd "$dest_dir" \
|
||||
&& for p in $YNH_EXECUTION_DIR/../sources/patches/${src_id}-*.patch; do \
|
||||
patch -p1 < $p; done) \
|
||||
sudo patch -p1 < $p; done) \
|
||||
|| ynh_die "Unable to apply patches"
|
||||
cd $old_dir
|
||||
fi
|
||||
|
||||
# Add supplementary files
|
||||
if test -e "$YNH_EXECUTION_DIR/../sources/extra_files/${src_id}"; then
|
||||
cp -a $YNH_EXECUTION_DIR/../sources/extra_files/$src_id/. "$dest_dir"
|
||||
sudo cp -a $YNH_EXECUTION_DIR/../sources/extra_files/$src_id/. "$dest_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check availability of a web path
|
||||
#
|
||||
# example: ynh_webpath_available some.domain.tld /coffee
|
||||
#
|
||||
# usage: ynh_webpath_available domain path
|
||||
# | arg: domain - the domain/host of the url
|
||||
# | arg: path - the web path to check the availability of
|
||||
ynh_webpath_available () {
|
||||
local domain=$1
|
||||
local path=$2
|
||||
sudo yunohost domain url-available $domain $path
|
||||
}
|
||||
|
||||
# Register/book a web path for an app
|
||||
#
|
||||
# example: ynh_webpath_register wordpress some.domain.tld /coffee
|
||||
#
|
||||
# usage: ynh_webpath_register app domain path
|
||||
# | arg: app - the app for which the domain should be registered
|
||||
# | arg: domain - the domain/host of the web path
|
||||
# | arg: path - the web path to be registered
|
||||
ynh_webpath_register () {
|
||||
local app=$1
|
||||
local domain=$2
|
||||
local path=$3
|
||||
sudo yunohost app register-url $app $domain $path
|
||||
}
|
||||
|
||||
# Calculate and store a file checksum into the app settings
|
||||
#
|
||||
# $app should be defined when calling this helper
|
||||
#
|
||||
# usage: ynh_store_file_checksum file
|
||||
# | arg: file - The file on which the checksum will performed, then stored.
|
||||
ynh_store_file_checksum () {
|
||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_set $app $checksum_setting_name $(sudo md5sum "$1" | cut -d' ' -f1)
|
||||
}
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
# This helper is primarily meant to allow to easily backup personalised/manually
|
||||
# modified config files.
|
||||
#
|
||||
# $app should be defined when calling this helper
|
||||
#
|
||||
# usage: ynh_backup_if_checksum_is_different file
|
||||
# | arg: file - The file on which the checksum test will be perfomed.
|
||||
#
|
||||
# | ret: Return the name a the backup file, or nothing
|
||||
ynh_backup_if_checksum_is_different () {
|
||||
local file=$1
|
||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
||||
if [ -n "$checksum_value" ]
|
||||
then # Proceed only if a value was stored into the app settings
|
||||
if ! echo "$checksum_value $file" | sudo md5sum -c --status
|
||||
then # If the checksum is now different
|
||||
backup_file="/home/yunohost.conf/backup/$file.backup.$(date '+%Y%m%d.%H%M%S')"
|
||||
sudo mkdir -p "$(dirname "$backup_file")"
|
||||
sudo cp -a "$file" "$backup_file" # Backup the current file
|
||||
echo "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file" >&2
|
||||
echo "$backup_file" # Return the name of the backup file
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Check availability of a web path
|
||||
|
|
|
@ -38,21 +38,21 @@ db_name=$(ynh_app_setting_get $app db_name)
|
|||
#=================================================
|
||||
|
||||
CHECK_SIZE "$final_path"
|
||||
ynh_backup_abstract "$final_path" "sources"
|
||||
ynh_backup "$final_path" "${YNH_APP_BACKUP_DIR}$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup_abstract "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${YNH_APP_BACKUP_DIR}/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE SQL BDD
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > dump.sql
|
||||
CHECK_SIZE "dump.sql"
|
||||
ynh_backup_abstract "dump.sql" "db.sql"
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
CHECK_SIZE "db.sql"
|
||||
# ynh_backup "db.sql" "${YNH_APP_BACKUP_DIR}/db.sql"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -60,10 +60,10 @@ ynh_backup_abstract "dump.sql" "db.sql"
|
|||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup_abstract "/etc/logrotate.d/$app" "logrotate"
|
||||
ynh_backup "/etc/logrotate.d/$app" "${YNH_APP_BACKUP_DIR}/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup_abstract "/etc/systemd/system/$app.service" "systemd"
|
||||
ynh_backup "/etc/systemd/system/$app.service" "${YNH_APP_BACKUP_DIR}/etc/systemd/system/$app.service"
|
||||
|
|
|
@ -91,13 +91,13 @@ fi
|
|||
# INSTALL NODEJS
|
||||
#=================================================
|
||||
|
||||
ynh_install_nodejs 0.10
|
||||
ynh_install_nodejs 4.8.3
|
||||
|
||||
#=================================================
|
||||
# CREATE A SQL BDD
|
||||
#=================================================
|
||||
|
||||
db_name=$(ynh_make_valid_dbid $app)
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
||||
|
@ -106,7 +106,7 @@ ynh_mysql_setup_db $db_name $db_name
|
|||
#=================================================
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_setup_source $final_path # Télécharge la source, décompresse et copie dans $final_path
|
||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -118,7 +118,7 @@ ynh_nginx_config
|
|||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create $app # Créer un utilisateur système dédié à l'app
|
||||
ynh_system_user_create $app /home/$app # Créer un utilisateur système dédié à l'app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
|
@ -141,12 +141,13 @@ ynh_use_logrotate
|
|||
# INSTALL ETHERPAD
|
||||
#=================================================
|
||||
|
||||
# final_path doit appartenir à `admin` pour l'exécution de installDeps.sh (avec root, `hash` perd la trace de node installé via nvm)
|
||||
sudo chown admin -R "$final_path"
|
||||
# Installe les dépendances de etherpad et procède à l'intallation.
|
||||
"$final_path/bin/installDeps.sh" > $install_log 2>&1
|
||||
sudo "$nodejs_path/npm" install forever -g >> $install_log 2>&1
|
||||
ynh_use_nodejs
|
||||
sudo_path "$final_path/bin/installDeps.sh" > $install_log 2>&1
|
||||
sudo_path npm install forever -g >> $install_log 2>&1
|
||||
|
||||
sudo ls -alh /root >&2
|
||||
sudo ls -alh /home/admin >&2
|
||||
#=================================================
|
||||
# CONFIGURE ETHERPAD
|
||||
#=================================================
|
||||
|
@ -164,8 +165,8 @@ then
|
|||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
fi
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||
ynh_store_checksum_config "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config
|
||||
ynh_store_checksum_config "$final_path/credentials.json" # Enregistre la somme de contrôle du fichier de config
|
||||
ynh_store_file_checksum "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config
|
||||
ynh_store_file_checksum "$final_path/credentials.json" # Enregistre la somme de contrôle du fichier de config
|
||||
|
||||
|
||||
#=================================================
|
||||
|
@ -198,22 +199,22 @@ sudo yunohost service add $app --log "/var/log/$app/etherpad.log"
|
|||
|
||||
script_dir="$PWD"
|
||||
cd "$final_path"
|
||||
sudo "$nodejs_path/npm" install ep_align >> $install_log 2>&1 # Add Left/Center/Right/Justify to lines of text in a pad
|
||||
sudo "$nodejs_path/npm" install ep_author_hover >> $install_log 2>&1 # Framapad - Adds author names to span titles
|
||||
sudo "$nodejs_path/npm" install ep_automatic_logut >> $install_log 2>&1 # Automatically disconnects user after some period of time (Prevent server overload)
|
||||
sudo "$nodejs_path/npm" install ep_comments_page >> $install_log 2>&1 # Framapad - Adds comments on sidebar and link it to the text.
|
||||
sudo "$nodejs_path/npm" install ep_countable >> $install_log 2>&1 # Framapad - Displays paragraphs, sentences, words and characters counts.
|
||||
sudo "$nodejs_path/npm" install ep_delete_empty_pads >> $install_log 2>&1 # Framapad - Delete pads which were never edited
|
||||
sudo "$nodejs_path/npm" install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts
|
||||
sudo "$nodejs_path/npm" install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite.
|
||||
sudo "$nodejs_path/npm" install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad
|
||||
sudo "$nodejs_path/npm" install ep_mypads >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad
|
||||
sudo "$nodejs_path/npm" install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter
|
||||
sudo "$nodejs_path/npm" install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking'
|
||||
sudo "$nodejs_path/npm" install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript
|
||||
sudo "$nodejs_path/npm" install ep_table_of_contents >> $install_log 2>&1 # Framapad - View a table of contents for your pad
|
||||
# sudo "$nodejs_path/npm" install ep_unoconv" # Framapad - Use unoconv instead of abiword to export pads.
|
||||
sudo "$nodejs_path/npm" install ep_user_font_size >> $install_log 2>&1 # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
|
||||
sudo_path npm install ep_align # Add Left/Center/Right/Justify to lines of text in a pad
|
||||
sudo_path npm install ep_author_hover >> $install_log 2>&1 # Framapad - Adds author names to span titles
|
||||
sudo_path npm install ep_automatic_logut >> $install_log 2>&1 # Automatically disconnects user after some period of time (Prevent server overload)
|
||||
sudo_path npm install ep_comments_page >> $install_log 2>&1 # Framapad - Adds comments on sidebar and link it to the text.
|
||||
sudo_path npm install ep_countable >> $install_log 2>&1 # Framapad - Displays paragraphs, sentences, words and characters counts.
|
||||
sudo_path npm install ep_delete_empty_pads >> $install_log 2>&1 # Framapad - Delete pads which were never edited
|
||||
sudo_path npm install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts
|
||||
sudo_path npm install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite.
|
||||
sudo_path npm install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad
|
||||
sudo_path npm install ep_mypads >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad
|
||||
sudo_path npm install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter
|
||||
sudo_path npm install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking'
|
||||
sudo_path npm install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript
|
||||
sudo_path npm install ep_table_of_contents >> $install_log 2>&1 # Framapad - View a table of contents for your pad
|
||||
# sudo_path npm install ep_unoconv" # Framapad - Use unoconv instead of abiword to export pads.
|
||||
sudo_path npm install ep_user_font_size >> $install_log 2>&1 # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
|
||||
sudo chown -R $app: $final_path/node_modules
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -42,7 +42,7 @@ fi
|
|||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
if [ "$abiword" -eq 1 ]
|
||||
if [ $abiword -eq 1 ]
|
||||
then
|
||||
ynh_remove_app_dependencies
|
||||
fi
|
||||
|
|
|
@ -48,27 +48,27 @@ test ! -d $final_path \
|
|||
# RESTORE OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file nginx.conf
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file sources
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE SQL BDD
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_create_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE OF THE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create $app # Recreate the dedicated user, if not exist
|
||||
ynh_system_user_create $app /home/$app # Recreate the dedicated user, if not exist
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORE
|
||||
|
@ -84,7 +84,7 @@ sudo chown $app -R /var/log/$app
|
|||
sudo chown admin -R $install_log
|
||||
|
||||
# Restaure la configuration de logrotate
|
||||
ynh_restore_file logrotate
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
@ -99,13 +99,15 @@ fi
|
|||
# INSTALL NODEJS
|
||||
#=================================================
|
||||
|
||||
ynh_install_nodejs 0.10
|
||||
ynh_install_nodejs 4.8.3
|
||||
|
||||
#=================================================
|
||||
# INSTALL ETHERPAD DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
sudo "$nodejs_path/npm" install forever -g >> $install_log 2>&1
|
||||
ynh_use_nodejs
|
||||
sudo_path npm cache clean
|
||||
sudo_path npm install forever -g >> $install_log 2>&1
|
||||
|
||||
#=================================================
|
||||
# ENABLE SERVICE IN ADMIN PANEL
|
||||
|
@ -117,7 +119,7 @@ sudo yunohost service add $app --log "/var/log/$app/etherpad.log"
|
|||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file systemd
|
||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||
## Démarrage auto du service
|
||||
sudo systemctl enable $app.service
|
||||
|
||||
|
@ -154,3 +156,7 @@ done
|
|||
echo ""
|
||||
kill -s 15 $PID_TAIL > /dev/null # Arrête l'exécution de tail.
|
||||
ynh_secure_remove "$tempfile"
|
||||
|
||||
sleep 20
|
||||
cat /var/log/$app/etherpad.log >&2
|
||||
echo "<<<" >&2
|
||||
|
|
|
@ -37,7 +37,7 @@ elif [ "$is_public" = "No" ]; then
|
|||
fi
|
||||
|
||||
if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting
|
||||
db_name=$(ynh_make_valid_dbid $app)
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
fi
|
||||
|
||||
|
@ -56,13 +56,19 @@ ynh_clean_setup () {
|
|||
}
|
||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
||||
|
||||
#=================================================
|
||||
# STOP ETHERPAD
|
||||
#=================================================
|
||||
|
||||
sudo systemctl stop $app
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
ynh_setup_source $final_path # Télécharge la source, décompresse et copie dans $final_path
|
||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -70,6 +76,26 @@ ynh_setup_source $final_path # Télécharge la source, décompresse et copie dan
|
|||
|
||||
ynh_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE NODEJS
|
||||
#=================================================
|
||||
|
||||
# Remove the old nvm helper.
|
||||
if [ -d /opt/nvm ]
|
||||
then
|
||||
ynh_secure_remove "/opt/nvm"
|
||||
sudo sed --in-place "/NVM_DIR/d" /root/.bashrc
|
||||
fi
|
||||
|
||||
ynh_install_nodejs 4.8.3
|
||||
|
||||
#=================================================
|
||||
# UPGRADE NPM MODULES
|
||||
#=================================================
|
||||
|
||||
sudo_path npm cache clean
|
||||
sudo_path npm update
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
|
@ -77,8 +103,8 @@ ynh_nginx_config
|
|||
#=================================================
|
||||
|
||||
# Copie ou modification d'un fichier de config
|
||||
ynh_compare_checksum_config "$final_path/settings.json" # Créé un backup du fichier de config si il a été modifié.
|
||||
ynh_compare_checksum_config "$final_path/credentials.json" # Créé un backup du fichier de config si il a été modifié.
|
||||
ynh_backup_if_checksum_is_different "$final_path/settings.json" # Créé un backup du fichier de config si il a été modifié.
|
||||
ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Créé un backup du fichier de config si il a été modifié.
|
||||
sudo cp ../conf/settings.json "$final_path/settings.json"
|
||||
sudo cp ../conf/credentials.json "$final_path/credentials.json"
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||
|
@ -88,7 +114,7 @@ password=$(ynh_app_setting_get $app password)
|
|||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
|
||||
ynh_replace_string "__PASSWD__" "$password" "$final_path/credentials.json"
|
||||
if [ "$abiword" -eq 1 ]
|
||||
if [ $abiword -eq 1 ]
|
||||
then
|
||||
abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword
|
||||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
|
@ -98,14 +124,14 @@ if test -z $language; then
|
|||
ynh_app_setting_set $app language $language
|
||||
fi
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||
ynh_store_checksum_config "$final_path/settings.json" # Réenregistre la somme de contrôle du fichier de config
|
||||
ynh_store_checksum_config "$final_path/credentials.json" # Réenregistre la somme de contrôle du fichier de config
|
||||
ynh_store_file_checksum "$final_path/settings.json" # Réenregistre la somme de contrôle du fichier de config
|
||||
ynh_store_file_checksum "$final_path/credentials.json" # Réenregistre la somme de contrôle du fichier de config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_create $app # Create the dedicated user, if not exist
|
||||
ynh_system_user_create $app /home/$app # Create the dedicated user, if not exist
|
||||
|
||||
#=================================================
|
||||
# SECURING FILES AND DIRECTORIES
|
||||
|
@ -127,6 +153,9 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
|
||||
ynh_systemd_config
|
||||
ynh_replace_string "__NODEJS__" "$nodejs_use_version" "/etc/systemd/system/$app.service"
|
||||
ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service"
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
#=================================================
|
||||
# SOME HACKS
|
||||
|
@ -140,11 +169,11 @@ sudo sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads"
|
|||
#=================================================
|
||||
|
||||
# Démarre etherpad
|
||||
WARNING echo "Démarrage d'etherpad"
|
||||
WARNING echo "Redémarrage d'etherpad"
|
||||
tempfile="$(mktemp)"
|
||||
tail -f -n1 /var/log/$app/etherpad.log > "$tempfile" & # Suit le démarrage dans le log
|
||||
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
|
||||
sudo systemctl start $app # Démarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
|
||||
sudo systemctl start $app # Redémarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
|
|
3
sources/extra_files/.gitignore
vendored
3
sources/extra_files/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
*.swp
|
||||
*~
|
||||
Notes
|
Loading…
Add table
Reference in a new issue