1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

Fix installation and nginx config

Resolves #24, resolves #31
This commit is contained in:
TitusPiJean 2017-02-27 19:06:31 +01:00
parent 589f91c30f
commit fe09ff43d2
3 changed files with 23 additions and 33 deletions

View file

@ -1,11 +1,12 @@
location ^~ YNH_WWW_PATH {
alias YNH_WWW_FINALPATH/ ;
try_files $uri $uri/ /YNH_WWW_ROOTAPP/index.php?$query_string;
index /YNH_WWW_ROOTAPP/index.php;
alias YNH_WWW_FINALPATH/;
try_files $uri $uri/ /index.php?$query_string;
index YNH_WWW_ROOTPATH/index.php;
location YNH_WWW_ROOTPATH/ { try_files $uri $uri/ /YNH_WWW_ROOTAPP/index.php?$query_string; }
location YNH_WWW_ROOTPATH/api { try_files $uri $uri/ /YNH_WWW_ROOTAPP/api.php?$query_string; }
location YNH_WWW_ROOTPATH/admin { try_files $uri $uri/ /YNH_WWW_ROOTAPP/admin.php?$query_string; }
# These weird try_files ... see http://stackoverflow.com/a/35102259
location YNH_WWW_ROOTPATH/ { try_files $uri $uri/ YNH_WWW_ROOTAPP/index.php?$query_string; }
location YNH_WWW_ROOTPATH/api { try_files $uri $uri/ YNH_WWW_ROOTAPP/api.php?$query_string; }
location YNH_WWW_ROOTPATH/admin { try_files $uri $uri/ YNH_WWW_ROOTAPP/admin.php?$query_string; }
location YNH_WWW_ROOTPATH/flarum {
deny all;

View file

@ -1,7 +1,7 @@
#!/bin/bash
# Load extra functions
source .functions
source .functions
# Activate TRAP to stop the script if an error is detected
TRAP_ON
@ -108,10 +108,10 @@ ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
nginxconf="../conf/nginx.conf"
if [ $path = "/" ]; then
sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf
sed -i "s@/YNH_WWW_ROOTAPP@@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@/@g" ../conf/nginx.conf
else
sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$app@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$path$path@g" ../conf/nginx.conf
fi
sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf
sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf
@ -164,31 +164,18 @@ rootsql="INSERT INTO api_keys VALUES ('"$roottoken"')"
ynh_mysql_execute_as_root "$apitablesql" $dbname
ynh_mysql_execute_as_root "$rootsql" $dbname
ynh_app_setting_set "$app" root_token "$roottoken"
fi
# Configure SSOwat auth extension
ssowatdomain=$(</etc/yunohost/current_host)
data='{"flarum-ext-auth-ssowat.address": "'$ssowatdomain'"}'
data='{"flarum-ext-auth-ssowat.address": "'$ssowatdomain'","flarum-ext-auth-ssowat.onlyUse": true}'
rep=$(curl -s -o /dev/null -w "%{http_code}" -k -i \
-H "Content-Type: application/json" \
-H "Authorization: Token $roottoken; userId=1" \
-X POST -d "$data" \
-L https://${domain}${path}/api/settings )
echo $path
exit 0
if [[ $rep != 204 ]]; then
echo "SSOwat domain setting failed"
exit 1
fi
data='{"flarum-ext-auth-ssowat.onlyUse": true}'
rep=$(curl -s -o /dev/null -w "%{http_code}" -k -i \
-H "Content-Type: application/json" \
-H "Authorization: Token $roottoken; userId=1" \
-X POST -d "$data" \
-L https://${domain}${path}/api/settings )
if [[ $rep != 204 ]]; then
echo "SSOwat auth exclusivity failed"
exit 1
ynh_die "ERROR: Could not configure SSOwat extension"
fi
# Enable the selected admin to login with SSOwat
@ -207,12 +194,12 @@ for username in $(ynh_user_list); do
-X POST -d "$data" \
-L https://${domain}${path}/api/users )
if [[ $rep != 201 ]]; then
echo "Flarum account creation failed for $username"
exit 1
ynh_die "ERROR: Flarum account creation failed for $username"
fi
usersql="UPDATE users SET ssowat_id = '$username' WHERE username = '$username'"
ynh_mysql_execute_as_root "$usersql" $dbname
fi
done
fi
>&2 echo "Admin : $admin, password : $adminpass. Change it!"

View file

@ -21,9 +21,12 @@ is_public=$(ynh_app_setting_get "$app" is_public)
CHECK_PATH
# Copy source files
src_path=/var/www/$app
sudo mkdir -p $src_path
sudo cp -a ../sources/. $src_path
#src_path=/var/www/$app
#sudo mkdir -p $src_path
#sudo cp -a ../sources/. $src_path
# Update flarum
sudo su - www-data -s /bin/bash -c "cd /var/www/${app} && composer update"
# Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
@ -32,14 +35,13 @@ sudo chmod -R 755 $src_path
# Modify Nginx configuration file and copy it to Nginx conf directory
### Nginx ###
if [ $path = "/" ]; then
nginxconf="../conf/nginx.conf"
if [ $path = "/" ]; then
sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf
sed -i "s@/YNH_WWW_ROOTAPP@@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@/@g" ../conf/nginx.conf
else
sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$app@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$path$path@g" ../conf/nginx.conf
fi
sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf
sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf