mirror of
https://github.com/YunoHost-Apps/lufi_ynh.git
synced 2024-09-03 19:36:28 +02:00
commit
5f595a2d07
15 changed files with 261 additions and 306 deletions
|
@ -9,8 +9,7 @@
|
||||||
listen => ['http://127.0.0.1:__PORT__'],
|
listen => ['http://127.0.0.1:__PORT__'],
|
||||||
# if you use Lufi behind a reverse proxy like Nginx, you want ro set proxy to 1
|
# if you use Lufi behind a reverse proxy like Nginx, you want ro set proxy to 1
|
||||||
# if you use Lufi directly, let it commented
|
# if you use Lufi directly, let it commented
|
||||||
#proxy => 1,
|
proxy => 1,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# put a way to contact you here and uncomment it
|
# put a way to contact you here and uncomment it
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
# LDIR is the path where you installed Lufi
|
|
||||||
# It has to end with a final /
|
|
||||||
LDIR=__FINALPATH__
|
|
||||||
|
|
||||||
# USER is the user who will launch Lufi
|
|
||||||
USER=www-data
|
|
198
conf/lufi.init
198
conf/lufi.init
|
@ -1,198 +0,0 @@
|
||||||
|
|
||||||
#!/bin/sh
|
|
||||||
# vim: set ts=4 sw=4 sts=4 tw=0:
|
|
||||||
# vim: set expandtab:
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: lufi
|
|
||||||
# Required-Start: $local_fs $remote_fs $network $syslog
|
|
||||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: starts lufi with hypnotoad
|
|
||||||
# Description: starts lufi with hypnotoad
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
||||||
DAEMON=script/lutim
|
|
||||||
NAME=lufi
|
|
||||||
DESC=lufi
|
|
||||||
|
|
||||||
if [ -f "/etc/default/lufi" ]
|
|
||||||
then
|
|
||||||
. /etc/default/lutim
|
|
||||||
if [ -z $LDIR ]
|
|
||||||
then
|
|
||||||
echo "LDIR variable is empty, please fill it in /etc/default/lufi"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if [ -z $USER ]
|
|
||||||
then
|
|
||||||
echo "USER variable is empty, please fill it in /etc/default/lufi"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Missing /etc/default/lutim file"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$LDIR$DAEMON" ]
|
|
||||||
then
|
|
||||||
echo "Missing $LDIR$DAEMON file"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
|
|
||||||
do_start()
|
|
||||||
{
|
|
||||||
# Return
|
|
||||||
# 0 if daemon has been started
|
|
||||||
# 1 if daemon was already running
|
|
||||||
# 2 if daemon could not be started
|
|
||||||
|
|
||||||
cd $LDIR
|
|
||||||
su $USER -c "carton exec hypnotoad $DAEMON >> /var/log/lufi/production.log 2>&1"
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_stop()
|
|
||||||
{
|
|
||||||
# Return
|
|
||||||
# 0 if daemon has been stopped
|
|
||||||
# 1 if daemon was already stopped
|
|
||||||
# 2 if daemon could not be stopped
|
|
||||||
# other if a failure occurred
|
|
||||||
|
|
||||||
cd $LDIR
|
|
||||||
su $USER -c "carton exec hypnotoad -s $DAEMON >> /var/log/lufi/production.log 2>&1"
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_status()
|
|
||||||
{
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]; then
|
|
||||||
log_progress_msg "$NAME is running"
|
|
||||||
else
|
|
||||||
log_failure_msg "$NAME is NOT running but PID file exists"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_failure_msg "$NAME is NOT running"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
log_daemon_msg "Starting $NAME"
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]
|
|
||||||
then
|
|
||||||
log_progress_msg "$NAME is already running. Unable to start."
|
|
||||||
log_end_msg 1;
|
|
||||||
else
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_failure_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_failure_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
log_daemon_msg "Stopping $NAME"
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]; then
|
|
||||||
do_stop
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log_failure_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
log_failure_msg "$NAME is NOT running. Unable to stop"
|
|
||||||
log_end_msg 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_failure_msg "$NAME is NOT running. Unable to stop"
|
|
||||||
log_end_msg 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
log_daemon_msg "Checking $NAME status"
|
|
||||||
do_status
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
log_daemon_msg "Reloading $NAME"
|
|
||||||
do_start
|
|
||||||
sleep 1
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_failure_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
log_daemon_msg "Restarting $NAME"
|
|
||||||
do_stop
|
|
||||||
sleep 6
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_failure_msg "failed";
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|status|reload|restart}" >&2
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -2,35 +2,37 @@ location __PATH__ {
|
||||||
if ($scheme = http) {
|
if ($scheme = http) {
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
}
|
}
|
||||||
location ~ [^/]\.php(/|$) {
|
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
|
||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
|
||||||
|
|
||||||
# This is important for user's privacy !
|
# This is important for user's privacy !
|
||||||
access_log off;
|
access_log off;
|
||||||
error_log /var/log/nginx/lutim.error.log;
|
error_log /var/log/nginx/lufi.error.log;
|
||||||
|
|
||||||
# This is important ! Make it OK with your Lutim configuration
|
# This is important ! Make it OK with your Lutim configuration
|
||||||
client_max_body_size 40M;
|
client_max_body_size 40M;
|
||||||
|
|
||||||
proxy_pass http://127.0.0.1:__PORT__;
|
if ($request_uri ~* ^/(img|css|font|js)/) {
|
||||||
|
add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT";
|
||||||
|
add_header Cache-Control "public, max-age=315360000";
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy_pass http://127.0.0.1:__PORT__/__PATH__;
|
||||||
|
|
||||||
|
# Really important ! Lufi uses WebSocket, it won't work without this
|
||||||
|
proxy_set_header Upgrade $http_upgrade ;
|
||||||
|
proxy_set_header Connection "upgrade" ;
|
||||||
|
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
# Lutim reads this header and understands that the current session is actually HTTPS.
|
# If you want to log the remote port of the file senders, you'll need that
|
||||||
# Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port $
|
proxy_set_header X-Remote-Port $remote_port;
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$
|
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
|
|
||||||
|
#--PRIVATE--# Include SSOWAT user panel.
|
||||||
|
#--PRIVATE--include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the Lutim administrator (must be an existing YunoHost user)",
|
"en": "Choose the Lufi administrator (must be an existing YunoHost user)",
|
||||||
"fr": "Choisissez un administrateur Lufi (doit être un utilisateur YunoHost)"
|
"fr": "Choisissez un administrateur Lufi (doit être un utilisateur YunoHost)"
|
||||||
},
|
},
|
||||||
"example": "john"
|
"example": "john"
|
||||||
|
|
|
@ -1,34 +1,42 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
ynh_version="2.4"
|
||||||
# $1 = Variable à vérifier
|
|
||||||
# $2 = Texte à afficher en cas d'erreur
|
YNH_VERSION () { # Returns the version number of the Yunohost moulinette
|
||||||
|
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_VAR () { # Verifies that the variable is not empty.
|
||||||
|
# $1 = Variable to be checked
|
||||||
|
# $2 = Display text on error
|
||||||
test -n "$1" || (echo "$2" >&2 && false)
|
test -n "$1" || (echo "$2" >&2 && false)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
|
EXIT_PROPERLY () { # Causes the script to stop in the event of an error. And clean the residue.
|
||||||
exit_code=$?
|
trap '' ERR
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
|
||||||
exit 0 # Quitte sans erreur si le script se termine correctement.
|
|
||||||
fi
|
|
||||||
trap '' EXIT
|
|
||||||
set +eu
|
|
||||||
echo -e "\e[91m \e[1m" # Shell in light red bold
|
echo -e "\e[91m \e[1m" # Shell in light red bold
|
||||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
|
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
|
||||||
|
|
||||||
if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter.
|
if type -t CLEAN_SETUP > /dev/null; then # Checks the existence of the function before executing it.
|
||||||
CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
|
CLEAN_SETUP # Call the specific cleanup function of the install script.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation.
|
# Compensates the ssowat bug that does not remove the app's input in case of installation error.
|
||||||
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
|
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
|
||||||
|
|
||||||
|
if [ "$ynh_version" = "2.2" ]; then
|
||||||
|
/bin/bash $script_dir/remove
|
||||||
|
fi
|
||||||
|
|
||||||
ynh_die
|
ynh_die
|
||||||
}
|
}
|
||||||
|
|
||||||
TRAP_ON () { # Activate signal capture
|
TRAP_ON () { # Activate signal capture
|
||||||
set -eu # Exit if a command fail, and if a variable is used unset.
|
trap EXIT_PROPERLY ERR # Capturing exit signals on error
|
||||||
trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script
|
}
|
||||||
|
|
||||||
|
TRAP_OFF () { # Ignoring signal capture until TRAP_ON
|
||||||
|
trap '' ERR # Ignoring exit signals
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_USER () { # Vérifie la validité de l'user admin
|
CHECK_USER () { # Vérifie la validité de l'user admin
|
||||||
|
@ -73,13 +81,13 @@ GENERATE_DB () { # Créer une base de données et un utilisateur dédié au nom
|
||||||
}
|
}
|
||||||
|
|
||||||
SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path
|
SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path
|
||||||
# $1 = Nom de l'archive téléchargée.
|
src=$(cat ../sources/source_md5 | awk -F' ' {'print $2'})
|
||||||
wget -nv -i ../sources/source_url -O $1
|
sudo wget -nv -i ../sources/source_url -O $src
|
||||||
# Décompresse la source
|
# Décompresse la source
|
||||||
if [ "$(echo ${1##*.})" == "gz" ]; then
|
if [ "$(echo ${src##*.})" == "gz" ]; then
|
||||||
tar -x -f $1
|
tar -x -f $src
|
||||||
elif [ "$(echo ${1##*.})" == "zip" ]; then
|
elif [ "$(echo ${src##*.})" == "zip" ]; then
|
||||||
unzip -q $1
|
unzip -q $src
|
||||||
else
|
else
|
||||||
false # Format d'archive non pris en charge.
|
false # Format d'archive non pris en charge.
|
||||||
fi
|
fi
|
||||||
|
|
26
scripts/backup
Normal file
26
scripts/backup
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Get multi-instances specific variables
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve app settings
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
|
# Copy the app files
|
||||||
|
final_path="/var/www/${app}"
|
||||||
|
ynh_backup "${final_path}" "sources" 1
|
||||||
|
|
||||||
|
# Copy the nginx conf files
|
||||||
|
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||||
|
|
||||||
|
# Copy the lufi fonf file
|
||||||
|
ynh_backup "${final_path}/lufi.conf" "lufi.conf"
|
||||||
|
ynh_backup "/etc/systemd/system/lufi.service" "systemd_lufi.service"
|
||||||
|
ynh_backup "/etc/cron.d/${app}" "cron_lufi"
|
||||||
|
ynh_backup "/etc/logrotate.d/${app}" "logrotate_lufi"
|
|
@ -1,13 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
source .fonctions # Loads the generic functions usually used in the script
|
||||||
|
source /usr/share/yunohost/helpers # Source app helpers
|
||||||
|
|
||||||
CLEAN_SETUP () {
|
CLEAN_SETUP () {
|
||||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
# Clean installation residues that are not supported by the remove script.
|
||||||
# Pas de nettoyage supplémentaire nécessaire ici...
|
# Clean hosts
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
TRAP_ON # Active trap pour arrêter le script si une erreur est détectée.
|
TRAP_ON # Active trap to stop the script if an error is detected.
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
@ -17,16 +21,12 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
script_dir=$PWD
|
script_dir=$PWD
|
||||||
|
|
||||||
# Vérifie que les variables ne sont pas vides.
|
# Vérifie que les variables ne sont pas vides.
|
||||||
CHECK_VAR "$app" "app name not set"
|
CHECK_VAR "$app" "app name not set"
|
||||||
CHECK_VAR "$script_dir" "script_dir not set"
|
CHECK_VAR "$script_dir" "script_dir not set"
|
||||||
|
|
||||||
|
|
||||||
CHECK_USER "$admin" # Vérifie la validité de l'user admin
|
CHECK_USER "$admin" # Vérifie la validité de l'user admin
|
||||||
|
|
||||||
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
CHECK_PATH # Vérifie et corrige la syntaxe du path.
|
||||||
|
@ -38,7 +38,7 @@ CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilis
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
CHECK_VAR "$domain_regex" "domain_regex empty"
|
CHECK_VAR "$domain_regex" "domain_regex empty"
|
||||||
|
|
||||||
FIND_PORT 8095 # Cherche un port libre.
|
FIND_PORT 8080 # Cherche un port libre.
|
||||||
|
|
||||||
# Enregistre les infos dans la config YunoHost
|
# Enregistre les infos dans la config YunoHost
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set $app admin $admin
|
||||||
|
@ -48,53 +48,42 @@ ynh_app_setting_set $app port $port
|
||||||
|
|
||||||
|
|
||||||
# Créer le repertoire de destination et stocke son emplacement.
|
# Créer le repertoire de destination et stocke son emplacement.
|
||||||
sudo mkdir "$final_path"
|
sudo mkdir "${final_path}"
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
|
||||||
SETUP_SOURCE "lufi.tar.gz" # Télécharge la source, décompresse et copie dans $final_path
|
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path
|
||||||
|
|
||||||
# Copie le fichier de config nginx
|
# Copie le fichier de config nginx
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
if [ "$is_public" = "Yes" ];
|
||||||
|
then
|
||||||
|
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
fi
|
||||||
|
|
||||||
# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl
|
# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl
|
||||||
sudo apt-get update
|
ynh_package_update
|
||||||
sudo apt-get install carton perlmagick -qy
|
ynh_package_install carton
|
||||||
|
ynh_package_install perlmagick
|
||||||
|
|
||||||
## Copie et configuration du fichier de conf.
|
## Copie et configuration du fichier de conf.
|
||||||
sudo cp ../conf/lufi.conf.template "$final_path/lufi.conf"
|
sudo cp ../conf/lufi.conf.template "${final_path}/lufi.conf"
|
||||||
sudo sed -i "s@__DOMAIN__@$domain@g" "$final_path/lufi.conf"
|
sudo sed -i "s@__DOMAIN__@$domain@g" "${final_path}/lufi.conf"
|
||||||
sudo sed -i "s@__PATH__@$path@g" "$final_path/lufi.conf"
|
sudo sed -i "s@__PATH__@$path@g" "${final_path}/lufi.conf"
|
||||||
sudo sed -i "s@__PORT__@$port@g" "$final_path/lufi.conf"
|
sudo sed -i "s@__PORT__@$port@g" "${final_path}/lufi.conf"
|
||||||
|
|
||||||
sudo sed -i "s@__ENCRYPT__@$always_encrypt@g" "$final_path/lufi.conf"
|
#sudo sed -i "s@__ENCRYPT__@$always_encrypt@g" "${final_path}/lufi.conf"
|
||||||
secret=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
secret=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||||
CHECK_VAR "$secret" "secret empty"
|
CHECK_VAR "$secret" "secret empty"
|
||||||
sudo sed -i "s@__SECRET__@$secret@g" "$final_path/lufi.conf"
|
sudo sed -i "s@__SECRET__@$secret@g" "${final_path}/lufi.conf"
|
||||||
STORE_MD5_CONFIG "lufi.conf" "$final_path/lufi.conf" # Enregistre la somme de contrôle du fichier de config
|
STORE_MD5_CONFIG "lufi.conf" "${final_path}/lufi.conf" # Enregistre la somme de contrôle du fichier de config
|
||||||
|
|
||||||
|
|
||||||
codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2)
|
|
||||||
CHECK_VAR "$codename" "codename empty"
|
|
||||||
ynh_app_setting_set $app codename $codename
|
|
||||||
if [ "$codename" = "wheezy" ]
|
|
||||||
then # On utilise le script init pour wheezy.
|
|
||||||
# Mise en place du script init
|
|
||||||
sudo cp ../conf/lufi.init /etc/init.d/lufi
|
|
||||||
sudo cp ../conf/lufi.default /etc/default/lufi
|
|
||||||
sudo chmod +x /etc/init.d/lufi
|
|
||||||
sudo chown root: /etc/init.d/lufi /etc/default/lufi
|
|
||||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lufi
|
|
||||||
## Démarrage auto du service
|
|
||||||
sudo update-rc.d lufi defaults
|
|
||||||
else # Et le script systemd à partir de jessie
|
|
||||||
# Mise en place du script systemd
|
# Mise en place du script systemd
|
||||||
sudo cp ../conf/lufi.service /etc/systemd/system/lufi.service
|
sudo cp ../conf/lufi.service /etc/systemd/system/lufi.service
|
||||||
sudo chown root: /etc/systemd/system/lufi.service
|
sudo chown root: /etc/systemd/system/lufi.service
|
||||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/lufi.service
|
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/lufi.service
|
||||||
## Démarrage auto du service
|
## Démarrage auto du service
|
||||||
sudo systemctl enable lufi.service
|
sudo systemctl enable lufi.service
|
||||||
fi
|
|
||||||
|
|
||||||
## Mise en place des crons
|
## Mise en place des crons
|
||||||
sudo cp ../conf/cron_lufi /etc/cron.d/$app
|
sudo cp ../conf/cron_lufi /etc/cron.d/$app
|
||||||
|
@ -109,6 +98,7 @@ sudo cp ../conf/logrotate /etc/logrotate.d/$app
|
||||||
sudo mkdir -p /var/log/$app/
|
sudo mkdir -p /var/log/$app/
|
||||||
cd $final_path
|
cd $final_path
|
||||||
sudo carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log"
|
sudo carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log"
|
||||||
|
# sudo carton exec hypnotoad script/lufi
|
||||||
|
|
||||||
# Configure le path du dossier perl en fonction de l'architecture système
|
# Configure le path du dossier perl en fonction de l'architecture système
|
||||||
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
|
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
|
||||||
|
@ -143,16 +133,22 @@ sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
|
|
||||||
# Start lufi
|
# Start lufi
|
||||||
sudo service lufi start
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl start lufi.service
|
||||||
|
sudo systemctl enable lufi.service
|
||||||
|
|
||||||
# Set right permissions on new files created at first start
|
# Set right permissions on new files created at first start
|
||||||
sudo chown -R www-data: "$final_path"
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
|
|
||||||
# Add lufi as a service
|
# Add lufi as a service
|
||||||
sudo yunohost service add lufi -l $final_path/log/production.log
|
sudo yunohost service add lufi -l $final_path/log/production.log
|
||||||
|
|
||||||
|
if [ "$is_public" = "No" ];
|
||||||
|
then
|
||||||
|
# Retire l'accès public
|
||||||
|
ynh_app_setting_delete $app unprotected_uris
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
fi
|
||||||
|
|
||||||
# Recharge la configuration Nginx
|
# Recharge la configuration Nginx
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
# Régénère la configuration de SSOwat
|
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -u
|
||||||
|
|
||||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||||
|
source /usr/share/yunohost/helpers # Source app helpers
|
||||||
|
|
||||||
# Récupère les infos de l'application.
|
# Récupère les infos de l'application.
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
# Arrêt du service
|
# Arrêt du service
|
||||||
if [ -e "/etc/init.d/lufi" ]; then
|
|
||||||
echo "Delete init.d script"
|
|
||||||
sudo service lufi stop
|
|
||||||
sudo rm "/etc/init.d/lufi"
|
|
||||||
sudo rm "/etc/default/lufi"
|
|
||||||
sudo update-rc.d -f lufi remove
|
|
||||||
fi
|
|
||||||
if [ -e "/etc/systemd/system/lufi.service" ]; then
|
if [ -e "/etc/systemd/system/lufi.service" ]; then
|
||||||
echo "Delete systemd script"
|
echo "Delete systemd script"
|
||||||
sudo service lufi stop
|
sudo service lufi stop
|
||||||
|
@ -46,6 +40,9 @@ SECURE_REMOVE '/var/log/$app/' # Suppression des log
|
||||||
|
|
||||||
REMOVE_LOGROTATE_CONF # Suppression de la configuration de logrotate
|
REMOVE_LOGROTATE_CONF # Suppression de la configuration de logrotate
|
||||||
|
|
||||||
|
ynh_package_remove carton || echo "ShellInABox already uninstalled"
|
||||||
|
ynh_package_remove perlmagick || echo "perlmagick already uninstalled"
|
||||||
|
|
||||||
# Régénère la configuration de SSOwat
|
# Régénère la configuration de SSOwat
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
|
85
scripts/restore
Normal file
85
scripts/restore
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# This restore script is adapted to Yunohost >=2.4
|
||||||
|
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# The parameter $app is the id of the app instance ex: ynhexample__2
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Get old parameter of the app
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path=$(ynh_app_setting_get $app path)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
|
# Check domain/path availability
|
||||||
|
sudo yunohost app checkurl "${domain}${path}" -a "${app}" \
|
||||||
|
|| ynh_die "Path not available: ${domain}${path}"
|
||||||
|
|
||||||
|
# Check $final_path
|
||||||
|
final_path="/var/www/${app}"
|
||||||
|
if [ -d "${final_path}" ]; then
|
||||||
|
ynh_die "There is already a directory: ${final_path}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check configuration files nginx
|
||||||
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
if [ -f "${nginx_conf}" ]; then
|
||||||
|
ynh_die "The NGINX configuration already exists at '${nginx_conf}'. You should safely delete it before restoring this app."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check configuration files lufi
|
||||||
|
lufi_conf="${final_path}/lufi.conf"
|
||||||
|
if [ -f "${lufi_conf}" ]; then
|
||||||
|
ynh_die "The LUFI CONF configuration already exists at '${lufi_conf}'. You should safely delete it before restoring this app."
|
||||||
|
fi
|
||||||
|
|
||||||
|
lufi_systemd="/etc/systemd/system/lufi.service"
|
||||||
|
if [ -f "${lufi_default}" ]; then
|
||||||
|
ynh_die "The LUFI SYSTEMD configuration already exists at '${lufi_systemd}'. You should safely delete it before restoring this app."
|
||||||
|
fi
|
||||||
|
|
||||||
|
lufi_cron="/etc/cron.d/${app}"
|
||||||
|
if [ -f "${lufi_cron}" ]; then
|
||||||
|
ynh_die "The LUFI CRONTAB configuration already exists at '${lufi_cron}'. You should safely delete it before restoring this app."
|
||||||
|
fi
|
||||||
|
|
||||||
|
lufi_logrotate="/etc/logrotate.d/${app}"
|
||||||
|
if [ -f "${lufi_logrotate}" ]; then
|
||||||
|
ynh_die "The LUFI LOGROTATE configuration already exists at '${lufi_logrotate}'. You should safely delete it before restoring this app."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restore sources & data
|
||||||
|
sudo cp -a ./sources "${final_path}"
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
sudo chown -R www-data: "${final_path}"
|
||||||
|
|
||||||
|
# Restore nginx configuration files
|
||||||
|
sudo cp -a ./nginx.conf "${nginx_conf}"
|
||||||
|
# Restore php-fpm configuration files
|
||||||
|
sudo cp -a ./php-fpm.conf "${phpfpm_conf}"
|
||||||
|
sudo cp -a ./php-fpm.ini "${phpfpm_ini}"
|
||||||
|
|
||||||
|
# Restore lufi configuration files
|
||||||
|
sudo cp -a ./lufi.conf "${lufi_conf}"
|
||||||
|
|
||||||
|
# Restore service
|
||||||
|
sudo cp -a ./systemd_lufi.service "${lufi_systemd}"
|
||||||
|
|
||||||
|
sudo cp -a ./cron_lufi "${lufi_cron}"
|
||||||
|
sudo cp -a ./logrotate_lufi "${lufi_logrotate}"
|
||||||
|
|
||||||
|
# Set ssowat config
|
||||||
|
if [ "$is_public" = "No" ];
|
||||||
|
then
|
||||||
|
ynh_app_setting_delete $app skipped_uris
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reload services
|
||||||
|
sudo systemctl reload php5-fpm
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
sudo yunohost app ssowatconf
|
44
scripts/upgrade
Normal file
44
scripts/upgrade
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
source .fonctions # Loads the generic functions usually used in the script
|
||||||
|
source /usr/share/yunohost/helpers # Source YunoHost helpers
|
||||||
|
|
||||||
|
# See comments in install script
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve app settings
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path=$(ynh_app_setting_get $app path)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
|
CHECK_PATH # Checks and corrects the syntax of the path.
|
||||||
|
|
||||||
|
final_path=/var/www/$app
|
||||||
|
|
||||||
|
# Get source
|
||||||
|
SETUP_SOURCE
|
||||||
|
|
||||||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
|
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
|
if [ "$is_public" = "Yes" ];
|
||||||
|
then
|
||||||
|
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup SSOwat
|
||||||
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
|
if [ "$is_public" = "Yes" ];
|
||||||
|
then
|
||||||
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reload Nginx
|
||||||
|
sudo systemctl reload php5-fpm
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
sudo yunohost app ssowatconf
|
1
sources/source_dir
Normal file
1
sources/source_dir
Normal file
|
@ -0,0 +1 @@
|
||||||
|
lufi-master-7db7688bc1e8bbe206f6717c98ece78d6e6a05fe
|
1
sources/source_md5
Normal file
1
sources/source_md5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
97091eb255f4b3389fd52e36b7860c1e lufi.zip
|
|
@ -1 +1 @@
|
||||||
https://git.framasoft.org/luc/lutim/repository/archive.tar.gz?ref=master
|
https://git.framasoft.org/luc/lufi/repository/archive.zip?ref=master
|
Loading…
Reference in a new issue