mirror of
https://github.com/YunoHost-Apps/opensondage_ynh.git
synced 2024-09-03 19:46:28 +02:00
96 lines
3.1 KiB
Bash
Executable file
96 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
admin=$3
|
|
legal=$4
|
|
language=$5
|
|
public_site=$6
|
|
|
|
# Check if admin exists
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Wrong admin"
|
|
exit 1
|
|
fi
|
|
sudo yunohost app setting opensondage admin -v $admin
|
|
sudo yunohost app setting opensondage language -v $language
|
|
sudo yunohost app setting opensondage legal -v $legal
|
|
sudo yunohost app setting opensondage public_site -v $public_site
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a opensondage
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# 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 'opensondage' as database name and user
|
|
db_user=opensondage
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
|
sudo yunohost app setting opensondage mysqlpwd -v $db_pwd
|
|
|
|
# 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 $final_path/admin/logs_studs.txt
|
|
chmod 700 $final_path/admin/logs_studs.txt
|
|
# Set permissions to roundcube directory
|
|
sudo chown -R www-data: $final_path
|
|
|
|
|
|
|
|
# Db installation
|
|
mysql -u $db_user -p$db_pwd $db_user < $final_path/install.mysql.sql
|
|
|
|
|
|
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
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
sudo service php5-fpm restart
|
|
|
|
sudo apt-get install php-fpdf
|
|
sudo yunohost app addaccess opensondage -u $admin
|
|
|
|
# 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/opensondage.conf
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
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
|