1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/galette_ynh.git synced 2024-09-03 18:36:28 +02:00
galette_ynh/scripts/install

118 lines
3.4 KiB
Text
Raw Normal View History

2015-10-17 10:47:21 +02:00
#!/bin/bash
####################################################
# 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
is_public=$4
####################################################
# Check domain / path availability #
####################################################
2015-10-17 10:47:21 +02:00
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\""
2015-10-17 10:47:21 +02:00
if [[ ! $? -eq 0 ]]; then
echo "Error : the chosen admin user does not exist"
2015-10-17 10:47:21 +02:00
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 #
####################################################
2015-10-17 10:47:21 +02:00
final_path=/var/www/$app
# Get and move sources
2015-10-17 18:26:27 +02:00
tar xjvf ../sources/galette-$version.tar.bz2
2015-10-17 18:37:46 +02:00
sudo mv galette-$version/galette $final_path
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
for folder in attachments cache exports files imports logs photos templates_c tempimages
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
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 #
####################################################
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
####################################################
# 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
####################################################
# Restart services #
####################################################
2015-10-17 10:47:21 +02:00
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
# todo : replace last password by user-specified pass
sudo python initialConf.py $domain$path $db_pwd $admin $db_pwd
# Delete the install folder as advised by galette php installer
sudo rm -rf $final_path/install