mirror of
https://github.com/YunoHost-Apps/opensondage_ynh.git
synced 2024-09-03 19:46:28 +02:00
100 lines
3.4 KiB
Bash
100 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$(sudo yunohost app setting opensondage domain)
|
|
path=$(sudo yunohost app setting opensondage path)
|
|
admin=$(sudo yunohost app setting opensondage admin)
|
|
legal=$(sudo yunohost app setting opensondage legal)
|
|
language=$(sudo yunohost app setting opensondage language)
|
|
public_site=$(sudo yunohost app setting opensondage public_site)
|
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
|
|
db_name=opensondage
|
|
|
|
sudo cp ../conf/variables.php.template $final_path/variables.php
|
|
|
|
# Change variables in OpenSondage configuration
|
|
sudo sed -i "s/yunouser/$db_user/g" $final_path/variables.php
|
|
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/variables.php
|
|
sudo sed -i "s/yunobase/$db_user/g" $final_path/variables.php
|
|
sudo sed -i "s/yunoadmin/$admin/g" $final_path/variables.php
|
|
sudo sed -i "s/I18NTOCHANGE/$language/g" $final_path/variables.php
|
|
sudo sed -i "s@yunourl@$domain$path@g" $final_path/variables.php
|
|
sudo sed -i "s@yunodomain@$domain@g" $final_path/variables.php
|
|
sudo sed -i "s@yunoinfolegal@$legal@g" $final_path/variables.php
|
|
|
|
|
|
|
|
if [[ "$language" = "" ]];
|
|
then
|
|
language=$(sudo grep LANGUE /var/www/opensondage/variables.php | cut -d"'" -f4)
|
|
fi
|
|
|
|
|
|
# Check if admin is not null
|
|
if [[ "$admin" = "" || "$language" = "" ]]; then
|
|
echo "Unable to upgrade, please contact support"
|
|
exit 1
|
|
fi
|
|
|
|
# Generate random password
|
|
db_pwd=$(sudo yunohost app setting opensondage mysqlpwd)
|
|
|
|
# Use 'opensondage' as database name and user
|
|
db_user=opensondage
|
|
|
|
### Execute potential SQL statements here
|
|
|
|
# Copy files to the right place
|
|
final_path=/var/www/opensondage
|
|
sudo mkdir -p $final_path
|
|
sudo cp -a ../sources/* $final_path
|
|
sudo cp ../conf/variables.php.template $final_path/variables.php
|
|
|
|
# Change variables in OpenSondage configuration
|
|
sudo sed -i "s/yunouser/$db_user/g" $final_path/variables.php
|
|
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/variables.php
|
|
sudo sed -i "s/yunobase/$db_user/g" $final_path/variables.php
|
|
sudo sed -i "s/yunoadmin/$admin/g" $final_path/variables.php
|
|
sudo sed -i "s/I18NTOCHANGE/$language/g" $final_path/variables.php
|
|
sudo sed -i "s@yunourl@$domain$path@g" $final_path/variables.php
|
|
sudo sed -i "s@yunodomain@$domain@g" $final_path/variables.php
|
|
sudo sed -i "s°yunoinfolegal°$legal°g" $final_path/variables.php
|
|
|
|
# Create log file
|
|
touch admin/logs_studs.txt
|
|
chmod 700 admin/logs_studs.txt
|
|
|
|
# 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 yunohost app addaccess opensondage -u $admin
|
|
sudo cp ../conf/nginx.conf-public /etc/nginx/conf.d/$domain.d/opensondage.conf
|
|
|
|
sed -i "s@NAMETOCHANGE@opensondage@g" ../conf/php-fpm.conf
|
|
finalphpconf=/etc/php5/fpm/pool.d/opensondage.conf
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
sudo chown root: $finalphpconf
|
|
sudo chmod 644 $finalphpconf
|
|
|
|
finalphpini=/etc/php5/fpm/conf.d/20-opensondage.ini
|
|
sudo cp ../conf/php-fpm.ini $finalphpini
|
|
sudo chown root: $finalphpini
|
|
sudo chmod 644 $finalphpini
|
|
|
|
sudo service php5-fpm restart
|
|
# Reload Nginx
|
|
sudo service nginx reload
|
|
sudo yunohost app setting opensondage skipped_uris -v "/"
|
|
if [ $public_site = "No" ];
|
|
then
|
|
sudo yunohost app setting opensondage protected_uris -v "/admin,/index.php,/choix_date.php,/infos_sondage.php,/scripts"
|
|
else
|
|
sudo yunohost app setting opensondage protected_uris -v "/admin,/scripts"
|
|
fi
|
|
sudo yunohost app ssowatconf
|