mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
117 lines
3.4 KiB
Bash
Executable file
117 lines
3.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
####################################################
|
|
# Retrieve arguments / set global variables #
|
|
####################################################
|
|
|
|
app=galette
|
|
version=0.8.2
|
|
|
|
domain=$1
|
|
path=$2
|
|
admin=$3
|
|
adminPass=$4
|
|
is_public=$5
|
|
|
|
####################################################
|
|
# Check domain / path availability #
|
|
####################################################
|
|
|
|
sudo yunohost app checkurl $domain$path -a $app
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Error : domain/path url isnt available"
|
|
exit 1
|
|
fi
|
|
|
|
####################################################
|
|
# Check that admin user is an existing account #
|
|
####################################################
|
|
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Error : the chosen admin user does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
sudo yunohost app setting $app admin -v $admin
|
|
|
|
sudo yunohost app setting $app is_public -v "$is_public"
|
|
|
|
####################################################
|
|
# Copy / install source files #
|
|
####################################################
|
|
|
|
final_path=/var/www/$app
|
|
|
|
# Get and move sources
|
|
|
|
tar xjvf ../sources/galette-$version.tar.bz2 > /dev/null
|
|
sudo mv galette-$version/galette $final_path
|
|
rm -r galette-$version
|
|
|
|
# Set permissions
|
|
|
|
sudo chown -R root:www-data $final_path
|
|
sudo chmod -R o-rwx $final_path
|
|
sudo chmod u+rx $final_path/config
|
|
sudo chmod g+rwx $final_path/config
|
|
for folder in attachments cache exports files imports logs photos templates_c tempimages
|
|
do
|
|
sudo chmod u+rx $final_path/data/$folder
|
|
sudo chmod g+rwx $final_path/data/$folder
|
|
done
|
|
|
|
####################################################
|
|
# Create a mysql database #
|
|
####################################################
|
|
|
|
# Generate random password
|
|
|
|
db_user=galette
|
|
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')
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
|
sudo yunohost app setting $app mysqlpassword -v $db_pwd
|
|
|
|
####################################################
|
|
# Nginx configuration #
|
|
####################################################
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
####################################################
|
|
# SSOWat configuration #
|
|
####################################################
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
then
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
|
fi
|
|
|
|
####################################################
|
|
# Restart services #
|
|
####################################################
|
|
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|
|
|
|
####################################################
|
|
# Call galette php installer and fill the form #
|
|
####################################################
|
|
|
|
# Install mechanize to have a browser in a python script
|
|
sudo pip install mechanize
|
|
|
|
# Then call python script to fill galette php installer with the right info
|
|
sudo python initialConf.py $domain$path $db_pwd $admin $adminPass
|
|
|
|
# Delete the install folder as advised by galette php installer
|
|
sudo rm -rf $final_path/install
|
|
|
|
|