2013-12-19 03:02:51 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
is_public=$3
|
|
|
|
title=$4
|
|
|
|
privatelinkbydefault=$5
|
2013-12-19 18:07:55 +01:00
|
|
|
admin=$6
|
2013-12-19 03:02:51 +01:00
|
|
|
|
2017-02-19 23:17:19 +01:00
|
|
|
# Load common variables and helpers
|
|
|
|
source ./_common.sh
|
|
|
|
|
2014-05-29 12:48:44 +02:00
|
|
|
# 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"
|
2017-02-19 23:17:19 +01:00
|
|
|
exit 1
|
2014-05-29 12:48:44 +02:00
|
|
|
fi
|
|
|
|
sudo yunohost app setting shaarli admin -v $admin
|
2013-12-19 03:02:51 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a shaarli
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2017-02-19 23:17:19 +01:00
|
|
|
exit 1
|
2013-12-19 03:02:51 +01:00
|
|
|
fi
|
|
|
|
|
2013-12-29 17:52:50 +01:00
|
|
|
# Install dependencies
|
2013-12-29 20:00:34 +01:00
|
|
|
sudo apt-get install php5-cli -y -qq
|
2013-12-29 17:52:50 +01:00
|
|
|
|
2013-12-19 03:02:51 +01:00
|
|
|
# Copy files to the right place
|
|
|
|
app_home_path=/home/yunohost.app/shaarli
|
|
|
|
final_path=/var/www/shaarli
|
2017-02-19 23:17:19 +01:00
|
|
|
|
2013-12-19 03:02:51 +01:00
|
|
|
sudo mkdir -p $final_path
|
2017-02-19 23:17:19 +01:00
|
|
|
# Download and extract in /var/www
|
|
|
|
extract_shaarli
|
2013-12-19 03:02:51 +01:00
|
|
|
|
2017-02-19 23:17:19 +01:00
|
|
|
sudo mkdir -p $app_home_path/data
|
|
|
|
sudo mkdir -p $app_home_path/cache
|
|
|
|
sudo mkdir -p $app_home_path/pagecache
|
|
|
|
sudo mkdir -p $app_home_path/tmp
|
|
|
|
sudo mkdir -p $app_home_path/conf
|
|
|
|
sudo chown -R www-data: $app_home_path
|
2013-12-19 03:02:51 +01:00
|
|
|
|
|
|
|
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')
|
2013-12-19 18:07:55 +01:00
|
|
|
if [ $privatelinkbydefault = "No" ]; then
|
2017-02-19 23:17:19 +01:00
|
|
|
privatelinkbydefault_php=false
|
2013-12-19 18:07:55 +01:00
|
|
|
else
|
2017-02-19 23:17:19 +01:00
|
|
|
privatelinkbydefault_php=true
|
2013-12-19 18:07:55 +01:00
|
|
|
fi
|
2013-12-19 03:02:51 +01:00
|
|
|
|
2013-12-19 18:07:55 +01:00
|
|
|
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
|
2013-12-19 03:02:51 +01:00
|
|
|
|
2013-12-19 18:07:55 +01:00
|
|
|
sudo cp ../conf/options.php $app_home_path/data/options.php
|
|
|
|
sudo cp ../conf/init_config.php $app_home_path/data/config.php
|
2015-05-09 00:15:36 +02:00
|
|
|
sudo php ../conf/init_config_user.php $(sudo yunohost user list --json | python ../conf/user_list.py)
|
2013-12-19 03:02:51 +01:00
|
|
|
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
2017-02-19 23:17:19 +01:00
|
|
|
#sudo chown -R root: $final_path
|
2013-12-19 03:02:51 +01:00
|
|
|
|
2013-12-19 18:07:55 +01:00
|
|
|
sudo find $app_home_path -type f | xargs sudo chmod 600
|
|
|
|
sudo find $app_home_path -type d | xargs sudo chmod 700
|
2013-12-19 03:02:51 +01:00
|
|
|
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
|
2013-12-19 18:13:14 +01:00
|
|
|
if [ $is_public = "Yes" ]; then
|
2017-02-19 23:17:19 +01:00
|
|
|
sudo yunohost app setting shaarli unprotected_uris -v "/"
|
2013-12-19 03:02:51 +01:00
|
|
|
fi
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|