From 81a1312fd2c66f100f18ed8cff974f55861872da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9veloppeur=20=C3=A9gar=C3=A9?= Date: Mon, 16 Feb 2015 23:19:37 +0100 Subject: [PATCH] init --- .gitattributes | 17 -------- README.md | 7 +++ conf/conf.php | 8 ++++ conf/nginx.conf | 33 ++++++++++++++ manifest.json | 49 +++++++++++++++++++++ scripts/install | 92 ++++++++++++++++++++++++++++++++++++++++ scripts/remove | 13 ++++++ scripts/upstream_version | 1 + 8 files changed, 203 insertions(+), 17 deletions(-) delete mode 100644 .gitattributes create mode 100644 README.md create mode 100644 conf/conf.php create mode 100644 conf/nginx.conf create mode 100644 manifest.json create mode 100644 scripts/install create mode 100644 scripts/remove create mode 100644 scripts/upstream_version diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index bdb0cab..0000000 --- a/.gitattributes +++ /dev/null @@ -1,17 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/README.md b/README.md new file mode 100644 index 0000000..fa62ac9 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +friendica_ynh +========== + +Friendica integration for YunoHost + +You can use accounts from YunoHost's LDAP. There are not yet active SSO. +For upgrade, please use admin page for updates. More stable. http://friendica.com/node/27 diff --git a/conf/conf.php b/conf/conf.php new file mode 100644 index 0000000..d6d8569 --- /dev/null +++ b/conf/conf.php @@ -0,0 +1,8 @@ + +$a->config['system']['addon'] = 'ldapauth'; + +$a->config['ldapauth']['ldap_server'] = 'localhost'; +$a->config['ldapauth']['ldap_searchdn'] = 'ou=users,dc=yunohost,dc=org'; +$a->config['ldapauth']['ldap_userattr'] = 'uid'; +$a->config['ldapauth']['ldap_autocreateaccount'] = 'true'; +$a->config['ldapauth']['ldap_autocreateaccount_emailattribute'] = 'mail'; diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..83959ec --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,33 @@ +location PATHTOCHANGE { + alias ALIASTOCHANGE; + client_max_body_size 10G; + index index.php; + + if (!-f $request_filename) { + rewrite ^PATHTOCHANGE/(.+)$ PATHTOCHANGE/index.php?q=$1 last; + } + #try_files $uri $uri/ =404; + + location ~* \.php { + include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_param HTTPS on; + fastcgi_index index.php; + fastcgi_pass unix:/var/run/php5-fpm.sock; + #try_files $uri $uri/ =404; + } + + #default_type text/html; + #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; + #} + + + # Include SSOWAT user panel. + #include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..17cf70a --- /dev/null +++ b/manifest.json @@ -0,0 +1,49 @@ +{ + "name": "Friendica", + "id": "friendica", + "description": { + "en": "Social Communication Server", + "fr": "Serveur de Communication Social" + }, + "developer": { + "name": "aymhce", + "email": "aymhce@gmail.com", + "url": "http://friendica.com" + }, + "multi_instance": "true", + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain for Friendica" + }, + "example": "domain.org" + }, + { + "name": "path", + "ask": { + "en": "Choose a path for Friendica" + }, + "example": "/friendica", + "default": "/friendica" + }, + { + "name": "admin", + "ask": { + "en": "Choose the Friendica administrator (must be an existing YunoHost user)" + }, + "example": "homer" + }, + { + "name": "public_site", + "ask": { + "en": "Is it a public Friendica site ?", + "fr": "Est-ce un site public ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + } + ] + } +} diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..805a766 --- /dev/null +++ b/scripts/install @@ -0,0 +1,92 @@ +#!/bin/bash + +# Retrieve arguments +domain=$1 +path=$2 +user=$3 +is_public=$4 + +# Check user parameter +sudo yunohost user list --json | grep -q "\"username\": \"$user\"" +if [[ ! $? -eq 0 ]]; then + echo "Wrong user" + exit 1 +fi +sudo yunohost app setting friendica admin_user -v $user + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a friendica +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Get admin mail +admin_mail=$(sudo yunohost user info $user | grep "mail:" | cut -d' ' -f2) + +# Get code +version=$(cat upstream_version) +git clone -b "${version}" 'https://github.com/friendica/friendica.git' +sudo chown -R admin friendica +sudo cp -ar friendica $final_path + +# 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') + +# Use 'friendica' as database name and user +db_user=friendica + +# Initialize database and store mysql password for upgrade +sudo yunohost app initdb $db_user -p $db_pwd +sudo yunohost app setting friendica mysqlpwd -v $db_pwd + +# Modify Nginx configuration file and copy it to Nginx conf directory + +final_path=/var/www/friendica + +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/friendica.conf + +# configure friendica + +sudo cp $final_path/htconfig.php $final_path/.htconfig.php + +sudo sed -i "s@your.mysqlhost.com@localhost@g" $final_path/.htconfig.php +sudo sed -i "s@mysqlusername@$db_user@g" $final_path/.htconfig.php +sudo sed -i "s@mysqldatabasename@$db_user@g" $final_path/.htconfig.php +sudo sed -i "s@mysqlpassword@$db_pwd@g" $final_path/.htconfig.php +sudo sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$admin_mail';/g" $final_path/.htconfig.php + +# init db + +mysql -u $db_user -p$db_pwd $db_user < $final_path/database.sql + +# Ldap auth + +wget -O ldapauth.php https://raw.githubusercontent.com/friendica/friendica-addons/master/ldapauth/ldapauth.php > /dev/null 2>&1 +echo "Copy ldapauth.php to $final_path/addon/ldapauth..." +mkdir -p $final_path/addon/ldapauth +sudo cp ldapauth.php $final_path/addon/ldapauth + +# Ldap auth config + +sudo su -c "cat ../conf/conf.php >> $final_path/.htconfig.php" + +# set permission + +sudo chown -R www-data:www-data $final_path + +# Reload Nginx and regenerate SSOwat conf + +sudo service nginx reload +sudo yunohost app setting friendica skipped_uris -v "/" +sudo yunohost app ssowatconf + +#protect URIs + +if [ $is_public = "No" ]; +then + sudo yunohost app setting friendica protected_uris -v "/" + sudo yunohost app ssowatconf +fi diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..4644d75 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,13 @@ +#!/bin/bash + +db_user=friendica +db_name=friendica +root_pwd=$(sudo cat /etc/yunohost/mysql) +domain=$(sudo yunohost app setting friendica domain) + +mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" + +sudo rm -rf /var/www/friendica +sudo rm -f /etc/nginx/conf.d/$domain.d/friendica.conf + +sudo service nginx reload diff --git a/scripts/upstream_version b/scripts/upstream_version new file mode 100644 index 0000000..83d3246 --- /dev/null +++ b/scripts/upstream_version @@ -0,0 +1 @@ +release-3.3.2