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

88 lines
2.5 KiB
Text
Raw Normal View History

2016-03-23 19:30:43 +01:00
#! /bin/bash
2016-04-04 22:35:43 +02:00
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
2016-03-23 19:30:43 +01:00
#retrieve arguments
domain=$1
path=$2
admin=$3
2016-03-25 09:49:10 +01:00
is_public=$4
default_lang=$5
2016-03-23 19:30:43 +01:00
2016-04-04 20:01:54 +02:00
# definie useful vars
app=bozon
parent_path=/var/www
final_path=$parent_path/$app
2016-03-23 19:30:43 +01:00
# Remove trailing slash
[ "$path" != "/" ] && path=${path%/}
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check user
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then
echo "Wrong user"
exit 1
fi
# Save app settings
sudo yunohost app setting $app admin -v "$admin"
sudo yunohost app setting $app is_public -v "$is_public"
sudo yunohost app setting $app domain -v "$domain"
sudo yunohost app setting $app path -v "$path"
2016-04-04 20:01:54 +02:00
# Download bozon
2016-04-04 21:36:41 +02:00
sudo wget https://github.com/broncowdd/BoZoN/archive/master.zip -O $parent_path/master.zip
2016-04-04 21:41:27 +02:00
sudo unzip $parent_path/master.zip -d $parent_path/
2016-04-04 21:29:46 +02:00
sudo rm $parent_path/master.zip
sudo mv $parent_path/BoZoN-master $parent_path/$app
2016-03-23 19:30:43 +01:00
2016-03-24 20:10:52 +01:00
# Copy files to final folder and set permissions
2016-03-23 19:30:43 +01:00
sudo find $final_path -type f -name ".htaccess" | xargs sudo rm
sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
2016-03-24 20:10:52 +01:00
# Configure config file
2016-03-25 09:19:48 +01:00
sudo sed -i "s@'en'@'$default_lang'@g" $final_path/config.php
2016-03-24 20:10:52 +01:00
2016-03-25 09:32:16 +01:00
# Create data folders
sudo mkdir -p $final_path/private
sudo mkdir -p $final_path/uploads
sudo mkdir -p $final_path/thumbs
sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $final_path/uploads
sudo chown -R www-data: $final_path/thumbs
2016-03-24 20:10:52 +01:00
# Configure nginx settings
2016-03-23 19:30:43 +01:00
folder_path=${path%/}
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
# If path is only / (without subfolder), add trailing slash to alias
alias_path=$final_path
[ "$path" == '/' ] && alias_path=$alias_path'/'
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is private, remove url to SSOWat conf from skipped_uris
if [ "$is_public" = "No" ];
then
2016-04-04 22:35:43 +02:00
# Redirect to SSOwat login in
sudo yunohost app setting $app unprotected_uris -d
else
sudo yunohost app setting $app unprotected_uris -v "/"
2016-03-23 19:30:43 +01:00
fi
2016-03-24 20:10:52 +01:00
# Adding admin to the allowed users
2016-03-23 19:30:43 +01:00
sudo yunohost app addaccess $app -u $admin
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf