From e614e9ef09e2abc103728552274fb55ac97dbf85 Mon Sep 17 00:00:00 2001 From: Elie Date: Tue, 6 May 2014 20:18:48 -0400 Subject: [PATCH] Install script with Ldap extensions --- README.md | 5 +- conf/LocalSettings.php | 159 +++++++++++++++++++++++++++++++++++++++++ conf/nginx.conf | 17 +++++ manifest.json | 49 +++++++++++++ scripts/install | 62 ++++++++++++++++ scripts/remove | 0 scripts/upgrade | 0 7 files changed, 288 insertions(+), 4 deletions(-) create mode 100755 conf/LocalSettings.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/upgrade diff --git a/README.md b/README.md index 06b90ea..c8b5af9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1 @@ -mediawiki_ynh -============= - -MediaWIki packaged for Yunohost +MediaWIki 1.22.6 packaged for Yunohost \ No newline at end of file diff --git a/conf/LocalSettings.php b/conf/LocalSettings.php new file mode 100755 index 0000000..b81fc22 --- /dev/null +++ b/conf/LocalSettings.php @@ -0,0 +1,159 @@ + 'localhost', +); + +$wgLDAPUseLocal = false; + +$wgLDAPEncryptionType = array( + 'mediawiki' => 'clear' +); + +$wgLDAPSearchAttributes = array( + 'mediawiki' => 'uid' +); + +$wgLDAPBaseDNs = array( + 'mediawiki' => 'dc=yunohost,dc=org' +); +$wgLDAPGroupBaseDNs = array( + 'mediawiki' => 'dc=yunohost,dc=org' +); +$wgLDAPUserBaseDNs = array( + 'mediawiki' => 'dc=yunohost,dc=org' +); + +$wgLDAPPreferences = array( + 'mediawiki' => array('email' => 'mail', 'realname' => 'cn') +); + +$wgLDAPDebug = 0; diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..18db1eb --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,17 @@ +location PATHTOCHANGE { + alias ALIASTOCHANGE; + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + client_max_body_size 10G; + index index.php; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php5-fpm-mediawiki.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..358b1f4 --- /dev/null +++ b/manifest.json @@ -0,0 +1,49 @@ +{ + "name": "Mediawiki", + "id": "mediawiki", + "description": { + "en": "Open Source Wiki software", + "fr": "Wiki Open Source" + }, + "developer": { + "name": "ElieSauveterre", + "email": "contact@mikangali.om", + "url": "http://www.mikangali.com/" + }, + "multi_instance": "true", + "arguments": { + "install": [ + { + "name": "domain", + "ask": { + "en": "Choose a domain for Mediawiki" + }, + "example": "domain.org" + }, + { + "name": "path", + "ask": { + "en": "Choose a path for Mediawiki" + }, + "example": "/wiki", + "default": "/wiki" + }, + { + "name": "wikiname", + "ask": { + "en": "Choose a name" + }, + "example": "My Wiki", + "default": "My Wiki" + }, + { + "name": "language", + "ask": { + "en": "Choose the language" + }, + "choices": ["en", "fr"], + "default": "en" + } + ] + } +} \ No newline at end of file diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..6df7fb2 --- /dev/null +++ b/scripts/install @@ -0,0 +1,62 @@ +# Retrieve arguments +domain=$1 +path=$2 +wiki_name=$3 +language=$4 + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a mediawiki +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Generate random DES key & password +deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') +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 'mediawiki' as database name and user +db_user=mediawiki + +# Initialize database and store mysql password for upgrade +sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../conf/SQL/mysql.initial.sql) +sudo yunohost app setting mediawiki mysqlpwd -v $db_pwd + +# Copy files to the right place +final_path=/var/www/mediawiki +sudo mkdir -p $final_path +sudo wget http://releases.wikimedia.org/mediawiki/1.22/mediawiki-1.22.6.tar.gz +sudo tar xvzf mediawiki-*.tar.gz +sudo mv mediawiki-*/* $final_path +sudo rm -R mediawiki-* +sudo cp ../conf/LocalSettings.php $final_path/ + +# LDAP Extension +sudo wget https://codeload.github.com/wikimedia/mediawiki-extensions-LdapAuthentication/legacy.tar.gz/REL1_22 +sudo tar -xzf REL1_22 +sudo mkdir $final_path/extensions/LdapAuthentication +sudo mv wikimedia-mediawiki-extensions-LdapAuthentication*/* $final_path/extensions/LdapAuthentication/ +sudo rm -R wikimedia-mediawiki-extensions-LdapAuthentication* +sudo rm REL1_22 + +# Change variables in Mediawiki configuration +sudo sed -i "s/ynh_wiki_name/$wiki_name/g" $final_path/LocalSettings.php +sudo sed -i "s/ynh_wiki_domain/$domain/g" $final_path/LocalSettings.php +sudo sed -i "s/ynh_wiki_db_name/$db_user/g" $final_path/LocalSettings.php +sudo sed -i "s/ynh_wiki_db_user/$db_user/g" $final_path/LocalSettings.php +sudo sed -i "s/ynh_wiki_db_password/$db_pwd/g" $final_path/LocalSettings.php +sudo sed -i "s/ynh_wiki_language/$language/g" $final_path/LocalSettings.php + +# Update DB +sudo php5 $final_path/maintenance/update.php + +# Set permissions to roundcube directory +sudo chown -R www-data: $final_path + +# Modify Nginx configuration file and copy it to Nginx conf directory +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/mediawiki.conf + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload +sudo yunohost app ssowatconf \ No newline at end of file diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..e69de29 diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..e69de29