From 2025637df779bc51ad4f3576fdb141b4b89bca72 Mon Sep 17 00:00:00 2001 From: src386 Date: Mon, 3 Aug 2015 12:05:52 +0200 Subject: [PATCH] . --- conf/nginx.conf | 41 ++++++++++++++++++++------------------ scripts/install | 52 +++++++++++++++++++++++-------------------------- scripts/remove | 16 +++++++++++++++ scripts/upgrade | 0 4 files changed, 62 insertions(+), 47 deletions(-) create mode 100644 scripts/remove create mode 100644 scripts/upgrade diff --git a/conf/nginx.conf b/conf/nginx.conf index e615978..7951152 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,23 +1,24 @@ location PATHTOCHANGE { alias ALIASTOCHANGE; - index index.php; - try_files $uri $uri/ index.php @movim; -#location @movim { -# rewrite ^/(.*) /index.php?query=$1 last; -# } + 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; - fastcgi_param SCRIPT_FILENAME $request_filename; - } + index index.php; + try_files $uri $uri/ /index.php; -location /movim/ws/ { + 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; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + +location ~ ^PATHTOCHANGE/ws/ { proxy_pass http://localhost:8080/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -31,8 +32,10 @@ location /movim/ws/ { proxy_redirect off; } -location /movim/log/ { - deny all; - } - +# Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} + +location ~ ^PATHTOCHANGE/(log|\.ht) { + deny all; } diff --git a/scripts/install b/scripts/install index fb4f6ff..892632c 100644 --- a/scripts/install +++ b/scripts/install @@ -11,8 +11,7 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi -#sudo yunohost app setting movim language -v $language -#sudo yunohost app setting movim public_site -v $public_site +sudo yunohost app setting movim public_site -v $public_site # Generate random password db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') @@ -24,34 +23,32 @@ db_user=movim sudo yunohost app initdb $db_user -p $db_pwd sudo yunohost app setting movim mysqlpwd -v $db_pwd -# Prereqs +# Install packages sudo apt-get install php5-gd php5-curl php5-imagick -y -# Copy files to the right place +# Install Movim files final_path=/var/www/movim sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path - -# Set permissions to Movim directory sudo chown -R www-data: $final_path # Install PHP dependencies cd $final_path -curl -sS https://getcomposer.org/installer | php -php composer.phar install +sudo su -c "curl -sS https://getcomposer.org/installer | php" -s /bin/sh www-data +sudo su -c "php composer.phar install" -s /bin/sh www-data # Movim configuration -mv $final_path/config/db.example.inc.php $final_path/config/db.inc.php -sed -i "s/yhuser/$db_user/g" $final_path/config/db.inc.php -sed -i "s/yhpwd/$db_pwd/g" $final_path/config/db.inc.php -sed -i "s/yhdb/$db_user/g" $final_path/config/db.inc.php +sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php +sudo sed -i "s/yhuser/$db_user/g" $final_path/config/db.inc.php +sudo sed -i "s/yhpwd/$db_pwd/g" $final_path/config/db.inc.php +sudo sed -i "s/yhdb/$db_user/g" $final_path/config/db.inc.php -# Prepare database -su -c "php mud.php db set" -s /bin/sh www-data -#sudo yunohost app addaccess opensondage -u $admin #a voir +# Populate Movim database +sudo su -c "php mud.php db set" -s /bin/sh www-data +sudo yunohost app addaccess movim -u $admin # Copy init script if Wheezy -cp -a ../conf/movim.init /etc/init.d/movim +sudo cp -a ../conf/movim.init /etc/init.d/movim sed -i "s/YHDIR/$final_path/g" /etc/init.d/movim # Copy systemd service if Jessie @@ -60,18 +57,17 @@ sed -i "s/YHDIR/$final_path/g" /etc/init.d/movim # Nginx configuration sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf -cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf + +# SSOwat Configuration +sudo yunohost app setting movim skipped_uris -v "/" +if [ $public_site = "No" ]; +then + sudo yunohost app setting movim protected_uris -v "/admin,/index.php" +else + sudo yunohost app setting movim protected_uris -v "/admin/index.php,/admin/logs_studs.txt,/scripts" +fi +sudo yunohost app ssowatconf # Start Movim /etc/init.d/movim start - -# Reload Nginx and regenerate SSOwat conf -sudo service nginx reload -sudo yunohost app setting opensondage skipped_uris -v "/" -if [ $public_site = "No" ]; -then - sudo yunohost app setting opensondage protected_uris -v "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts" -else - sudo yunohost app setting opensondage protected_uris -v "/admin/index.php,/admin/logs_studs.txt,/scripts" -fi -sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..4f32835 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,16 @@ +#!/bin/bash + +db_user=movim +db_name=movim +root_pwd=$(sudo cat /etc/yunohost/mysql) +mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" + +# Removing executable files +sudo rm -rf /var/www/movim +domain=$(sudo yunohost app setting movim domain) +sudo rm -f /etc/nginx/conf.d/$domain.d/movim.conf + +#REMOVE INIT + +# Restarting services +sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..e69de29