mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
commit
41f74bd99e
11 changed files with 215 additions and 298 deletions
10
README.md
10
README.md
|
@ -1,6 +1,6 @@
|
|||
# Lutim for YunoHost
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/lutim.svg)](https://ci-apps.yunohost.org/jenkins/job/lutim%20%28Community%29/lastBuild/consoleFull)
|
||||
[![Integration level](https://dash.yunohost.org/integration/lutim.svg)](https://dash.yunohost.org/appci/app/lutim)
|
||||
[![Install Lutim with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lutim)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
@ -13,10 +13,14 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
|
|||
Lutim stores images and allows you to see them, download them or share them on social networks.
|
||||
Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year.
|
||||
|
||||
**Shipped version:** 0.9.3
|
||||
**Shipped version:** 0.10.4
|
||||
|
||||
## Screenshots
|
||||
|
||||
## Demo
|
||||
|
||||
* [Official instance](https://lut.im/)
|
||||
|
||||
## Configuration
|
||||
|
||||
Edit the file `/var/www/lutim/lutim.conf` to edit the configuration of Lutim.
|
||||
|
@ -36,7 +40,7 @@ Not relevant.
|
|||
#### Supported architectures
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
|
10
README_fr.md
10
README_fr.md
|
@ -1,6 +1,6 @@
|
|||
# Lutim pour YunoHost
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/lutim.svg)](https://ci-apps.yunohost.org/jenkins/job/lutim%20%28Community%29/lastBuild/consoleFull)
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/lutim.svg)](https://dash.yunohost.org/appci/app/lutim)
|
||||
[![Installer Lutim avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lutim)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
@ -13,10 +13,14 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst
|
|||
Lutim stocke les images et vous permet de les voir, de les télécharger ou de les partager sur les réseaux sociaux.
|
||||
Les images sont stockées indéfiniment à moins que vous ne demandiez qu'elles soient effacées à la première vue ou après 24 heures / une semaine / un mois / un an.
|
||||
|
||||
**Version embarquée:** 0.9.3
|
||||
**Version embarquée:** 0.10.4
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
## Démo
|
||||
|
||||
* [Instance officielle](https://lut.im/)
|
||||
|
||||
## Configuration
|
||||
|
||||
Editez le fichier `/var/www/lutim/lutim. conf` pour éditer la configuration de Lutim.
|
||||
|
@ -36,7 +40,7 @@ Non applicable.
|
|||
#### Architectures supportées.
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://framagit.org/luc/lutim/repository/0.9.3/archive.tar.gz
|
||||
SOURCE_SUM=e11380472f314011328b4e2aa31f3ba8
|
||||
SOURCE_URL=https://framagit.org/luc/lutim/repository/0.10.4/archive.tar.gz
|
||||
SOURCE_SUM=aca9466fc49729a58e055e1a0fb1b8b0
|
||||
SOURCE_SUM_PRG=md5sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Self hosting images and sharing anonymous application",
|
||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||
},
|
||||
"version": "0.9.3~ynh1",
|
||||
"version": "0.10.4~ynh1",
|
||||
"url": "https://lut.im",
|
||||
"license": "AGPL-3.0",
|
||||
"maintainer": {
|
||||
|
@ -14,7 +14,7 @@
|
|||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 2.7.12"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
37
scripts/_apt
37
scripts/_apt
|
@ -1,37 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://github.com/YunoHost/yunohost/pull/391
|
||||
|
||||
# Define and install dependencies with a equivs control file
|
||||
# This helper can/should only be called once per app
|
||||
#
|
||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
||||
# | arg: dep - the package name to install in dependence
|
||||
ynh_install_app_dependencies () {
|
||||
dependencies=$@
|
||||
manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version=$(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
|
||||
# echo "A package named ${dep_app}-ynh-deps is already installed" >&2
|
||||
# else
|
||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Package: ${dep_app}-ynh-deps
|
||||
Version: ${version}
|
||||
Depends: ${dependencies// /, }
|
||||
Architecture: all
|
||||
Description: Fake package for ${app} (YunoHost app) dependencies
|
||||
This meta-package is only responsible of installing its dependencies.
|
||||
EOF
|
||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
||||
|| ynh_die "Unable to install dependencies" # Install the fake package and its dependencies
|
||||
rm /tmp/${dep_app}-ynh-deps.control
|
||||
ynh_app_setting_set $app apt_dependencies $dependencies
|
||||
# fi
|
||||
}
|
|
@ -34,216 +34,41 @@ IS_PACKAGE_CHECK () { # Détermine une exécution en conteneur (Non testé)
|
|||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# INFOS
|
||||
# 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
|
||||
# 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 à 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.
|
||||
|
||||
n_install_dir="/opt/node_n"
|
||||
node_version_path="/opt/node_n/n/versions/node"
|
||||
# N_PREFIX est le dossier de n, il doit être chargé dans les variables d'environnement pour n.
|
||||
export N_PREFIX="$n_install_dir"
|
||||
|
||||
ynh_install_n () {
|
||||
echo "Installation of N - Node.js version management" >&2
|
||||
# Build an app.src for n
|
||||
mkdir -p "../conf"
|
||||
echo "SOURCE_URL=https://github.com/tj/n/archive/v2.1.7.tar.gz
|
||||
SOURCE_SUM=2ba3c9d4dd3c7e38885b37e02337906a1ee91febe6d5c9159d89a9050f2eea8f" > "../conf/n.src"
|
||||
# Download and extract n
|
||||
ynh_setup_source "$n_install_dir/git" n
|
||||
# Install n
|
||||
(cd "$n_install_dir/git"
|
||||
PREFIX=$N_PREFIX make install 2>&1)
|
||||
}
|
||||
|
||||
ynh_use_nodejs () {
|
||||
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
|
||||
|
||||
load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH=\"$n_install_dir/bin:$PATH\"; N_PREFIX="$n_install_dir""
|
||||
|
||||
nodejs_use_version="$n_install_dir/bin/n -q $nodejs_version"
|
||||
|
||||
# "Load" a version of node
|
||||
eval $load_n_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"
|
||||
}
|
||||
|
||||
ynh_install_nodejs () {
|
||||
# Use n, https://github.com/tj/n to manage the nodejs versions
|
||||
nodejs_version="$1"
|
||||
local n_install_script="https://git.io/n-install"
|
||||
|
||||
# Create $n_install_dir
|
||||
mkdir -p "$n_install_dir"
|
||||
|
||||
# Load n path in PATH
|
||||
CLEAR_PATH="$n_install_dir/bin:$PATH"
|
||||
# Remove /usr/local/bin in PATH in case of node has already setup.
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
# Move an existing node binary, to avoid to block n.
|
||||
test -x /usr/bin/node && mv /usr/bin/node /usr/bin/node_n
|
||||
test -x /usr/bin/npm && mv /usr/bin/npm /usr/bin/npm_n
|
||||
|
||||
# If n is not previously setup, install it
|
||||
if ! test n --version > /dev/null 2>&1
|
||||
then
|
||||
ynh_install_n
|
||||
fi
|
||||
|
||||
# Modify the default N_PREFIX in n script
|
||||
ynh_replace_string "^N_PREFIX=\${N_PREFIX-.*}$" "N_PREFIX=\${N_PREFIX-$N_PREFIX}" "$n_install_dir/bin/n"
|
||||
|
||||
# Restore /usr/local/bin in PATH
|
||||
PATH=$CLEAR_PATH
|
||||
|
||||
# And replace the old node binary.
|
||||
test -x /usr/bin/node_n && mv /usr/bin/node_n /usr/bin/node
|
||||
test -x /usr/bin/npm_n && mv /usr/bin/npm_n /usr/bin/npm
|
||||
|
||||
# Install the requested version of nodejs
|
||||
n $nodejs_version
|
||||
|
||||
# Find the last "real" version for this major version of node.
|
||||
real_nodejs_version=$(find $node_version_path/$nodejs_version* -maxdepth 0 | sort --version-sort | tail --lines=1)
|
||||
real_nodejs_version=$(basename $real_nodejs_version)
|
||||
|
||||
# Create a symbolic link for this major version. If the file doesn't already exist
|
||||
if [ ! -e "$node_version_path/$nodejs_version" ]
|
||||
then
|
||||
ln --symbolic --force --no-target-directory $node_version_path/$real_nodejs_version $node_version_path/$nodejs_version
|
||||
fi
|
||||
|
||||
# Store the ID of this app and the version of node requested for it
|
||||
echo "$YNH_APP_ID:$nodejs_version" | tee --append "$n_install_dir/ynh_app_version"
|
||||
|
||||
# Store nodejs_version into the config of this app
|
||||
ynh_app_setting_set $app nodejs_version $nodejs_version
|
||||
|
||||
# Build the update script and set the cronjob
|
||||
ynh_cron_upgrade_node
|
||||
|
||||
ynh_use_nodejs
|
||||
}
|
||||
|
||||
ynh_remove_nodejs () {
|
||||
ynh_use_nodejs
|
||||
|
||||
# Remove the line for this app
|
||||
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" "$n_install_dir/ynh_app_version"
|
||||
then
|
||||
n rm $nodejs_version
|
||||
fi
|
||||
|
||||
# If none another app uses n, remove n
|
||||
if [ ! -s "$n_install_dir/ynh_app_version" ]
|
||||
then
|
||||
ynh_secure_remove "$n_install_dir"
|
||||
ynh_secure_remove "/usr/local/n"
|
||||
sed --in-place "/N_PREFIX/d" /root/.bashrc
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_cron_upgrade_node () {
|
||||
# Build the update script
|
||||
cat > "$n_install_dir/node_update.sh" << EOF
|
||||
#!/bin/bash
|
||||
|
||||
version_path="$node_version_path"
|
||||
n_install_dir="$n_install_dir"
|
||||
|
||||
# Log the date
|
||||
date
|
||||
|
||||
# List all real installed version of node
|
||||
all_real_version="\$(find \$version_path/* -maxdepth 0 -type d | sed "s@\$version_path/@@g")"
|
||||
|
||||
# Keep only the major version number of each line
|
||||
all_real_version=\$(echo "\$all_real_version" | sed 's/\..*\$//')
|
||||
|
||||
# Remove double entries
|
||||
all_real_version=\$(echo "\$all_real_version" | sort --unique)
|
||||
|
||||
# Read each major version
|
||||
while read version
|
||||
do
|
||||
echo "Update of the version \$version"
|
||||
sudo \$n_install_dir/bin/n \$version
|
||||
|
||||
# Find the last "real" version for this major version of node.
|
||||
real_nodejs_version=\$(find \$version_path/\$version* -maxdepth 0 | sort --version-sort | tail --lines=1)
|
||||
real_nodejs_version=\$(basename \$real_nodejs_version)
|
||||
|
||||
# Update the symbolic link for this version
|
||||
sudo ln --symbolic --force --no-target-directory \$version_path/\$real_nodejs_version \$version_path/\$version
|
||||
done <<< "\$(echo "\$all_real_version")"
|
||||
EOF
|
||||
|
||||
chmod +x "$n_install_dir/node_update.sh"
|
||||
|
||||
# Build the cronjob
|
||||
cat > "/etc/cron.daily/node_update" << EOF
|
||||
#!/bin/bash
|
||||
|
||||
$n_install_dir/node_update.sh >> $n_install_dir/node_update.log
|
||||
EOF
|
||||
|
||||
chmod +x "/etc/cron.daily/node_update"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Start or restart a service and follow its booting
|
||||
#
|
||||
# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name]
|
||||
#
|
||||
# | arg: Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# | arg: Log file - The log file to watch
|
||||
# | arg: Service name
|
||||
# /var/log/$app/$app.log will be used if no other log is defined.
|
||||
# | arg: Log file - The log file to watch; specify "systemd" to read systemd journal for specified service
|
||||
# /var/log/$app/$app.log will be used if no other log is defined.
|
||||
# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
|
||||
# | arg: Service name
|
||||
|
||||
ynh_check_starting () {
|
||||
local line_to_match="$1"
|
||||
local service_name="${4:-$app}"
|
||||
local app_log="${2:-/var/log/$service_name/$service_name.log}"
|
||||
local timeout=${3:-300}
|
||||
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
local service_name="${4:-$app}"
|
||||
|
||||
echo "Starting of $service_name" >&2
|
||||
systemctl stop $service_name
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
tail -F -n0 "$app_log" > "$templog" &
|
||||
# Get the PID of the tail command
|
||||
if [ "$app_log" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$app_log" > "$templog" &
|
||||
fi
|
||||
# Get the PID of the last command
|
||||
local pid_tail=$!
|
||||
systemctl start $service_name
|
||||
|
||||
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
|
||||
# Read the log until the sentence is found, which means the app finished starting. Or run until the timeout.
|
||||
if grep --quiet "$line_to_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
|
@ -254,12 +79,22 @@ ynh_check_starting () {
|
|||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
echo "The service $service_name didn't fully start before the timeout." >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
|
@ -369,9 +204,20 @@ ynh_print_ON () {
|
|||
#
|
||||
# usage: ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_build_main_dir () {
|
||||
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip 2>&1
|
||||
unzip -q master.zip
|
||||
./yunohost.multimedia-master/script/ynh_media_build.sh
|
||||
local ynh_media_release="v1.0"
|
||||
local checksum="4852c8607db820ad51f348da0dcf0c88"
|
||||
|
||||
# Download yunohost.multimedia scripts
|
||||
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
|
||||
|
||||
# Check the control sum
|
||||
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|
||||
|| ynh_die "Corrupt source"
|
||||
|
||||
# Extract
|
||||
mkdir yunohost.multimedia-master
|
||||
tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
|
||||
./yunohost.multimedia-master/script/ynh_media_build.sh
|
||||
}
|
||||
|
||||
# Add a directory in yunohost.multimedia
|
||||
|
@ -456,7 +302,7 @@ EOF
|
|||
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||
|
||||
systemctl restart fail2ban
|
||||
systemctl reload fail2ban
|
||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||
if [ -n "$fail2ban_error" ]
|
||||
then
|
||||
|
@ -471,7 +317,7 @@ EOF
|
|||
ynh_remove_fail2ban_config () {
|
||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||
sudo systemctl restart fail2ban
|
||||
systemctl reload fail2ban
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -487,6 +333,38 @@ ynh_read_manifest () {
|
|||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version
|
||||
ynh_app_upstream_version () {
|
||||
manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Read package version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number after ~ynh
|
||||
# In the last example it return 3
|
||||
#
|
||||
# usage: ynh_app_package_version
|
||||
ynh_app_package_version () {
|
||||
manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
# Exit without error if the package is up to date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of a package
|
||||
|
@ -569,8 +447,16 @@ Automatic diagnosis data from YunoHost
|
|||
|
||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||
|
||||
# Define binary to use for mail command
|
||||
if [ -e /usr/bin/bsd-mailx ]
|
||||
then
|
||||
local mail_bin=/usr/bin/bsd-mailx
|
||||
else
|
||||
local mail_bin=/usr/bin/mail.mailutils
|
||||
fi
|
||||
|
||||
# Send the email to the recipients
|
||||
echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -612,8 +498,6 @@ is_jessie () {
|
|||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
#============= FUTURE YUNOHOST HELPER ============
|
||||
#=================================================
|
||||
|
||||
# Delete a file checksum from the app settings
|
||||
|
@ -626,3 +510,66 @@ ynh_delete_file_checksum () {
|
|||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_delete $app $checksum_setting_name
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_ON () {
|
||||
# Create an html to serve as maintenance notice
|
||||
echo "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="3">
|
||||
<title>Your app $app is currently under maintenance!</title>
|
||||
<style>
|
||||
body {
|
||||
width: 70em;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Your app $app is currently under maintenance!</h1>
|
||||
<p>This app has been put under maintenance by your administrator at $(date)</p>
|
||||
<p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p>
|
||||
|
||||
</body>
|
||||
</html>" > "/var/www/html/maintenance.$app.html"
|
||||
|
||||
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
|
||||
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
|
||||
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
|
||||
# Use another location, to not be in conflict with the original config file
|
||||
location ${path_url}_maintenance/ {
|
||||
alias /var/www/html/ ;
|
||||
|
||||
try_files maintenance.$app.html =503;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||
|
||||
# The current config file will redirect all requests to the root of the app.
|
||||
# To keep the full path, we can use the following rewrite rule:
|
||||
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
|
||||
# The difference will be in the $1 at the end, which keep the following queries.
|
||||
# But, if it works perfectly for a html request, there's an issue with any php files.
|
||||
# This files are treated as simple files, and will be downloaded by the browser.
|
||||
# Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was.
|
||||
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
||||
ynh_maintenance_mode_OFF () {
|
||||
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
||||
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||
systemctl reload nginx
|
||||
|
||||
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
|
||||
sleep 4
|
||||
|
||||
# Then remove the temporary files used for the maintenance.
|
||||
rm "/var/www/html/maintenance.$app.html"
|
||||
rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
|
51
scripts/_sed
51
scripts/_sed
|
@ -1,51 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://github.com/YunoHost/yunohost/pull/394
|
||||
|
||||
# Substitute/replace a string (or expression) by another in a file
|
||||
#
|
||||
# usage: ynh_replace_string match_string replace_string target_file
|
||||
# | arg: match_string - String to be searched and replaced in the file
|
||||
# | arg: replace_string - String that will replace matches
|
||||
# | arg: target_file - File in which the string will be replaced.
|
||||
#
|
||||
# As this helper is based on sed command, regular expressions and
|
||||
# references to sub-expressions can be used
|
||||
# (see sed manual page for more information)
|
||||
ynh_replace_string () {
|
||||
local delimit=@
|
||||
local match_string=$1
|
||||
local replace_string=$2
|
||||
local workfile=$3
|
||||
|
||||
# Escape the delimiter if it's in the string.
|
||||
match_string=${match_string//${delimit}/"\\${delimit}"}
|
||||
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
||||
|
||||
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
|
||||
}
|
||||
|
||||
# Substitute/replace a password by another in a file
|
||||
#
|
||||
# usage: ynh_replace_password_string match_string replace_string target_file
|
||||
# | arg: match_string - String to be searched and replaced in the file
|
||||
# | arg: replace_string - String that will replace matches
|
||||
# | arg: target_file - File in which the string will be replaced.
|
||||
#
|
||||
# This helper will use ynh_replace_string, but as you can use special
|
||||
# characters, you can't use some regular expressions and sub-expressions.
|
||||
ynh_replace_password_string () {
|
||||
local match_string=$1
|
||||
local replace_string=$2
|
||||
local workfile=$3
|
||||
|
||||
# Escape any backslash to preserve them as simple backslash.
|
||||
match_string=${match_string//\\/"\\\\"}
|
||||
replace_string=${replace_string//\\/"\\\\"}
|
||||
|
||||
# Escape the & character, who has a special function in sed.
|
||||
match_string=${match_string//&/"\&"}
|
||||
replace_string=${replace_string//&/"\&"}
|
||||
|
||||
ynh_replace_string "$match_string" "$replace_string" "$workfile"
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source _sed
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
|
@ -38,6 +37,14 @@ test -n "$new_path" || new_path="/"
|
|||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
path_url=$old_path
|
||||
domain=$old_domain
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
@ -135,3 +142,11 @@ ynh_system_reload nginx
|
|||
|
||||
# Wait for lutim fully started
|
||||
ynh_check_starting "Manager.*started" "/var/log/$app/production.log" "120"
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
path_url=$old_path
|
||||
domain=$old_domain
|
||||
ynh_maintenance_mode_OFF
|
||||
|
|
|
@ -55,6 +55,12 @@ ynh_app_setting_set $app domain $domain
|
|||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app always_encrypt $always_encrypt
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
@ -197,6 +203,12 @@ ynh_check_starting "Manager.*started" "/var/log/$app/production.log" "120"
|
|||
# Set right permissions on new files created at first start
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_OFF
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
|
|
@ -46,6 +46,12 @@ ynh_webpath_available $domain $path_url \
|
|||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORE STEPS
|
||||
#=================================================
|
||||
|
@ -131,6 +137,12 @@ ynh_system_reload nginx
|
|||
# Wait for lutim fully started
|
||||
ynh_check_starting "Manager.*started" "/var/log/$app/production.log" "120"
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_OFF
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
|
|
@ -10,7 +10,6 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source _variables
|
||||
source _apt
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
|
@ -78,6 +77,12 @@ ynh_abort_if_errors
|
|||
|
||||
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -178,3 +183,9 @@ ynh_system_reload nginx
|
|||
|
||||
# Wait for lutim fully started
|
||||
ynh_check_starting "Manager.*started" "/var/log/$app/production.log" "120"
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_OFF
|
||||
|
|
Loading…
Reference in a new issue