2014-05-07 02:18:48 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
wiki_name=$3
|
|
|
|
language=$4
|
2014-09-01 22:13:34 +02:00
|
|
|
is_public=$5
|
|
|
|
|
2014-05-07 02:18:48 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2014-05-08 09:57:31 +02:00
|
|
|
# Instal php5-cli dependency
|
2014-05-08 10:18:45 +02:00
|
|
|
sudo apt-get update
|
2014-05-08 09:57:31 +02:00
|
|
|
sudo apt-get install php5-cli -y
|
|
|
|
|
2014-05-07 02:18:48 +02:00
|
|
|
# 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
|
2014-05-08 10:18:45 +02:00
|
|
|
sudo cp -r ../sources/mediawiki/* $final_path
|
2014-05-07 02:18:48 +02:00
|
|
|
sudo cp ../conf/LocalSettings.php $final_path/
|
|
|
|
|
|
|
|
# LDAP Extension
|
2014-05-08 09:57:31 +02:00
|
|
|
sudo cp -r ../sources/LdapAuthentication $final_path/extensions/
|
2014-05-07 02:18:48 +02:00
|
|
|
|
2014-05-09 03:12:44 +02:00
|
|
|
# RemoteUser Extension
|
|
|
|
sudo wget https://codeload.github.com/wikimedia/mediawiki-extensions-Auth_remoteuser/legacy.tar.gz/REL1_22
|
|
|
|
sudo tar -xzf REL1_22
|
|
|
|
sudo mkdir $final_path/extensions/Auth_remoteuser
|
|
|
|
sudo mv wikimedia-mediawiki-extensions-Auth_remoteuser*/* $final_path/extensions/Auth_remoteuser/
|
|
|
|
sudo rm -R wikimedia-mediawiki-extensions-Auth_remoteuser*
|
|
|
|
sudo rm REL1_22
|
|
|
|
|
2014-05-07 02:18:48 +02:00
|
|
|
# Change variables in Mediawiki configuration
|
2014-05-09 03:39:33 +02:00
|
|
|
pathForWiki=$path
|
|
|
|
if [ "$pathForWiki" = "/" ]; then
|
|
|
|
pathForWiki=""
|
|
|
|
fi
|
|
|
|
|
2014-05-08 03:04:04 +02:00
|
|
|
sudo sed -i "s/ynh_wiki_name/$wiki_name/g" $final_path/LocalSettings.php
|
2014-05-09 03:39:33 +02:00
|
|
|
sudo sed -i "s@ynh_wiki_path@$pathForWiki@g" $final_path/LocalSettings.php
|
2014-05-08 03:16:44 +02:00
|
|
|
sudo sed -i "s@ynh_wiki_domain@$domain@g" $final_path/LocalSettings.php
|
2014-05-07 02:18:48 +02:00
|
|
|
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
|
|
|
|
|
2014-09-01 22:13:34 +02:00
|
|
|
|
|
|
|
#sudo yunohost app setting mediawiki is_public -v "$is_public"
|
|
|
|
#if [ $is_public = "Yes" ];
|
|
|
|
#then
|
|
|
|
# sudo yunohost app setting mediawiki skipped_uris -v "/"
|
|
|
|
#fi
|
|
|
|
|
2014-05-07 02:18:48 +02:00
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
2014-05-08 09:57:31 +02:00
|
|
|
sudo yunohost app ssowatconf
|
2014-09-01 22:13:34 +02:00
|
|
|
|
|
|
|
# Add admin account
|
|
|
|
# Step 1 : get a token
|
|
|
|
#gettoken=$(curl -c tmpcookie -kL -X POST https://$domain$path/api.php --data "format=json&action=createaccount&name=monAdmin&password=123456&reason=InstallMediawiki")
|
|
|
|
#echo $gettoken
|
|
|
|
#token=$(echo $gettoken | grep -Po '(?<="token":")[^"]*')
|
|
|
|
#echo $token
|
|
|
|
## Step 2 : create the account
|
|
|
|
#echo "format=json&token=$token&action=createaccount&name=monAdmin&reason=InstallMediawiki"
|
|
|
|
#curl -b tmpcookie -kL -X POST https://$domain$path/api.php --data "format=json&token=$token&action=createaccount&name=monAdmin&password=123456&reason=InstallMediawiki"
|