1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
lutim_ynh/scripts/install
Maniack Crudelis 8a91e320ef Init
2014-10-06 13:19:51 +02:00

90 lines
2.4 KiB
Bash

#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
admin=$3
is_public=$4
# Check if admin exists
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then
echo "Wrong admin"
exit 1
fi
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a leed
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Add settings to YunoHost
sudo yunohost app setting lutim admin -v $admin
sudo yunohost app setting lutim domain -v $domain
# Copy files to right place
final_path=/var/www/lutim
sudo mkdir -p $final_path
sudo cp -a ../sources/lutim-master/* $final_path
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/lutim.conf
# Set right permissions for curl install
# sudo chown -R www-data: $final_path
# Installation du module perl carton
yes | sudo cpan Carton
# Installation de perlmagick, interface perl pour imagemagick
sudo apt-get install perlmagick -qy
# Installation de lutim via carton
cd $final_path
echo pwd
sudo carton install
## Copie et configuration du fichier de conf.
# Mise en place des scripts init
sudo cp $final_path/utilities/lutim.init /etc/init.d/lutim
sudo cp $final_path/utilities/lutim.default /etc/default/lutim
sudo chmod +x /etc/init.d/lutim
chown root:root /etc/init.d/lutim /etc/default/lutim
## vim /etc/default/lutim
## /etc/init.d/lutim start
## Démarrage auto des scripts init
## Voir les crons et les mettre en place.
## Reverse proxy nginx à configurer
# Change variables in lutim configuration
sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/lutim.conf
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/lutim.conf
# Files owned by root, www-data can just read
# sudo find $final_path -type f | xargs sudo chmod 644
# sudo find $final_path -type d | xargs sudo chmod 755
# sudo chown -R root: $final_path
# www-data can write on plugins and cache
# sudo chown -R www-data $final_path/cache $final_path/plugins
# Make app public or private
sudo yunohost app setting lutim is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting lutim skipped_uris -v "/"
else # Si l'app est privée, seul le visionnage des images est public
sudo yunohost app setting lutim skipped_regex -v "/(stats|manifest.webapp|(d|m)/.+)?$"
fi # REGEX À INVERSER ! Je pense...
# Reload Nginx, start lutim and regenerate SSOwat conf
sudo service nginx reload
sudo /etc/init.d/lutim start
sudo yunohost app ssowatconf