#!/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 lutim 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 # Installation du module perl carton echo "Installation du module perl carton. Attention, étape très longue..." # yes | sudo cpan Carton | sudo tee $final_path/cpan_setup.log 2>&1 > /dev/null 2>&1 # Debug yes | sudo cpan Carton > /dev/null 2>&1 # Installation de perlmagick, interface perl pour imagemagick sudo apt-get install perlmagick -qy ## Copie et configuration du fichier de conf. sudo cp ../conf/lutim.conf.template $final_path/lutim.conf sudo sed -i "s@__DOMAIN__@$domain@g" $final_path/lutim.conf sudo sed -i "s@__PATH__@$path@g" $final_path/lutim.conf # Mise en place des scripts init sudo cp ../sources/lutim-master/utilities/lutim.init /etc/init.d/lutim sudo cp ../conf/lutim.default /etc/default/lutim sudo chmod +x /etc/init.d/lutim sudo chown root:root /etc/init.d/lutim /etc/default/lutim sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim ## Mise en place des crons sudo cp ../conf/cron_lutim /etc/cron.d/lutim sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/cron.d/lutim # Installation de lutim via carton cd $final_path sudo carton install ## Démarrage auto des scripts init sudo update-rc.d lutim defaults # sudo update-rc.d -f lutim remove # Change variables in nginx configuration sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/lutim.conf # Set right permissions sudo chown -R www-data: $final_path # 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 # Reload Nginx, start lutim and regenerate SSOwat conf sudo service nginx reload sudo /etc/init.d/lutim start sudo yunohost app ssowatconf