mirror of
https://github.com/YunoHost-Apps/shaarli_ynh.git
synced 2024-09-03 20:26:10 +02:00
68 lines
2.1 KiB
Bash
68 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
is_public=$3
|
|
title=$4
|
|
privatelinkbydefault=$5
|
|
admin=$6
|
|
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a shaarli
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Install dependencies
|
|
sudo apt-get install php5-cli -y -qq
|
|
|
|
# Copy files to the right place
|
|
app_home_path=/home/yunohost.app/shaarli
|
|
final_path=/var/www/shaarli
|
|
sudo mkdir -p $final_path
|
|
sudo cp -r ../sources/* $final_path
|
|
|
|
for subdir in data cache pagecache tmp
|
|
do
|
|
sudo mkdir -p $app_home_path/$subdir
|
|
sudo chown -R www-data: $app_home_path/$subdir
|
|
done
|
|
|
|
salt=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|
if [ $privatelinkbydefault = "No" ]; then
|
|
privatelinkbydefault_php=false
|
|
else
|
|
privatelinkbydefault_php=true
|
|
fi
|
|
|
|
sudo sed -i "s@YNH_SALT@$salt@g" ../conf/init_config.php
|
|
sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/init_config.php
|
|
sudo sed -i "s@YNH_TITLE@$title@g" ../conf/init_config.php
|
|
sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/init_config.php
|
|
sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/init_config.php
|
|
|
|
sudo cp ../conf/options.php $app_home_path/data/options.php
|
|
sudo cp ../conf/init_config.php $app_home_path/data/config.php
|
|
sudo php ../conf/init_config_user.php $(sudo yunohost user list | python ../conf/user_list.py)
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
|
sudo chown -R root: $final_path
|
|
|
|
sudo find $app_home_path -type f | xargs sudo chmod 600
|
|
sudo find $app_home_path -type d | xargs sudo chmod 700
|
|
sudo chown -R www-data: $app_home_path
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
sudo sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
|
sudo sed -i "s@YNH_ALIAS@$final_path@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/shaarli.conf
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
if [ $is_public = "Yes" ]; then
|
|
sudo yunohost app setting shaarli unprotected_uris -v "/"
|
|
fi
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|