2015-10-17 10:47:21 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
####################################################
|
|
|
|
# Retrieve arguments / set global variables #
|
|
|
|
####################################################
|
|
|
|
|
|
|
|
app=galette
|
|
|
|
version=0.8.2
|
|
|
|
|
2015-10-17 10:47:21 +02:00
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
admin=$3
|
2015-10-29 02:09:41 +01:00
|
|
|
adminPass=$4
|
|
|
|
is_public=$5
|
2015-10-17 10:47:21 +02:00
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
####################################################
|
|
|
|
# Check domain / path availability #
|
|
|
|
####################################################
|
2015-10-17 10:47:21 +02:00
|
|
|
|
|
|
|
sudo yunohost app checkurl $domain$path -a $app
|
2015-10-17 13:41:39 +02:00
|
|
|
|
|
|
|
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\""
|
2015-10-17 10:47:21 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2015-10-17 13:41:39 +02:00
|
|
|
echo "Error : the chosen admin user does not exist"
|
2015-10-17 10:47:21 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
sudo yunohost app setting $app admin -v $admin
|
|
|
|
|
|
|
|
sudo yunohost app setting $app is_public -v "$is_public"
|
|
|
|
|
|
|
|
####################################################
|
|
|
|
# Copy / install source files #
|
|
|
|
####################################################
|
|
|
|
|
2015-10-17 10:47:21 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
# Get and move sources
|
|
|
|
|
2015-10-29 01:46:59 +01:00
|
|
|
tar xjvf ../sources/galette-$version.tar.bz2 > /dev/null
|
2015-10-17 18:37:46 +02:00
|
|
|
sudo mv galette-$version/galette $final_path
|
2015-10-17 13:41:39 +02:00
|
|
|
rm -r galette-$version
|
|
|
|
|
|
|
|
# Set permissions
|
|
|
|
|
2015-10-17 18:37:46 +02:00
|
|
|
sudo chown -R root:www-data $final_path
|
|
|
|
sudo chmod -R o-rwx $final_path
|
2015-10-29 01:51:07 +01:00
|
|
|
sudo chmod u+rx $final_path/config
|
|
|
|
sudo chmod g+rwx $final_path/config
|
2015-10-18 17:42:36 +02:00
|
|
|
for folder in attachments cache exports files imports logs photos templates_c tempimages
|
2015-10-17 13:41:39 +02:00
|
|
|
do
|
2015-10-17 18:41:03 +02:00
|
|
|
sudo chmod u+rx $final_path/data/$folder
|
|
|
|
sudo chmod g+rwx $final_path/data/$folder
|
2015-10-17 13:41:39 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
####################################################
|
2015-10-24 13:19:18 +02:00
|
|
|
# Create a mysql database #
|
2015-10-17 13:41:39 +02:00
|
|
|
####################################################
|
|
|
|
|
|
|
|
# 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 #
|
|
|
|
####################################################
|
|
|
|
|
2015-10-17 18:37:46 +02:00
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
2015-10-17 10:47:21 +02:00
|
|
|
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
|
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
####################################################
|
|
|
|
# SSOWat configuration #
|
|
|
|
####################################################
|
|
|
|
|
2015-10-17 10:47:21 +02:00
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
|
|
|
fi
|
|
|
|
|
2015-10-17 13:41:39 +02:00
|
|
|
####################################################
|
|
|
|
# Restart services #
|
|
|
|
####################################################
|
2015-10-17 10:47:21 +02:00
|
|
|
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
|
2015-10-24 13:19:18 +02:00
|
|
|
####################################################
|
|
|
|
# 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
|
2015-10-29 02:09:41 +01:00
|
|
|
sudo python initialConf.py $domain$path $db_pwd $admin $adminPass
|
2015-10-24 13:19:18 +02:00
|
|
|
|
|
|
|
# Delete the install folder as advised by galette php installer
|
2015-10-29 02:09:41 +01:00
|
|
|
sudo rm -rf $final_path/install
|
2015-10-24 13:19:18 +02:00
|
|
|
|
|
|
|
|