2017-07-08 18:06:56 +02:00
#!/bin/bash
#=================================================
2019-01-06 02:32:27 +01:00
# EXEC_LOGIN_AS Helper
# Execute a command as another user with login
# (hence in user home dir, with prior loading of .profile, etc.)
# usage: exec_login_as USER COMMAND [ARG ...]
exec_login_as( ) {
local user = $1
shift 1
exec_as $user --login " $@ "
}
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as( ) {
local user = $1
shift 1
if [ [ $user = $( whoami) ] ] ; then
eval " $@ "
else
sudo -u " $user " " $@ "
fi
2017-07-08 18:06:56 +02:00
}
#=================================================
# PACKAGE CHECK BYPASSING...
#=================================================
IS_PACKAGE_CHECK ( ) { # Détermine une exécution en conteneur (Non testé)
return $( uname -n | grep -c 'pchecker_lxc' )
}
#=================================================
2017-12-27 13:08:59 +01:00
# EXPERIMENTAL HELPERS
2017-07-08 18:06:56 +02:00
#=================================================
# 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"
2017-12-27 13:08:59 +01:00
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)
}
2017-07-08 18:06:56 +02:00
ynh_use_nodejs ( ) {
nodejs_version = $( ynh_app_setting_get $app nodejs_version)
2017-12-27 13:08:59 +01:00
load_n_path = " [[ : $PATH : == *\": $n_install_dir /bin:\"* ]] || PATH=\" $n_install_dir /bin: $PATH \"; N_PREFIX= " $n_install_dir ""
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
nodejs_use_version = " $n_install_dir /bin/n -q $nodejs_version "
2017-07-08 18:06:56 +02:00
# "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
2017-12-27 13:08:59 +01:00
nodejs_version = " $1 "
2017-07-08 18:06:56 +02:00
local n_install_script = "https://git.io/n-install"
# Create $n_install_dir
2017-12-27 13:08:59 +01:00
mkdir -p " $n_install_dir "
2017-07-08 18:06:56 +02:00
# 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.
2017-12-27 13:08:59 +01:00
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
2017-07-08 18:06:56 +02:00
# If n is not previously setup, install it
2017-12-27 13:08:59 +01:00
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 "
2017-07-08 18:06:56 +02:00
# Restore /usr/local/bin in PATH
PATH = $CLEAR_PATH
# And replace the old node binary.
2017-12-27 13:08:59 +01:00
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
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Install the requested version of nodejs
n $nodejs_version
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# 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
2017-07-08 18:06:56 +02:00
# Store the ID of this app and the version of node requested for it
2017-12-27 13:08:59 +01:00
echo " $YNH_APP_ID : $nodejs_version " | tee --append " $n_install_dir /ynh_app_version "
2017-07-08 18:06:56 +02:00
# Store nodejs_version into the config of this app
ynh_app_setting_set $app nodejs_version $nodejs_version
2017-12-27 13:08:59 +01:00
# Build the update script and set the cronjob
ynh_cron_upgrade_node
2017-07-08 18:06:56 +02:00
ynh_use_nodejs
}
ynh_remove_nodejs ( ) {
ynh_use_nodejs
# Remove the line for this app
2017-12-27 13:08:59 +01:00
sed --in-place " / $YNH_APP_ID : $nodejs_version /d " " $n_install_dir /ynh_app_version "
2017-07-08 18:06:56 +02:00
# 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 "
2017-12-27 13:08:59 +01:00
ynh_secure_remove "/usr/local/n"
sed --in-place "/N_PREFIX/d" /root/.bashrc
2017-07-08 18:06:56 +02:00
fi
}
2017-12-27 13:08:59 +01:00
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
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
chmod +x " $n_install_dir /node_update.sh "
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# 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
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
chmod +x "/etc/cron.daily/node_update"
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
#=================================================
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Start or restart a service and follow its booting
#
# usage: ynh_check_starting "Line to match" [Log file] [Timeout]
#
# | 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
# /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.
ynh_check_starting ( ) {
local line_to_match = " $1 "
local app_log = " ${ 2 :- /var/log/ $app / $app .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
}
echo " Starting of $app " >& 2
systemctl restart $app
local templog = " $( mktemp) "
# Following the starting of the app in its log
tail -f -n1 " $app_log " > " $templog " &
# Get the PID of the tail command
local pid_tail = $!
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_to_match " " $templog "
then
echo " The service $app has correctly started. " >& 2
break
fi
echo -n "." >& 2
sleep 1
done
if [ $i -eq $timeout ]
then
echo " The service $app didn't fully started before the timeout. " >& 2
2017-07-08 18:06:56 +02:00
fi
2017-12-27 13:08:59 +01:00
echo ""
ynh_clean_check_starting
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
#=================================================
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
ynh_print_log ( ) {
echo " ${ 1 } "
}
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Print an info on stdout
#
# usage: ynh_print_info "Text to print"
# | arg: text - The text to print
ynh_print_info ( ) {
ynh_print_log " [INFO] ${ 1 } "
}
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Print a warning on stderr
#
# usage: ynh_print_warn "Text to print"
# | arg: text - The text to print
ynh_print_warn ( ) {
ynh_print_log " [WARN] ${ 1 } " >& 2
}
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Print a error on stderr
#
# usage: ynh_print_err "Text to print"
# | arg: text - The text to print
ynh_print_err ( ) {
ynh_print_log " [ERR] ${ 1 } " >& 2
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Execute a command and print the result as an error
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_exec_err command to execute
# usage: ynh_exec_err "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# | arg: command - command to execute
ynh_exec_err ( ) {
ynh_print_err " $( eval $@ ) "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Execute a command and print the result as a warning
#
# usage: ynh_exec_warn command to execute
# usage: ynh_exec_warn "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_warn ( ) {
ynh_print_warn " $( eval $@ ) "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Execute a command and force the result to be printed on stdout
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_exec_warn_less command to execute
# usage: ynh_exec_warn_less "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# | arg: command - command to execute
ynh_exec_warn_less ( ) {
eval $@ 2>& 1
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Execute a command and redirect stdout in /dev/null
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_exec_quiet command to execute
# usage: ynh_exec_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# | arg: command - command to execute
ynh_exec_quiet ( ) {
eval $@ > /dev/null
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Execute a command and redirect stdout and stderr in /dev/null
#
# usage: ynh_exec_fully_quiet command to execute
# usage: ynh_exec_fully_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_fully_quiet ( ) {
eval $@ > /dev/null 2>& 1
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Remove any logs for all the following commands.
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_print_OFF
# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging.
ynh_print_OFF ( ) {
set +x
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Restore the logging after ynh_print_OFF
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_print_ON
ynh_print_ON ( ) {
set -x
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
echo ynh_print_ON > /dev/null
}
#=================================================
# Install or update the main directory yunohost.multimedia
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# 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
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Add a directory in yunohost.multimedia
# This "directory" will be a symbolic link to a existing directory.
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
#
# | arg: Source directory - The real directory which contains your medias.
# | arg: Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
ynh_multimedia_addfolder ( ) {
local source_dir = " $1 "
local dest_dir = " $2 "
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source= " $source_dir " --dest= " $dest_dir "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Move a directory in yunohost.multimedia, and replace by a symbolic link
#
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
#
# | arg: Source directory - The real directory which contains your medias.
# It will be moved to "Destination directory"
# A symbolic link will replace it.
# | arg: Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
ynh_multimedia_movefolder ( ) {
local source_dir = " $1 "
local dest_dir = " $2 "
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source= " $source_dir " --dest= " $dest_dir "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Allow an user to have an write authorisation in multimedia directories
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_multimedia_addaccess user_name
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# | arg: user_name - The name of the user which gain this access.
ynh_multimedia_addaccess ( ) {
local user_name = $1
groupadd -f multimedia
usermod -a -G multimedia $user_name
}
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
#=================================================
# Create a dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
# | arg: log_file - Log file to be checked by fail2ban
# | arg: failregex - Failregex to be looked for by fail2ban
# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3
# | arg: ports - Ports blocked for a banned IP address - default: http,https
ynh_add_fail2ban_config ( ) {
# Process parameters
logpath = $1
failregex = $2
max_retry = ${ 3 :- 3 }
ports = ${ 4 :- http ,https }
test -n " $logpath " || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
test -n " $failregex " || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
finalfail2banjailconf = " /etc/fail2ban/jail.d/ $app .conf "
finalfail2banfilterconf = " /etc/fail2ban/filter.d/ $app .conf "
ynh_backup_if_checksum_is_different " $finalfail2banjailconf " 1
ynh_backup_if_checksum_is_different " $finalfail2banfilterconf " 1
sudo tee $finalfail2banjailconf <<EOF
[ $app ]
enabled = true
port = $ports
filter = $app
logpath = $logpath
maxretry = $max_retry "
EOF
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
sudo tee $finalfail2banfilterconf <<EOF
[ INCLUDES]
before = common.conf
[ Definition]
failregex = $failregex
ignoreregrex = "
EOF
ynh_store_file_checksum " $finalfail2banjailconf "
ynh_store_file_checksum " $finalfail2banfilterconf "
sudo systemctl restart fail2ban
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Remove the dedicated fail2ban config (jail and filter conf files)
2017-07-08 18:06:56 +02:00
#
2017-12-27 13:08:59 +01:00
# usage: ynh_remove_fail2ban_config
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
}
#=================================================
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key
# | arg: manifest - Path of the manifest to read
# | arg: key - Name of the key to find
ynh_read_manifest ( ) {
manifest = " $1 "
key = " $2 "
python3 -c " import sys, json;print(json.load(open(' $manifest '))[' $key ']) "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
# Exit without error if the package is up to date
#
# This helper should be used to avoid an upgrade of a package
# when it's not needed.
#
# To force an upgrade, even if the package is up to date,
# you have to set the variable YNH_FORCE_UPGRADE before.
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
#
# usage: ynh_abort_if_up_to_date
ynh_abort_if_up_to_date ( ) {
local force_upgrade = ${ YNH_FORCE_UPGRADE :- 0 }
local package_check = ${ PACKAGE_CHECK_EXEC :- 0 }
local version = $( ynh_read_manifest " /etc/yunohost/apps/ $YNH_APP_INSTANCE_NAME /manifest.json " "version" || echo 1.0)
local last_version = $( ynh_read_manifest "../manifest.json" "version" || echo 1.0)
if [ " $version " = " $last_version " ]
2017-07-08 18:06:56 +02:00
then
2017-12-27 13:08:59 +01:00
if [ " $force_upgrade " != "0" ]
then
echo "Upgrade forced by YNH_FORCE_UPGRADE." >& 2
unset YNH_FORCE_UPGRADE
elif [ " $package_check " != "0" ]
2017-07-08 18:06:56 +02:00
then
2017-12-27 13:08:59 +01:00
echo "Upgrade forced for package check." >& 2
2017-07-08 18:06:56 +02:00
else
2017-12-27 13:08:59 +01:00
ynh_die "Up-to-date, nothing to do" 0
2017-07-08 18:06:56 +02:00
fi
fi
}
2017-12-27 13:08:59 +01:00
#=================================================
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin( ) {
2018-07-11 10:17:59 +02:00
local app_message = " ${ 1 :- ...No specific information... } "
2017-12-27 13:08:59 +01:00
local recipients = " ${ 2 :- root } "
# Retrieve the email of users
find_mails ( ) {
local list_mails = " $1 "
local mail
local recipients = " "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ " $mail " = "root" ] || echo " $mail " | grep --quiet "@"
then
recipients = " $recipients $mail "
else
# But replace an user name without a domain after by its email
if mail = $( ynh_user_get_info " $mail " "mail" 2> /dev/null)
then
recipients = " $recipients $mail "
fi
fi
done
echo " $recipients "
}
recipients = $( find_mails " $recipients " )
local mail_subject = " ☁️🆈🅽🅷☁️: \` $app \` was just installed! "
local mail_message = " This is an automated message from your beloved YunoHost server.
2018-07-11 10:17:59 +02:00
Specific information for the application $app .
2017-12-27 13:08:59 +01:00
$app_message
2018-07-11 10:17:59 +02:00
2017-12-27 13:08:59 +01:00
---
Automatic diagnosis data from YunoHost
2018-07-11 10:17:59 +02:00
2017-12-27 13:08:59 +01:00
$( yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d' ) "
2018-07-11 10:17:59 +02:00
# 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
2017-12-27 13:08:59 +01:00
# Send the email to the recipients
2018-07-11 10:17:59 +02:00
echo " $mail_message " | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s " $mail_subject " " $recipients "
2017-07-08 18:06:56 +02:00
}
2017-12-27 13:08:59 +01:00
#=================================================
#============= FUTURE YUNOHOST HELPER ============
#=================================================
2017-07-08 18:06:56 +02:00
2017-12-27 13:08:59 +01:00
# Delete a file checksum from the app settings
2017-07-08 18:06:56 +02:00
#
# $app should be defined when calling this helper
#
2017-12-27 13:08:59 +01:00
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum ( ) {
2017-07-08 18:06:56 +02:00
local checksum_setting_name = checksum_${ 1 //[ \/ ]/_ } # Replace all '/' and ' ' by '_'
2017-12-28 16:23:13 +01:00
ynh_app_setting_delete $app $checksum_setting_name
}