1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mediawiki_ynh.git synced 2024-09-03 19:46:05 +02:00
mediawiki_ynh/scripts/install

58 lines
2.1 KiB
Text

# 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
# Instal php5-cli dependency
sudo apt-get install php5-cli -y
# 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 cp ../sources/mediawiki/* $final_path
sudo cp ../conf/LocalSettings.php $final_path/
# LDAP Extension
sudo cp -r ../sources/LdapAuthentication $final_path/extensions/
# 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_path@$path@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