mirror of
https://github.com/YunoHost-Apps/lufi_ynh.git
synced 2024-09-03 19:36:28 +02:00
Install ok, bug with static file, check nginx config
This commit is contained in:
parent
c6be09aac5
commit
917e75e94d
8 changed files with 117 additions and 74 deletions
|
@ -9,13 +9,17 @@
|
|||
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 directly, let it commented
|
||||
#proxy => 1,
|
||||
|
||||
proxy => 1,
|
||||
|
||||
# Please read http://mojolicious.org/perldoc/Mojo/Server/Hypnotoad#workers
|
||||
# to adjust this to your server
|
||||
workers => 30,
|
||||
clients => 1,
|
||||
},
|
||||
|
||||
# put a way to contact you here and uncomment it
|
||||
# MANDATORY
|
||||
contact => 'webmaster@__DOMAIN__',
|
||||
contact => 'webmaster@__DOMAIN__',
|
||||
|
||||
# array of random strings used to encrypt cookies
|
||||
# optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT
|
||||
|
@ -79,7 +83,7 @@
|
|||
# example: you want to have Lufi under https://example.org/lufi/
|
||||
# => set prefix to '/lufi' or to '/lufi/', it doesn't matter
|
||||
# optional, defaut is /
|
||||
prefix => '__PATH__',
|
||||
prefix => '__PATH__/',
|
||||
|
||||
# array of authorized domains for API calls.
|
||||
# if you want to authorize everyone to use the API: ['*']
|
||||
|
|
|
@ -15,4 +15,4 @@ ExecStop=/usr/bin/carton exec hypnotoad -s script/lufi >> /var/log/lufi/producti
|
|||
ExecReload=/usr/bin/carton exec hypnotoad script/lufi >> /var/log/lufi/production.log 2>&1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=multi-user.target
|
|
@ -1,19 +1,8 @@
|
|||
location __PATH__ {
|
||||
if ($scheme = http) {
|
||||
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;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
# This is important for user's privacy !
|
||||
access_log off;
|
||||
error_log /var/log/nginx/lutim.error.log;
|
||||
|
@ -21,16 +10,29 @@ location __PATH__ {
|
|||
# This is important ! Make it OK with your Lutim configuration
|
||||
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__/;
|
||||
|
||||
# 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 X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# Lutim reads this header and understands that the current session is actually HTTPS.
|
||||
# Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port $
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
# If you want to log the remote port of the file senders, you'll need that
|
||||
proxy_set_header X-Remote-Port $remote_port;
|
||||
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$
|
||||
proxy_redirect off;
|
||||
|
||||
#--PRIVATE--# Include SSOWAT user panel.
|
||||
#--PRIVATE--include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"name": "admin",
|
||||
"type": "user",
|
||||
"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)"
|
||||
},
|
||||
"example": "john"
|
||||
|
|
|
@ -1,34 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
||||
# $1 = Variable à vérifier
|
||||
# $2 = Texte à afficher en cas d'erreur
|
||||
ynh_version="2.4"
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
|
||||
exit_code=$?
|
||||
if [ "$exit_code" -eq 0 ]; then
|
||||
exit 0 # Quitte sans erreur si le script se termine correctement.
|
||||
fi
|
||||
trap '' EXIT
|
||||
set +eu
|
||||
EXIT_PROPERLY () { # Causes the script to stop in the event of an error. And clean the residue.
|
||||
trap '' ERR
|
||||
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
|
||||
|
||||
if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter.
|
||||
CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
|
||||
if type -t CLEAN_SETUP > /dev/null; then # Checks the existence of the function before executing it.
|
||||
CLEAN_SETUP # Call the specific cleanup function of the install script.
|
||||
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
|
||||
|
||||
if [ "$ynh_version" = "2.2" ]; then
|
||||
/bin/bash $script_dir/remove
|
||||
fi
|
||||
|
||||
ynh_die
|
||||
}
|
||||
|
||||
TRAP_ON () { # Activate signal capture
|
||||
set -eu # Exit if a command fail, and if a variable is used unset.
|
||||
trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script
|
||||
trap EXIT_PROPERLY ERR # Capturing exit signals on error
|
||||
}
|
||||
|
||||
TRAP_OFF () { # Ignoring signal capture until TRAP_ON
|
||||
trap '' ERR # Ignoring exit signals
|
||||
}
|
||||
|
||||
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
|
||||
# $1 = Nom de l'archive téléchargée.
|
||||
wget -nv -i ../sources/source_url -O $1
|
||||
src=$(cat ../sources/source_md5 | awk -F' ' {'print $2'})
|
||||
sudo wget -nv -i ../sources/source_url -O $src
|
||||
# Décompresse la source
|
||||
if [ "$(echo ${1##*.})" == "gz" ]; then
|
||||
tar -x -f $1
|
||||
elif [ "$(echo ${1##*.})" == "zip" ]; then
|
||||
unzip -q $1
|
||||
if [ "$(echo ${src##*.})" == "gz" ]; then
|
||||
tar -x -f $src
|
||||
elif [ "$(echo ${src##*.})" == "zip" ]; then
|
||||
unzip -q $src
|
||||
else
|
||||
false # Format d'archive non pris en charge.
|
||||
fi
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
#!/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 () {
|
||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
||||
# Pas de nettoyage supplémentaire nécessaire ici...
|
||||
# Clean installation residues that are not supported by the remove script.
|
||||
# Clean hosts
|
||||
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
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
|
@ -17,16 +21,12 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
script_dir=$PWD
|
||||
|
||||
# Vérifie que les variables ne sont pas vides.
|
||||
CHECK_VAR "$app" "app name not set"
|
||||
CHECK_VAR "$script_dir" "script_dir not set"
|
||||
|
||||
|
||||
CHECK_USER "$admin" # Vérifie la validité de l'user admin
|
||||
|
||||
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')
|
||||
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
|
||||
ynh_app_setting_set $app admin $admin
|
||||
|
@ -48,31 +48,35 @@ ynh_app_setting_set $app port $port
|
|||
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
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
|
||||
sudo apt-get update
|
||||
sudo apt-get install carton perlmagick -qy
|
||||
ynh_package_update
|
||||
ynh_package_install carton
|
||||
ynh_package_install perlmagick
|
||||
|
||||
## Copie et configuration du fichier de 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@__PATH__@$path@g" "$final_path/lufi.conf"
|
||||
sudo sed -i "s@__PORT__@$port@g" "$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@__PATH__@$path@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')
|
||||
CHECK_VAR "$secret" "secret empty"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2)
|
||||
CHECK_VAR "$codename" "codename empty"
|
||||
|
@ -109,6 +113,7 @@ sudo cp ../conf/logrotate /etc/logrotate.d/$app
|
|||
sudo mkdir -p /var/log/$app/
|
||||
cd $final_path
|
||||
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
|
||||
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
|
||||
|
@ -119,6 +124,10 @@ then
|
|||
fi
|
||||
CHECK_VAR "$arch_dir" "arch_dir empty"
|
||||
sudo sed -i "s@__ARCHDIR__@$arch_dir@g" "$final_path/script/lufi"
|
||||
# TODO: fix a bug service restart
|
||||
# Add contact
|
||||
sudo sed -i "/thumbnail_size => 100,/a contact => 'webmaster@$domain'\," "${final_path}/lib/Lutim.pm"
|
||||
|
||||
|
||||
# Change variables in nginx configuration
|
||||
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
@ -143,16 +152,32 @@ sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
|||
sudo chown -R www-data: $final_path
|
||||
|
||||
# Start lufi
|
||||
sudo service lufi start
|
||||
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.
|
||||
sudo /etc/init.d/lufi start
|
||||
sudo update-rc.d lufi defaults
|
||||
sudo service lufi start
|
||||
else
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl start lufi.service
|
||||
sudo systemctl enable lufi.service
|
||||
fi
|
||||
|
||||
# Set right permissions on new files created at first start
|
||||
sudo chown -R www-data: "$final_path"
|
||||
|
||||
|
||||
# Add lufi as a service
|
||||
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
|
||||
sudo service nginx reload
|
||||
# Régénère la configuration de SSOwat
|
||||
sudo yunohost app ssowatconf
|
||||
sudo service nginx reload
|
|
@ -1,13 +1,14 @@
|
|||
#!/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 /usr/share/yunohost/helpers # Source app helpers
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
# Arrêt du service
|
||||
|
@ -46,6 +47,9 @@ SECURE_REMOVE '/var/log/$app/' # Suppression des log
|
|||
|
||||
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
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
https://git.framasoft.org/luc/lutim/repository/archive.tar.gz?ref=master
|
||||
https://git.framasoft.org/luc/lutim/repository/archive.zip?ref=master
|
Loading…
Add table
Reference in a new issue