mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
107 lines
3.1 KiB
Bash
Executable file
107 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
####################################################
|
|
# Retrieve arguments / set global variables #
|
|
####################################################
|
|
|
|
app=galette
|
|
version=0.8.2
|
|
|
|
domain=$1
|
|
path=$2
|
|
admin=$3
|
|
is_public=$4
|
|
|
|
####################################################
|
|
# 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
|
|
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
|
|
for folder in cache config exports 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 and configure galette #
|
|
####################################################
|
|
|
|
# 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
|
|
|
|
# Edit config file
|
|
|
|
sed -i "s/USER_DB_VALUE/$db_user/g" ../conf/config.inc.php
|
|
sed -i "s/PWD_DB_VALUE/$db_pwd/g" ../conf/config.inc.php
|
|
sed -i "s/NAME_DB_VALUE/$db_user/g" ../conf/config.inc.php
|
|
sudo cp ../conf/config.inc.php $final_path/config/
|
|
|
|
####################################################
|
|
# 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
|
|
|